Skip to content

Commit

Permalink
updated examples to use latest asset directory; added gedi l2a and l1…
Browse files Browse the repository at this point in the history
…b example notebooks
  • Loading branch information
jpswinski committed Apr 20, 2023
1 parent f1912ac commit db7e6f2
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 18 deletions.
4 changes: 2 additions & 2 deletions demo/voila_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
" display.clear_output()\n",
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
" print('parms = ', json.dumps(atl06_parms, indent=4), sep='')\n",
" print('gdf = icesat2.atl06p(parms, asset=\"nsidc-s3\")')\n",
" print('gdf = icesat2.atl06p(parms, asset=\"icesat2\")')\n",
" \n",
"# link buttons\n",
"run_button.on_click(on_run_clicked)\n",
Expand Down Expand Up @@ -571,7 +571,7 @@
" display.clear_output()\n",
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
" print('parms = ', json.dumps(atl03_parms, indent=4), sep='')\n",
" print('gdf = icesat2.atl03sp(parms, asset=\"nsidc-s3\")')\n",
" print('gdf = icesat2.atl03sp(parms, asset=\"icesat2\")')\n",
" \n",
"# install click handler callback\n",
"show_code03_button.on_click(on_show_code03_clicked)"
Expand Down
2 changes: 1 addition & 1 deletion examples/api_widgets_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"### Build and transmit requests to SlideRule\n",
"\n",
"- SlideRule will query the [NASA Common Metadata Repository (CMR)](https://cmr.earthdata.nasa.gov/) for ATL03 data within our region of interest\n",
"- When using the `nsidc-s3` asset, the ICESat-2 ATL03 data are then accessed from the NSIDC AWS s3 bucket in `us-west-2`\n",
"- When using the `icesat2` asset, the ICESat-2 ATL03 data are then accessed from the NSIDC AWS s3 bucket in `us-west-2`\n",
"- The ATL03 granules is spatially subset within SlideRule to our exact region of interest\n",
"- SlideRule then uses our specified parameters to calculate average height segments from the ATL03 data in parallel\n",
"- The completed data is streamed concurrently back and combined into a geopandas GeoDataFrame within the Python client"
Expand Down
17 changes: 12 additions & 5 deletions examples/arcticdem_mosaic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"cell_type": "code",
"execution_count": null,
"id": "9dada6f9-e621-4a3a-825b-065ef6846645",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
Expand All @@ -44,10 +46,13 @@
"cell_type": "code",
"execution_count": null,
"id": "93edfc47-1cd5-4927-962c-fd447c9e807a",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"icesat2.init(\"slideruleearth.io\", verbose=True)"
"#icesat2.init(\"slideruleearth.io\", verbose=True)\n",
"icesat2.init(\"localhost\", verbose=True, organization=None)"
]
},
{
Expand All @@ -70,7 +75,7 @@
},
"outputs": [],
"source": [
"asset = \"nsidc-s3\"\n",
"asset = \"icesat2\"\n",
"resource = \"ATL03_20190314093716_11600203_005_01.h5\"\n",
"region = sliderule.toregion(\"../data/dicksonfjord.geojson\")\n",
"parms = { \"poly\": region['poly'],\n",
Expand All @@ -97,7 +102,9 @@
"cell_type": "code",
"execution_count": null,
"id": "e19bae20-140e-4d55-bb73-64a9630096d1",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"gdf"
Expand Down
2 changes: 1 addition & 1 deletion examples/arcticdem_strip_boundaries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
" \"time_start\":'2020-01-01',\n",
" \"time_end\":'2021-01-01',\n",
" \"samples\": {\"strips\": {\"asset\": \"arcticdem-strips\", \"with_flags\": True}} }\n",
"gdf = icesat2.atl06p(parms, asset=\"nsidc-s3\")"
"gdf = icesat2.atl06p(parms, asset=\"icesat2\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/atl03_widgets_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"metadata": {},
"source": [
"### Transmit requests to SlideRule\n",
"- When using the `nsidc-s3` asset, the ICESat-2 ATL03 data are then accessed from the NSIDC AWS s3 bucket in `us-west-2`\n",
"- When using the `icesat2` asset, the ICESat-2 ATL03 data are then accessed from the NSIDC AWS s3 bucket in `us-west-2`\n",
"- The ATL03 granules is spatially subset within SlideRule to our exact region of interest\n",
"- Photon classification parameters can then be extracted or calculated for our ATL03 data\n",
"- The completed data is streamed concurrently back and combined into a geopandas GeoDataFrame within the Python client"
Expand Down
2 changes: 1 addition & 1 deletion examples/cmr_debug_regions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"source": [
"def s3_retrieve(granule, **kwargs):\n",
" # set default keyword arguments\n",
" kwargs.setdefault('asset','nsidc-s3')\n",
" kwargs.setdefault('asset','icesat2')\n",
" kwargs.setdefault('index_key','time')\n",
" kwargs.setdefault('polygon',None)\n",
" # regular expression operator for extracting information from files\n",
Expand Down
150 changes: 150 additions & 0 deletions examples/gedi_l1b.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0e7a3594-2353-476d-a42a-b6bf1b279c61",
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"import matplotlib.pyplot as plt\n",
"from sliderule import gedi\n",
"from sliderule import earthdata\n",
"import sliderule"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "54acbd2a-23d8-4cb9-ac06-b3893a3b45db",
"metadata": {},
"outputs": [],
"source": [
"# initialize client (notebook only processes one granule, so one node is sufficient)\n",
"#gedi.init(\"slideruleearth.io\", verbose=True)\n",
"gedi.init(\"localhost\", verbose=True, organization=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1421300-b0d1-4139-928e-f8bc612a8ac9",
"metadata": {},
"outputs": [],
"source": [
"# Specify region of interest from geojson\n",
"poly_fn = 'grandmesa.geojson'\n",
"region = sliderule.toregion(poly_fn)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "720dc13b-c6af-4580-ac55-ab4c5263b96e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"granules = earthdata.cmr(short_name=\"GEDI01_B\", polygon=region[\"poly\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a46a84ed-05f5-47b8-b4b7-d063dacfddde",
"metadata": {},
"outputs": [],
"source": [
"# Build GEDI L4A Request Parameters\n",
"parms = {\n",
" \"poly\": region[\"poly\"],\n",
" \"degrade_flag\": 0,\n",
" \"quality_flag\": 1,\n",
" \"beam\": 0\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "02682045-e626-4864-b4eb-1ed04d77d778",
"metadata": {},
"outputs": [],
"source": [
"# Latch Start Time\n",
"perf_start = time.perf_counter()\n",
"\n",
"# Request GEDI Data\n",
"gedi01b = gedi.gedi01bp(parms, resources=['GEDI01_B_2019109210809_O01988_03_T02056_02_005_01_V002.h5'])\n",
" \n",
"# Latch Stop Time\n",
"perf_stop = time.perf_counter()\n",
"\n",
"# Display Statistics\n",
"perf_duration = perf_stop - perf_start\n",
"print(\"Completed in {:.3f} seconds of wall-clock time\".format(perf_duration))\n",
"print(\"Received {} footprints\".format(gedi01b.shape[0]))\n",
"if len(gedi01b) > 0:\n",
" print(\"Beams: {}\".format(gedi01b[\"beam\"].unique()))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "92d482e1-08e2-49a4-9ff7-155b7952e178",
"metadata": {},
"outputs": [],
"source": [
"gedi01b"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eeade03e-0dc7-42fe-a879-8e59cce8e6af",
"metadata": {},
"outputs": [],
"source": [
"# plot elevations\n",
"f, ax = plt.subplots(1, 2, figsize=[12,8])\n",
"ax[0].set_title(\"Elevation of First Bin\")\n",
"ax[0].set_aspect('equal')\n",
"gedi01b.plot(ax=ax[0], column='elevation_start', cmap='inferno', s=0.1)\n",
"ax[1].set_title(\"Elevation of Last Bin\")\n",
"ax[1].set_aspect('equal')\n",
"gedi01b.plot(ax=ax[1], column='elevation_stop', cmap='inferno', s=0.1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b7243ae5-f3bb-4219-8486-bde773f4effa",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit db7e6f2

Please sign in to comment.