Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49626b7

Browse files
committed
added atl06 subsetting example
1 parent b741d03 commit 49626b7

File tree

2 files changed

+281
-2
lines changed

2 files changed

+281
-2
lines changed

demo/voila_demo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
" atl06_json = json.dumps(atl06_parms, indent=4)\n",
337337
" atl06_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl06_json)\n",
338338
" print('parms = ', atl06_json, sep='')\n",
339-
" print('gdf = icesat2.atl06p(parms, asset=\"icesat2\")')\n",
339+
" print('gdf = icesat2.atl06p(parms)')\n",
340340
" \n",
341341
"# link buttons\n",
342342
"run_button.on_click(on_run_clicked)\n",
@@ -575,7 +575,7 @@
575575
" atl03_json = json.dumps(atl03_parms, indent=4)\n",
576576
" atl03_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl03_json)\n",
577577
" print('parms = ', atl03_json, sep='')\n",
578-
" print('gdf = icesat2.atl03sp(parms, asset=\"icesat2\")')\n",
578+
" print('gdf = icesat2.atl03sp(parms)')\n",
579579
" \n",
580580
"# install click handler callback\n",
581581
"show_code03_button.on_click(on_show_code03_clicked)"

examples/atl06_subsetting.ipynb

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "e243172d-a731-4f1a-ae97-7c7a1fd63757",
6+
"metadata": {
7+
"tags": []
8+
},
9+
"source": [
10+
"# ATL06 Subsetting and On-Demand Product Generation"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"id": "a824b4cc-e7a1-4d4e-be55-13f3a6c8e96e",
16+
"metadata": {},
17+
"source": [
18+
"### Purpose\n",
19+
"Subset ATL06 granule and compare against on-demand generated ATL06 elevations using SlideRule"
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"id": "e5e2efc2-078a-4e37-8083-75994ebf62e8",
25+
"metadata": {
26+
"tags": []
27+
},
28+
"source": [
29+
"#### Import Packages"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"id": "338d80d9-e8f7-40ec-a294-683562437f69",
36+
"metadata": {
37+
"tags": []
38+
},
39+
"outputs": [],
40+
"source": [
41+
"from sliderule import sliderule, icesat2, earthdata"
42+
]
43+
},
44+
{
45+
"cell_type": "markdown",
46+
"id": "7dc950a2-4b0c-4c8f-b7cc-ea6092f8c96e",
47+
"metadata": {
48+
"tags": []
49+
},
50+
"source": [
51+
"#### Configure Logging"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"id": "73e23172-83d2-4bd7-a2e9-84b9ac296037",
58+
"metadata": {
59+
"tags": []
60+
},
61+
"outputs": [],
62+
"source": [
63+
"import logging\n",
64+
"loglevel = logging.CRITICAL\n",
65+
"logging.basicConfig(level=loglevel)"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"id": "613b066a-fbda-4583-a29c-dbe35c182252",
71+
"metadata": {
72+
"tags": []
73+
},
74+
"source": [
75+
"#### Initialize SlideRule Python Client"
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": null,
81+
"id": "0ca128df-4ff0-4b95-ae40-d0a040c9a9db",
82+
"metadata": {
83+
"tags": []
84+
},
85+
"outputs": [],
86+
"source": [
87+
"domain = \"slideruleearth.io\"\n",
88+
"organization = \"uw\"\n",
89+
"sliderule.init(domain, organization=organization, verbose=True, loglevel=loglevel)"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"id": "95e29e39-bef3-4312-8498-f037267da964",
95+
"metadata": {
96+
"tags": []
97+
},
98+
"source": [
99+
"#### Build Request Parameters"
100+
]
101+
},
102+
{
103+
"cell_type": "code",
104+
"execution_count": null,
105+
"id": "3f58197d-5265-4c83-bc62-6049ace71538",
106+
"metadata": {
107+
"tags": []
108+
},
109+
"outputs": [],
110+
"source": [
111+
"granule = '_20181016104402_02720106_006_02.h5'"
112+
]
113+
},
114+
{
115+
"cell_type": "code",
116+
"execution_count": null,
117+
"id": "07da0425-2ebf-41aa-b84d-8f27a508cdbe",
118+
"metadata": {
119+
"tags": []
120+
},
121+
"outputs": [],
122+
"source": [
123+
"region = sliderule.toregion(\"tests/data/grandmesa.geojson\")"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": null,
129+
"id": "3f01b208-4665-47c0-90e3-95834cc61338",
130+
"metadata": {
131+
"tags": []
132+
},
133+
"outputs": [],
134+
"source": [
135+
"parms = {\n",
136+
" \"poly\": region[\"poly\"],\n",
137+
" \"srt\": icesat2.SRT_LAND,\n",
138+
" \"cnf\": icesat2.CNF_SURFACE_HIGH,\n",
139+
" \"ats\": 10.0,\n",
140+
" \"cnt\": 10,\n",
141+
" \"len\": 40.0,\n",
142+
" \"res\": 20.0,\n",
143+
" \"maxi\": 1\n",
144+
"}"
145+
]
146+
},
147+
{
148+
"cell_type": "markdown",
149+
"id": "90bb8070-d857-424a-a100-d1ea32631e82",
150+
"metadata": {
151+
"tags": []
152+
},
153+
"source": [
154+
"#### Make ATL06 Subsetting Request"
155+
]
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": null,
160+
"id": "ecc3f250-0785-4630-a261-13d12ab59819",
161+
"metadata": {
162+
"tags": []
163+
},
164+
"outputs": [],
165+
"source": [
166+
"sdp = icesat2.atl06sp(parms, resources=['ATL06'+granule])\n",
167+
"sdp"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"id": "a0f5c12e-c439-4549-ae7d-61af9954787b",
173+
"metadata": {},
174+
"source": [
175+
"#### Make ATL06 On-Demand Request"
176+
]
177+
},
178+
{
179+
"cell_type": "code",
180+
"execution_count": null,
181+
"id": "d5128cac-5df0-4102-91e5-bb65cce7e0f2",
182+
"metadata": {},
183+
"outputs": [],
184+
"source": [
185+
"sr = icesat2.atl06p(parms, resources=['ATL03_20181016104402_02720106_006_02.h5'])\n",
186+
"sr"
187+
]
188+
},
189+
{
190+
"cell_type": "markdown",
191+
"id": "0b5a2b18-f3fb-48bc-90d2-53350638d1dc",
192+
"metadata": {
193+
"tags": []
194+
},
195+
"source": [
196+
"#### Plot Results"
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"id": "61c365cf-6bab-408c-8b2f-49a3d896692b",
203+
"metadata": {
204+
"tags": []
205+
},
206+
"outputs": [],
207+
"source": [
208+
"# Import Plotting Library\n",
209+
"import matplotlib.pyplot as plt\n",
210+
"import matplotlib"
211+
]
212+
},
213+
{
214+
"cell_type": "code",
215+
"execution_count": null,
216+
"id": "64bc423d-2348-4217-804f-63119ff71d16",
217+
"metadata": {
218+
"tags": []
219+
},
220+
"outputs": [],
221+
"source": [
222+
"# Setup Plot\n",
223+
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
224+
"fig.set_facecolor('white')\n",
225+
"fig.canvas.header_visible = False\n",
226+
"ax.set_title(\"SlideRule vs. Standard Data Product Elevations\")\n",
227+
"ax.set_xlabel('UTC')\n",
228+
"ax.set_ylabel('height (m)')\n",
229+
"legend_elements = []\n",
230+
"\n",
231+
"# Plot SlideRule ATL06 Elevations\n",
232+
"sc1 = ax.scatter(sr.index.values, sr[\"h_mean\"].values, c='red', s=2.5)\n",
233+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='red', lw=6, label='SR'))\n",
234+
"\n",
235+
"# Plot SDP ATL06 Elevations\n",
236+
"sdp_filtered = sdp[sdp[\"h_li\"] < 10000]\n",
237+
"sc2 = ax.scatter(sdp_filtered.index.values, sdp_filtered[\"h_li\"].values, c='blue', s=2.5)\n",
238+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='blue', lw=6, label='SDP'))\n",
239+
"\n",
240+
"# Display Legend\n",
241+
"lgd = ax.legend(handles=legend_elements, loc=3, frameon=True)\n",
242+
"lgd.get_frame().set_alpha(1.0)\n",
243+
"lgd.get_frame().set_edgecolor('white')\n",
244+
"\n",
245+
"# Show Plot\n",
246+
"plt.show()"
247+
]
248+
},
249+
{
250+
"cell_type": "code",
251+
"execution_count": null,
252+
"id": "04137254-5356-4f1d-9438-2126063f2258",
253+
"metadata": {},
254+
"outputs": [],
255+
"source": []
256+
}
257+
],
258+
"metadata": {
259+
"kernelspec": {
260+
"display_name": "Python 3 (ipykernel)",
261+
"language": "python",
262+
"name": "python3"
263+
},
264+
"language_info": {
265+
"codemirror_mode": {
266+
"name": "ipython",
267+
"version": 3
268+
},
269+
"file_extension": ".py",
270+
"mimetype": "text/x-python",
271+
"name": "python",
272+
"nbconvert_exporter": "python",
273+
"pygments_lexer": "ipython3",
274+
"version": "3.11.3"
275+
}
276+
},
277+
"nbformat": 4,
278+
"nbformat_minor": 5
279+
}

0 commit comments

Comments
 (0)