Skip to content

Commit 586bf2c

Browse files
committed
Merge branch 'development' of github.com:ICESat2-SlideRule/sliderule-python into development
2 parents 73f5f74 + d829363 commit 586bf2c

16 files changed

+517
-162
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Example usage:
3333
from sliderule import icesat2
3434

3535
# initialize
36-
icesat2.init("slideruleearth.io", verbose=True)
36+
icesat2.init("slideruleearth.io", verbose=False)
3737

3838
# region of interest
3939
region = [ {"lon":-105.82971551223244, "lat": 39.81983728534918},

environment.yml

Lines changed: 4 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
@@ -25,5 +25,6 @@ dependencies:
2525
- shapely
2626
- tk
2727
- xyzservices
28+
- pyarrow
2829
- pip:
2930
- -e ./

examples/arcticdem.ipynb

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
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(\"slideruleearth.io\", verbose=True)"
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\": {\"mosaic\": {\"asset\": \"arcticdem-mosaic\", \"radius\": 10.0, \"zonal_stats\": True}} }\n",
46+
"gdf = icesat2.atl06p(parms, asset=asset, resources=[resource])"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"id": "fd15bf14-ab10-4cf6-9524-592962a8f8b2",
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"gdf"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": null,
62+
"id": "59ea096b-3443-4b9a-b114-e818f143ca45",
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"gdf[\"value_delta\"] = gdf[\"h_mean\"] - gdf[\"mosaic.value\"]\n",
67+
"gdf[\"value_delta\"].describe()"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"id": "f80cd750-9b91-406a-ac6a-dc04937cd811",
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"gdf[\"mean_delta\"] = gdf[\"h_mean\"] - gdf[\"mosaic.mean\"]\n",
78+
"gdf[\"mean_delta\"].describe()"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"id": "4e8fe135-bc15-4b8b-887f-ae16ac81487f",
85+
"metadata": {},
86+
"outputs": [],
87+
"source": [
88+
"gdf[\"median_delta\"] = gdf[\"h_mean\"] - gdf[\"mosaic.median\"]\n",
89+
"gdf[\"median_delta\"].describe()"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"id": "d6785ed8-cb0d-49cb-9de1-30ac5792884a",
96+
"metadata": {},
97+
"outputs": [],
98+
"source": [
99+
"# Setup Plot\n",
100+
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
101+
"fig.set_facecolor('white')\n",
102+
"fig.canvas.header_visible = False\n",
103+
"ax.set_title(\"SlideRule vs. ArcticDEM Elevations\")\n",
104+
"ax.set_xlabel('UTC')\n",
105+
"ax.set_ylabel('height (m)')\n",
106+
"legend_elements = []\n",
107+
"\n",
108+
"# Plot SlideRule ATL06 Elevations\n",
109+
"df = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
110+
"sc1 = ax.scatter(df.index.values, df[\"h_mean\"].values, c='red', s=2.5)\n",
111+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='red', lw=6, label='ATL06-SR'))\n",
112+
"\n",
113+
"# Plot ArcticDEM Elevations\n",
114+
"sc2 = ax.scatter(df.index.values, df[\"mosaic.value\"].values, c='blue', s=2.5)\n",
115+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='blue', lw=6, label='ArcticDEM'))\n",
116+
"\n",
117+
"# Plot ArcticDEM Mean Elevations\n",
118+
"sc2 = ax.scatter(df.index.values, df[\"mosaic.value\"].values, c='green', s=2.5)\n",
119+
"legend_elements.append(matplotlib.lines.Line2D([0], [0], color='green', lw=6, label='ArcticDEM'))\n",
120+
"\n",
121+
"# Display Legend\n",
122+
"lgd = ax.legend(handles=legend_elements, loc=3, frameon=True)\n",
123+
"lgd.get_frame().set_alpha(1.0)\n",
124+
"lgd.get_frame().set_edgecolor('white')\n",
125+
"\n",
126+
"# Show Plot\n",
127+
"plt.show()"
128+
]
129+
},
130+
{
131+
"cell_type": "code",
132+
"execution_count": null,
133+
"id": "82c65e28-468e-463e-9afe-2b52064e7bae",
134+
"metadata": {},
135+
"outputs": [],
136+
"source": [
137+
"# Setup Plot\n",
138+
"fig,ax = plt.subplots(num=None, figsize=(10, 8))\n",
139+
"fig.set_facecolor('white')\n",
140+
"fig.canvas.header_visible = False\n",
141+
"ax.set_title(\"Delta Elevations between SlideRule and ArcticDEM\")\n",
142+
"ax.set_xlabel('UTC')\n",
143+
"ax.set_ylabel('height (m)')\n",
144+
"ax.yaxis.grid(True)\n",
145+
"\n",
146+
"# Plot Deltas\n",
147+
"df1 = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
148+
"sc1 = ax.scatter(df1.index.values, df1[\"value_delta\"].values, c='blue', s=2.5)\n",
149+
"\n",
150+
"# Plot Deltas\n",
151+
"df2 = gdf[(gdf['rgt'] == 1160) & (gdf['gt'] == 10) & (gdf['cycle'] == 2)]\n",
152+
"sc2 = ax.scatter(df2.index.values, df2[\"mean_delta\"].values, c='green', s=2.5)\n",
153+
"\n",
154+
"# Show Plot\n",
155+
"plt.show()"
156+
]
157+
},
158+
{
159+
"cell_type": "code",
160+
"execution_count": null,
161+
"id": "eed8f243-dd0c-4473-a952-fcb2bb863e3c",
162+
"metadata": {},
163+
"outputs": [],
164+
"source": []
165+
}
166+
],
167+
"metadata": {
168+
"kernelspec": {
169+
"display_name": "Python 3 (ipykernel)",
170+
"language": "python",
171+
"name": "python3"
172+
},
173+
"language_info": {
174+
"codemirror_mode": {
175+
"name": "ipython",
176+
"version": 3
177+
},
178+
"file_extension": ".py",
179+
"mimetype": "text/x-python",
180+
"name": "python",
181+
"nbconvert_exporter": "python",
182+
"pygments_lexer": "ipython3",
183+
"version": "3.8.15"
184+
}
185+
},
186+
"nbformat": 4,
187+
"nbformat_minor": 5
188+
}

