Skip to content

Commit

Permalink
added arcticdem jupyter notebook example
Browse files Browse the repository at this point in the history
  • Loading branch information
jpswinski committed Dec 20, 2022
1 parent 838caf8 commit 1eaa956
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 3 deletions.
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ dependencies:
- geopandas
- h5py
- ipykernel
- ipywidgets>=7.6,<8.0
- ipyleaflet>=0.15
- jupyterlab=3
- ipywidgets
- ipyleaflet
- jupyterlab
- jupyterlab_widgets
- matplotlib
- ipympl
Expand Down
148 changes: 148 additions & 0 deletions examples/arcticdem.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "acb12a75-1636-471a-9649-48a408801d4f",
"metadata": {},
"outputs": [],
"source": [
"from sliderule import icesat2\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"import geopandas"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8167cbe-3fe3-4dc9-a5ad-0cbba51c8a07",
"metadata": {},
"outputs": [],
"source": [
"icesat2.init(\"localhost\", verbose=True, organization=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98ef750a-e88b-4125-b951-d1e29ce50ce2",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"asset = \"nsidc-s3\"\n",
"resource = \"ATL03_20190314093716_11600203_005_01.h5\"\n",
"region = icesat2.toregion(\"../tests/data/dicksonfjord.geojson\")\n",
"parms = { \"poly\": region['poly'],\n",
" \"cnf\": \"atl03_high\",\n",
" \"ats\": 5.0,\n",
" \"cnt\": 5,\n",
" \"len\": 20.0,\n",
" \"res\": 10.0,\n",
" \"maxi\": 1,\n",
" \"samples\": [\"arcticdem-mosaic\"] }\n",
"gdf = icesat2.atl06p(parms, asset=asset, resources=[resource])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0ebba64-93ab-45c8-9c53-cc5078332617",
"metadata": {},
"outputs": [],
"source": [
"gdf[\"delta\"] = gdf[\"h_mean\"] - gdf[\"arcticdem-mosaic-1980-01-06\"]\n",
"gdf[\"delta\"].describe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db8b0b39-b421-46c6-bb5f-7abc6b1168b7",
"metadata": {},
"outputs": [],
"source": [
"# Setup Plot\n",
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
"fig.set_facecolor('white')\n",
"fig.canvas.header_visible = False\n",
"ax.set_title(\"SlideRule vs. ArcticDEM Elevations\")\n",
"ax.set_xlabel('UTC')\n",
"ax.set_ylabel('height (m)')\n",
"legend_elements = []\n",
"\n",
"# Plot SlideRule ATL06 Elevations\n",
"df = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
"sc1 = ax.scatter(df.index.values, df[\"h_mean\"].values, c='red', s=2.5)\n",
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='red', lw=6, label='ATL06-SR'))\n",
"\n",
"# Plot ArcticDEM Elevations\n",
"sc2 = ax.scatter(df.index.values, df[\"arcticdem-mosaic-1980-01-06\"].values, c='blue', s=2.5)\n",
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='blue', lw=6, label='ArcticDEM'))\n",
"\n",
"# Display Legend\n",
"lgd = ax.legend(handles=legend_elements, loc=3, frameon=True)\n",
"lgd.get_frame().set_alpha(1.0)\n",
"lgd.get_frame().set_edgecolor('white')\n",
"\n",
"# Show Plot\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "82c65e28-468e-463e-9afe-2b52064e7bae",
"metadata": {},
"outputs": [],
"source": [
"# Setup Plot\n",
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
"fig.set_facecolor('white')\n",
"fig.canvas.header_visible = False\n",
"ax.set_title(\"Delta Elevations between SlideRule and ArcticDEM\")\n",
"ax.set_xlabel('UTC')\n",
"ax.set_ylabel('height (m)')\n",
"ax.yaxis.grid(True)\n",
"\n",
"# Plot Deltas\n",
"df = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
"sc1 = ax.scatter(df.index.values, df[\"delta\"].values, c='green', s=2.5)\n",
"\n",
"# Show Plot\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eed8f243-dd0c-4473-a952-fcb2bb863e3c",
"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.8.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 1eaa956

Please sign in to comment.