Skip to content

Commit 2c4b16a

Browse files
Merge pull request #33 from carbonplan/s3_update
Updates Azure sources to s3
2 parents ae6481c + 8b1aae0 commit 2c4b16a

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

offset-project-fire/buffer_pool_analysis.ipynb

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
37+
"import intake\n",
3738
"import numpy as np\n",
3839
"import pandas as pd\n",
39-
"import intake\n",
40-
"\n",
41-
"from carbonplan_styles.mpl import set_theme\n",
4240
"from carbonplan_styles.colors import colors\n",
41+
"from carbonplan_styles.mpl import set_theme\n",
4342
"\n",
4443
"# set options\n",
4544
"set_theme(style=\"carbonplan_light\")\n",
@@ -60,7 +59,7 @@
6059
"outputs": [],
6160
"source": [
6261
"df = pd.read_excel(\n",
63-
" \"https://carbonplan.blob.core.windows.net/carbonplan-articles/offset-project-fire/arboc_issuance.xlsx\",\n",
62+
" \"https://carbonplan-articles.s3.us-west-2.amazonaws.com/offset-project-fire/arboc_issuance.xlsx\",\n",
6463
" sheet_name=3,\n",
6564
" engine=\"openpyxl\",\n",
6665
")\n",
@@ -100,11 +99,7 @@
10099
"metadata": {},
101100
"outputs": [],
102101
"source": [
103-
"df = df[\n",
104-
" ~df[\"Forest Buffer Account Contribution\"].apply(\n",
105-
" lambda x: isinstance(x, str)\n",
106-
" )\n",
107-
"]\n",
102+
"df = df[~df[\"Forest Buffer Account Contribution\"].apply(lambda x: isinstance(x, str))]\n",
108103
"df = df[df[\"ARB Offset Credits Issued\"] > 0]\n",
109104
"forest_df = df[df[\"Project Type\"] == \"Forest\"]\n",
110105
"\n",
@@ -254,15 +249,11 @@
254249
"perc_credits[\"state\"] = perc_credits.index.map(proj_state_map)\n",
255250
"perc_credits = perc_credits.rename(\n",
256251
" # clean up column title\n",
257-
" columns={\n",
258-
" \"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"\n",
259-
" }\n",
252+
" columns={\"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"}\n",
260253
")\n",
261254
"\n",
262255
"proj_loc = perc_credits.index.get_loc(proj_id)\n",
263-
"display(\n",
264-
" perc_credits[: proj_loc + 1]\n",
265-
") # +1 to include ACR260, otherwise off by one"
256+
"display(perc_credits[: proj_loc + 1]) # +1 to include ACR260, otherwise off by one"
266257
]
267258
},
268259
{
@@ -298,15 +289,11 @@
298289
"sorted_credits[\"state\"] = sorted_credits.index.map(proj_state_map)\n",
299290
"sorted_credits = sorted_credits.rename(\n",
300291
" # clean up column title\n",
301-
" columns={\n",
302-
" \"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"\n",
303-
" }\n",
292+
" columns={\"ARB Offset Credits Issued\": \"Percent Forest ARB Offset Credits Issued\"}\n",
304293
")\n",
305294
"\n",
306295
"proj_loc = sorted_credits.index.get_loc(proj_id)\n",
307-
"display(\n",
308-
" sorted_credits[: proj_loc + 1]\n",
309-
") # +1 to include ACR260, otherwise off by one"
296+
"display(sorted_credits[: proj_loc + 1]) # +1 to include ACR260, otherwise off by one"
310297
]
311298
},
312299
{

offset-project-fire/catalog.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sources:
2424
allowed: [noaa, suomi, modis]
2525
driver: geojson
2626
args:
27-
urlpath: 'https://carbonplan.blob.core.windows.net/carbonplan-articles/offset-project-fire/lionshead-{{sensor}}.json'
27+
urlpath: 'hhttps://carbonplan-articles.s3.us-west-2.amazonaws.com/offset-project-fire/lionshead-{{sensor}}.json'
2828

2929
project:
3030
metadata:
@@ -41,7 +41,7 @@ sources:
4141
url: https://americancarbonregistry.org/
4242
driver: geojson
4343
args:
44-
urlpath: 'https://carbonplan.blob.core.windows.net/carbonplan-articles/offset-project-fire/carb_project_geometry.json'
44+
urlpath: 'https://carbonplan-articles.s3.us-west-2.amazonaws.com/offset-project-fire/carb_project_geometry.json'
4545

4646
arboc_issuance:
4747
metadata:
@@ -58,4 +58,4 @@ sources:
5858
url: https://ww2.arb.ca.gov/
5959
driver: csv
6060
args:
61-
urlpath: 'https://carbonplan.blob.core.windows.net/carbonplan-articles/offset-project-fire/arb_offset_credit_issuance.csv'
61+
urlpath: 'https://carbonplan-articles.s3.us-west-2.amazonaws.com/offset-project-fire/arb_offset_credit_issuance.csv'

offset-project-fire/fire_analysis.ipynb

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
"import copy\n",
5757
"import os\n",
5858
"\n",
59-
"from carbonplan_styles.colors import colors\n",
6059
"import fsspec\n",
6160
"import geopandas\n",
6261
"import hvplot.pandas\n",
6362
"import intake\n",
6463
"import pandas as pd\n",
6564
"import pyproj\n",
6665
"import shapely\n",
66+
"from carbonplan_styles.colors import colors\n",
6767
"from shapely.ops import cascaded_union\n",
6868
"\n",
6969
"# plot styles\n",
@@ -79,7 +79,7 @@
7979
"# open our data catalog\n",
8080
"cat = intake.open_catalog(\"./catalog.yaml\")\n",
8181
"\n",
82-
"write_to_azure = False"
82+
"write_to_s3 = False"
8383
]
8484
},
8585
{
@@ -244,9 +244,7 @@
244244
"source": [
245245
"burned_poly = cascaded_union(full_res.geometry.values)\n",
246246
"burned_gdf = (\n",
247-
" geopandas.GeoDataFrame.from_dict(\n",
248-
" {\"row\": {\"geometry\": burned_poly}}, orient=\"index\"\n",
249-
" )\n",
247+
" geopandas.GeoDataFrame.from_dict({\"row\": {\"geometry\": burned_poly}}, orient=\"index\")\n",
250248
" .set_geometry(\"geometry\")\n",
251249
" .set_crs(working_crs)\n",
252250
")"
@@ -310,10 +308,7 @@
310308
"\n",
311309
"burned_project_area = burned_project.area.sum()\n",
312310
"print(\"Burned Project Area: %.2f m2\" % burned_project_area)\n",
313-
"print(\n",
314-
" \"Percent Project Burned: %.2f%%\"\n",
315-
" % (burned_project_area / project_area * 100)\n",
316-
")"
311+
"print(\"Percent Project Burned: %.2f%%\" % (burned_project_area / project_area * 100))"
317312
]
318313
},
319314
{
@@ -323,13 +318,10 @@
323318
"outputs": [],
324319
"source": [
325320
"# dump the polygons out to a geojson file for use in the article.\n",
326-
"if write_to_azure:\n",
327-
" # blob file system\n",
328-
" from adlfs import AzureBlobFileSystem\n",
321+
"if write_to_s3:\n",
322+
" import s3fs\n",
329323
"\n",
330-
" fs = AzureBlobFileSystem(\n",
331-
" account_name=\"carbonplan\", account_key=os.environ[\"BLOB_ACCOUNT_KEY\"]\n",
332-
" )\n",
324+
" fs = s3fs.s3fs.S3FileSystem()\n",
333325
" with fs.open(\n",
334326
" \"carbonplan-articles/offset-project-fire/lionshead_fire_polygons.json\",\n",
335327
" \"w\",\n",

0 commit comments

Comments
 (0)