Skip to content

Commit 5559772

Browse files
committed
Merge branch 'development' of github.com:ICESat2-SlideRule/sliderule-python into development
2 parents 7c0690b + 6c92ec1 commit 5559772

File tree

10 files changed

+398
-120
lines changed

10 files changed

+398
-120
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@ dmypy.json
130130

131131
# User
132132
.vscode/
133-
pytrace.*
133+
.DS_Store
134+
.DS_Store?
135+
pytrace.*

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# sliderule-python
22
[![Tests](https://github.com/ICESat2-SlideRule/sliderule-python/actions/workflows/test.yml/badge.svg)](https://github.com/ICESat2-SlideRule/sliderule-python/actions/workflows/test.yml)
3+
[![Read the Docs](https://readthedocs.org/projects/sliderule-python/badge/?version=latest)](https://slideruleearth.io/rtd/)
34
[![Binder](https://mybinder.org/badge_logo.svg)](https://gke.mybinder.org/v2/gh/ICESat2-SlideRule/sliderule-python/main?urlpath=lab)
45
[![badge](https://img.shields.io/static/v1.svg?logo=Jupyter&label=PangeoBinderAWS&message=us-west-2&color=orange)](https://aws-uswest2-binder.pangeo.io/v2/gh/ICESat2-SlideRule/sliderule-python/main?urlpath=lab)
56
[![DOI](https://zenodo.org/badge/311384982.svg)](https://zenodo.org/badge/latestdoi/311384982)
67

78
SlideRule's Python client makes it easier to interact with SlideRule from a Python script.
89

9-
Detailed [documentation](https://www.slideruleearth.org/rtd/) on installing and using this client can be found at [slideruleearth.io](https://www.slideruleearth.org).
10+
Detailed [documentation](https://slideruleearth.io/rtd/) on installing and using this client can be found at [slideruleearth.io](https://slideruleearth.io/).
1011

1112
## I. Installing the SlideRule Python Client
1213

1314
```bash
1415
conda install -c conda-forge sliderule
1516
```
1617

17-
For alternate methods to install SlideRule, including options for developers, please see the [installation instructions](https://www.slideruleearth.org/rtd/getting_started/Install.html) on slideruleearth.io.
18+
For alternate methods to install SlideRule, including options for developers, please see the [installation instructions](https://slideruleearth.io/rtd/getting_started/Install.html).
1819

1920
### Dependencies
2021

@@ -59,7 +60,7 @@ More extensive examples in the form of Jupyter Notebooks can be found in the [ex
5960

6061
## III. Reference and User's Guide
6162

62-
Please see our [documentation](https://www.slideruleearth.org/rtd/) page for reference and user's guide material.
63+
Please see our [documentation](https://slideruleearth.io/rtd/) page for reference and user's guide material.
6364

6465
## IV. Licensing
6566

examples/api_widgets_demo.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"source": [
119119
"### Interactive Mapping with Leaflet\n",
120120
"\n",
121-
"Interactive maps within the SlideRule python API are build upon [ipyleaflet](https://ipyleaflet.readthedocs.io).\n",
121+
"Interactive maps within the SlideRule python API are built upon [ipyleaflet](https://ipyleaflet.readthedocs.io).\n",
122122
"\n",
123123
"#### Leaflet Basemaps and Layers\n",
124124
"\n",
@@ -138,6 +138,7 @@
138138
" <li><a href=\"https://asterweb.jpl.nasa.gov/gdem.asp\">ASTER GDEM Hillshade</a></li>\n",
139139
" <li><a href=\"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9\">ESRI Imagery</a></li>\n",
140140
" <li><a href=\"http://glims.colorado.edu/glacierdata/\">Global Land Ice Measurements from Space (GLIMS)</a></li>\n",
141+
" <li><a href=\"https://www.glims.org/RGI/\">Randolph Glacier Inventory (RGI)</a></li>\n",
141142
" </ul>\n",
142143
" </td>\n",
143144
" <td align='left' valign='top' width=\"30%\">\n",
@@ -151,6 +152,7 @@
151152
" <li><a href=\"https://lima.usgs.gov/\">Landsat Image Mosaic of Antarctica (LIMA)</a></li>\n",
152153
" <li><a href=\"https://nsidc.org/data/nsidc-0280\">MODIS Mosaic of Antarctica (MOA)</a></li>\n",
153154
" <li><a href=\"https://nsidc.org/data/NSIDC-0103\">Radarsat Antarctic Mapping Project (RAMP)</a></li>\n",
155+
" <li><a href=\"https://www.pgc.umn.edu/data/rema\">Reference Elevation Model of Antarctica (REMA)</a></li>\n",
154156
" </ul>\n",
155157
" </td>\n",
156158
" </tr>\n",
@@ -168,7 +170,8 @@
168170
"source": [
169171
"widgets.VBox([\n",
170172
" SRwidgets.projection,\n",
171-
" SRwidgets.layers\n",
173+
" SRwidgets.layers,\n",
174+
" SRwidgets.raster_functions\n",
172175
"])"
173176
]
174177
},
@@ -201,7 +204,10 @@
201204
"metadata": {},
202205
"outputs": [],
203206
"source": [
204-
"m.add_layer(layers=SRwidgets.layers.value)"
207+
"m.add_layer(\n",
208+
" layers=SRwidgets.layers.value,\n",
209+
" rendering_rule=SRwidgets.rendering_rule\n",
210+
")"
205211
]
206212
},
207213
{

examples/atl03_widgets_demo.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"source": [
109109
"### Interactive Mapping with Leaflet\n",
110110
"\n",
111-
"Interactive maps within the SlideRule python API are build upon [ipyleaflet](https://ipyleaflet.readthedocs.io).\n",
111+
"Interactive maps within the SlideRule python API are built upon [ipyleaflet](https://ipyleaflet.readthedocs.io).\n",
112112
"\n",
113113
"#### Leaflet Basemaps and Layers\n",
114114
"\n",
@@ -128,6 +128,7 @@
128128
" <li><a href=\"https://asterweb.jpl.nasa.gov/gdem.asp\">ASTER GDEM Hillshade</a></li>\n",
129129
" <li><a href=\"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9\">ESRI Imagery</a></li>\n",
130130
" <li><a href=\"http://glims.colorado.edu/glacierdata/\">Global Land Ice Measurements from Space (GLIMS)</a></li>\n",
131+
" <li><a href=\"https://www.glims.org/RGI/\">Randolph Glacier Inventory (RGI)</a></li>\n",
131132
" </ul>\n",
132133
" </td>\n",
133134
" <td align='left' valign='top' width=\"30%\">\n",
@@ -141,6 +142,7 @@
141142
" <li><a href=\"https://lima.usgs.gov/\">Landsat Image Mosaic of Antarctica (LIMA)</a></li>\n",
142143
" <li><a href=\"https://nsidc.org/data/nsidc-0280\">MODIS Mosaic of Antarctica (MOA)</a></li>\n",
143144
" <li><a href=\"https://nsidc.org/data/NSIDC-0103\">Radarsat Antarctic Mapping Project (RAMP)</a></li>\n",
145+
" <li><a href=\"https://www.pgc.umn.edu/data/rema\">Reference Elevation Model of Antarctica (REMA)</a></li>\n",
144146
" </ul>\n",
145147
" </td>\n",
146148
" </tr>\n",
@@ -158,7 +160,8 @@
158160
"source": [
159161
"widgets.VBox([\n",
160162
" SRwidgets.projection,\n",
161-
" SRwidgets.layers\n",
163+
" SRwidgets.layers,\n",
164+
" SRwidgets.raster_functions\n",
162165
"])"
163166
]
164167
},
@@ -191,7 +194,10 @@
191194
"metadata": {},
192195
"outputs": [],
193196
"source": [
194-
"m.add_layer(layers=SRwidgets.layers.value)"
197+
"m.add_layer(\n",
198+
" layers=SRwidgets.layers.value,\n",
199+
" rendering_rule=SRwidgets.rendering_rule\n",
200+
")"
195201
]
196202
},
197203
{

examples/voila_demo.ipynb

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
"import numpy as np\n",
7777
"import matplotlib.lines\n",
7878
"import matplotlib.pyplot as plt\n",
79+
"# autoreload\n",
80+
"%load_ext autoreload\n",
81+
"%autoreload 2\n",
7982
"%matplotlib inline"
8083
]
8184
},
@@ -124,6 +127,7 @@
124127
"results = []\n",
125128
"SRwidgets = ipysliderule.widgets()\n",
126129
"points_dropdown = None\n",
130+
"update_button = widgets.Button(description=\"Update Map\")\n",
127131
"run_button = widgets.Button(description=\"Run SlideRule!\")\n",
128132
"run_output = widgets.Output()\n",
129133
"refresh_button = widgets.Button(description=\"Refresh Plot\")\n",
@@ -151,11 +155,49 @@
151155
"outputs": [],
152156
"source": [
153157
"# create ipyleaflet map in specified projection\n",
154-
"m = ipysliderule.leaflet('Global', layer_control=False)\n",
158+
"m = ipysliderule.leaflet(SRwidgets.projection.value)\n",
159+
"# install click handler callback\n",
160+
"m.add_selected_callback(SRwidgets.atl06_click_handler)\n",
155161
"display(m.map)\n",
156162
"display(run_output)"
157163
]
158164
},
165+
{
166+
"cell_type": "code",
167+
"execution_count": null,
168+
"metadata": {
169+
"extensions": {
170+
"jupyter_dashboards": {
171+
"version": 1,
172+
"views": {
173+
"default_view": {
174+
"hidden": true
175+
}
176+
}
177+
}
178+
}
179+
},
180+
"outputs": [],
181+
"source": [
182+
"# update map\n",
183+
"def on_update_clicked(b):\n",
184+
" m.add_layer(\n",
185+
" layers=SRwidgets.layers.value,\n",
186+
" rendering_rule=SRwidgets.rendering_rule\n",
187+
" )\n",
188+
" \n",
189+
"# map widgets\n",
190+
"display(widgets.VBox([\n",
191+
" SRwidgets.projection,\n",
192+
" SRwidgets.layers,\n",
193+
" SRwidgets.raster_functions\n",
194+
"]))\n",
195+
"\n",
196+
"# update button\n",
197+
"update_button.on_click(on_update_clicked)\n",
198+
"display(update_button)"
199+
]
200+
},
159201
{
160202
"cell_type": "code",
161203
"execution_count": null,
@@ -177,17 +219,19 @@
177219
"\n",
178220
"# callbacks for events and exceptions\n",
179221
"def demo_logeventrec(rec):\n",
180-
" print(f'{rec[\"attr\"]} \\r', end=\"\")\n",
222+
" # print(f'{rec[\"attr\"]} \\r', end=\"\")\n",
223+
" pass\n",
181224
"\n",
182225
"def demo_exceptrec(rec):\n",
183-
" print(f'{rec[\"text\"]} \\r', end=\"\")\n",
226+
" if \"Successfully\" in rec[\"text\"]:\n",
227+
" print(f'{rec[\"text\"]} \\r', end=\"\")\n",
184228
"\n",
185229
"# build and transmit requests to SlideRule\n",
186230
"def runSlideRule():\n",
187231
" global url_textbox, parms, results\n",
188232
" \n",
189233
" # set the url for the sliderule service\n",
190-
" icesat2.init(url_textbox.value, loglevel=logging.WARNING, max_resources=1000)\n",
234+
" icesat2.init(url_textbox.value, loglevel=logging.ERROR, max_resources=1000)\n",
191235
"\n",
192236
" # sliderule asset and data release\n",
193237
" asset = SRwidgets.asset.value\n",
@@ -251,14 +295,14 @@
251295
"def on_refresh_clicked(b):\n",
252296
" global atl06_rsps\n",
253297
" with refresh_output:\n",
254-
" if atl06_rsps.shape[0] > 0:\n",
298+
" if atl06_rsps and atl06_rsps.shape[0] > 0:\n",
255299
" max_plot_points = 10000\n",
256300
" if points_dropdown.value == \"100K\":\n",
257301
" max_plot_points = 100000\n",
258302
" elif points_dropdown.value == \"unlimited\":\n",
259303
" max_plot_points = 1000000000\n",
260304
" m.GeoData(atl06_rsps, column_name=SRwidgets.variable.value, cmap=SRwidgets.colormap, max_plot_points=max_plot_points)\n",
261-
" \n",
305+
"\n",
262306
"# link buttons\n",
263307
"run_button.on_click(on_run_clicked)\n",
264308
"refresh_button.on_click(on_refresh_clicked)"
@@ -316,7 +360,7 @@
316360
" SRwidgets.variable,\n",
317361
" SRwidgets.cmap,\n",
318362
" points_dropdown,\n",
319-
" SRwidgets.reverse\n",
363+
" SRwidgets.reverse,\n",
320364
"]))\n",
321365
"\n",
322366
"# display buttons\n",
@@ -402,7 +446,7 @@
402446
" url = 'host.docker.internal'\n",
403447
" else:\n",
404448
" url = url_textbox.value\n",
405-
" icesat2.init(url, loglevel=logging.WARNING)\n",
449+
" icesat2.init(url, loglevel=logging.ERROR)\n",
406450
"\n",
407451
" # sliderule asset and data release\n",
408452
" asset = SRwidgets.asset.value\n",
@@ -518,6 +562,13 @@
518562
"display(pc_button)\n",
519563
"display(pc_output)"
520564
]
565+
},
566+
{
567+
"cell_type": "code",
568+
"execution_count": null,
569+
"metadata": {},
570+
"outputs": [],
571+
"source": []
521572
}
522573
],
523574
"metadata": {

sliderule/icesat2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ def __query_resources(parm, version, return_polygons=False):
362362

363363
# Check Resources are Under Limit #
364364
if(len(resources) > max_requested_resources):
365-
logger.error("Exceeded maximum requested resources: %d (current max is %d)\nConsider using icesat2.set_max_resources to set a higher limit.", len(resources), max_requested_resources)
366-
resources = []
365+
raise RuntimeError('Exceeded maximum requested granules: {} (current max is {})\nConsider using icesat2.set_max_resources to set a higher limit.'.format(len(resources), max_requested_resources))
367366
else:
368367
logger.info("Identified %d resources to process", len(resources))
369368

0 commit comments

Comments
 (0)