examples/voila_demo.ipynb

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"import warnings\n",
7474
"import time\n",
7575
"import json\n",
76-
"from IPython.display import clear_output\n",
76+
"from IPython import display\n",
7777
"# atl03 plotting imports\n",
7878
"import numpy as np\n",
7979
"import matplotlib.lines\n",
@@ -158,12 +158,18 @@
158158
},
159159
"outputs": [],
160160
"source": [
161-
"# create ipyleaflet map in specified projection\n",
162-
"m = ipysliderule.leaflet(SRwidgets.projection.value)\n",
163-
"# install click handler callback\n",
164-
"m.add_selected_callback(SRwidgets.atl06_click_handler)\n",
165-
"display(m.map)\n",
166-
"display(run_output)"
161+
"def create_map(projection):\n",
162+
" # create ipyleaflet map in specified projection\n",
163+
" global m\n",
164+
" m = ipysliderule.leaflet(projection)\n",
165+
" # install click handler callback\n",
166+
" m.add_selected_callback(SRwidgets.atl06_click_handler)\n",
167+
" display.display(m.map)\n",
168+
"\n",
169+
"# interactively change map when projection widget is changed\n",
170+
"out = widgets.interactive_output(create_map, dict(projection=SRwidgets.projection))\n",
171+
"display.display(out)\n",
172+
"display.display(run_output)"
167173
]
168174
},
169175
{
@@ -189,17 +195,17 @@
189195
" layers=SRwidgets.layers.value,\n",
190196
" rendering_rule=SRwidgets.rendering_rule\n",
191197
" )\n",
192-
" \n",
198+
"\n",
193199
"# map widgets\n",
194-
"display(widgets.VBox([\n",
200+
"display.display(widgets.VBox([\n",
195201
" SRwidgets.projection,\n",
196202
" SRwidgets.layers,\n",
197203
" SRwidgets.raster_functions\n",
198204
"]))\n",
199205
"\n",
200206
"# update button\n",
201207
"update_button.on_click(on_update_clicked)\n",
202-
"display(update_button)"
208+
"display.display(update_button)"
203209
]
204210
},
205211
{
@@ -317,7 +323,7 @@
317323
"def on_show_code06_clicked(b):\n",
318324
" global url_textbox, atl06_parms\n",
319325
" with show_code06_output:\n",
320-
" clear_output()\n",
326+
" display.clear_output()\n",
321327
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
322328
" print('parms = ', json.dumps(atl06_parms, indent=4), sep='')\n",
323329
" print('gdf = icesat2.atl06p(parms, asset=\"nsidc-s3\")')\n",
@@ -355,7 +361,7 @@
355361
" description='URL:',\n",
356362
" disabled=False\n",
357363
")\n",
358-
"display(url_textbox)\n",
364+
"display.display(url_textbox)\n",
359365
"\n",
360366
"# points to plot drop down\n",
361367
"points_dropdown = widgets.Dropdown(\n",
@@ -366,7 +372,7 @@
366372
")\n",
367373
"\n",
368374
"# display widgets for setting SlideRule parameters\n",
369-
"display(widgets.VBox([\n",
375+
"display.display(widgets.VBox([\n",
370376
" SRwidgets.surface_type,\n",
371377
" SRwidgets.length,\n",
372378
" SRwidgets.step,\n",
@@ -384,9 +390,9 @@
384390
"]))\n",
385391
"\n",
386392
"# display buttons\n",
387-
"display(run_button)\n",
388-
"display(refresh_button, refresh_output)\n",
389-
"display(show_code06_button, show_code06_output)"
393+
"display.display(run_button)\n",
394+
"display.display(refresh_button, refresh_output)\n",
395+
"display.display(show_code06_button, show_code06_output)"
390396
]
391397
},
392398
{
@@ -553,7 +559,7 @@
553559
"def on_show_code03_clicked(b):\n",
554560
" global url_textbox, atl03_parms\n",
555561
" with show_code03_output:\n",
556-
" clear_output()\n",
562+
" display.clear_output()\n",
557563
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
558564
" print('parms = ', json.dumps(atl03_parms, indent=4), sep='')\n",
559565
" print('gdf = icesat2.atl03sp(parms, asset=\"nsidc-s3\")')\n",
@@ -590,14 +596,14 @@
590596
" disabled = False,\n",
591597
")\n",
592598
"\n",
593-
"display(SRwidgets.rgt)\n",
594-
"display(SRwidgets.cycle)\n",
595-
"display(SRwidgets.ground_track)\n",
596-
"display(SRwidgets.plot_classification)\n",
597-
"display(elev_dropdown)\n",
598-
"display(pc_button)\n",
599-
"display(pc_output)\n",
600-
"display(show_code03_button, show_code03_output)"
599+
"display.display(SRwidgets.rgt)\n",
600+
"display.display(SRwidgets.cycle)\n",
601+
"display.display(SRwidgets.ground_track)\n",
602+
"display.display(SRwidgets.plot_classification)\n",
603+
"display.display(elev_dropdown)\n",
604+
"display.display(pc_button)\n",
605+
"display.display(pc_output)\n",
606+
"display.display(show_code03_button, show_code03_output)"
601607
]
602608
}
603609
],
@@ -635,7 +641,7 @@
635641
"name": "python",
636642
"nbconvert_exporter": "python",
637643
"pygments_lexer": "ipython3",
638-
"version": "3.8.15"
644+
"version": "3.10.6"
639645
},
640646
"toc-showtags": false
641647
},

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ numpy
33
fiona
44
geopandas
55
shapely
6-
scikit-learn
6+
scikit-learn
7+
pyarrow

0 commit comments

Comments
 (0)