Skip to content

Commit 1eaa956

Browse files
committed
added arcticdem jupyter notebook example
1 parent 838caf8 commit 1eaa956

File tree

2 files changed

+151
-3
lines changed

2 files changed

+151
-3
lines changed

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ dependencies:
66
- geopandas
77
- h5py
88
- ipykernel
9-
- ipywidgets>=7.6,<8.0
10-
- ipyleaflet>=0.15
11-
- jupyterlab=3
9+
- ipywidgets
10+
- ipyleaflet
11+
- jupyterlab
1212
- jupyterlab_widgets
1313
- matplotlib
1414
- ipympl

examples/arcticdem.ipynb

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "acb12a75-1636-471a-9649-48a408801d4f",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from sliderule import icesat2\n",
11+
"import matplotlib.pyplot as plt\n",
12+
"import matplotlib\n",
13+
"import geopandas"
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": null,
19+
"id": "b8167cbe-3fe3-4dc9-a5ad-0cbba51c8a07",
20+
"metadata": {},
21+
"outputs": [],
22+
"source": [
23+
"icesat2.init(\"localhost\", verbose=True, organization=None)"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"id": "98ef750a-e88b-4125-b951-d1e29ce50ce2",
30+
"metadata": {
31+
"tags": []
32+
},
33+
"outputs": [],
34+
"source": [
35+
"asset = \"nsidc-s3\"\n",
36+
"resource = \"ATL03_20190314093716_11600203_005_01.h5\"\n",
37+
"region = icesat2.toregion(\"../tests/data/dicksonfjord.geojson\")\n",
38+
"parms = { \"poly\": region['poly'],\n",
39+
" \"cnf\": \"atl03_high\",\n",
40+
" \"ats\": 5.0,\n",
41+
" \"cnt\": 5,\n",
42+
" \"len\": 20.0,\n",
43+
" \"res\": 10.0,\n",
44+
" \"maxi\": 1,\n",
45+
" \"samples\": [\"arcticdem-mosaic\"] }\n",
46+
"gdf = icesat2.atl06p(parms, asset=asset, resources=[resource])"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"id": "d0ebba64-93ab-45c8-9c53-cc5078332617",
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"gdf[\"delta\"] = gdf[\"h_mean\"] - gdf[\"arcticdem-mosaic-1980-01-06\"]\n",
57+
"gdf[\"delta\"].describe()"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"id": "db8b0b39-b421-46c6-bb5f-7abc6b1168b7",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"# Setup Plot\n",
68+
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
69+
"fig.set_facecolor('white')\n",
70+
"fig.canvas.header_visible = False\n",
71+
"ax.set_title(\"SlideRule vs. ArcticDEM Elevations\")\n",
72+
"ax.set_xlabel('UTC')\n",
73+
"ax.set_ylabel('height (m)')\n",
74+
"legend_elements = []\n",
75+
"\n",
76+
"# Plot SlideRule ATL06 Elevations\n",
77+
"df = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
78+
"sc1 = ax.scatter(df.index.values, df[\"h_mean\"].values, c='red', s=2.5)\n",
79+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='red', lw=6, label='ATL06-SR'))\n",
80+
"\n",
81+
"# Plot ArcticDEM Elevations\n",
82+
"sc2 = ax.scatter(df.index.values, df[\"arcticdem-mosaic-1980-01-06\"].values, c='blue', s=2.5)\n",
83+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='blue', lw=6, label='ArcticDEM'))\n",
84+
"\n",
85+
"# Display Legend\n",
86+
"lgd = ax.legend(handles=legend_elements, loc=3, frameon=True)\n",
87+
"lgd.get_frame().set_alpha(1.0)\n",
88+
"lgd.get_frame().set_edgecolor('white')\n",
89+
"\n",
90+
"# Show Plot\n",
91+
"plt.show()"
92+
]
93+
},
94+
{
95+
"cell_type": "code",
96+
"execution_count": null,
97+
"id": "82c65e28-468e-463e-9afe-2b52064e7bae",
98+
"metadata": {},
99+
"outputs": [],
100+
"source": [
101+
"# Setup Plot\n",
102+
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
103+
"fig.set_facecolor('white')\n",
104+
"fig.canvas.header_visible = False\n",
105+
"ax.set_title(\"Delta Elevations between SlideRule and ArcticDEM\")\n",
106+
"ax.set_xlabel('UTC')\n",
107+
"ax.set_ylabel('height (m)')\n",
108+
"ax.yaxis.grid(True)\n",
109+
"\n",
110+
"# Plot Deltas\n",
111+
"df = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
112+
"sc1 = ax.scatter(df.index.values, df[\"delta\"].values, c='green', s=2.5)\n",
113+
"\n",
114+
"# Show Plot\n",
115+
"plt.show()"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"id": "eed8f243-dd0c-4473-a952-fcb2bb863e3c",
122+
"metadata": {},
123+
"outputs": [],
124+
"source": []
125+
}
126+
],
127+
"metadata": {
128+
"kernelspec": {
129+
"display_name": "Python 3 (ipykernel)",
130+
"language": "python",
131+
"name": "python3"
132+
},
133+
"language_info": {
134+
"codemirror_mode": {
135+
"name": "ipython",
136+
"version": 3
137+
},
138+
"file_extension": ".py",
139+
"mimetype": "text/x-python",
140+
"name": "python",
141+
"nbconvert_exporter": "python",
142+
"pygments_lexer": "ipython3",
143+
"version": "3.8.15"
144+
}
145+
},
146+
"nbformat": 4,
147+
"nbformat_minor": 5
148+
}

0 commit comments

Comments
 (0)