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

Skip to content

Commit 79f80bb

Browse files
committed
demo updates for latest client
1 parent 0b93ae3 commit 79f80bb

File tree

5 files changed

+47
-59
lines changed

5 files changed

+47
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Example notebooks that use SlideRule's Python client for processing Earth scienc
77
## Overview
88
Detailed [documentation](https://slideruleearth.io/rtd/) on installing and using the SlideRule Python client can be found at [slideruleearth.io](https://slideruleearth.io/).
99

10-
> NOTE: As of 3/10/2023 the source code for SlideRule's Python client has moved to the [sliderule](https://github.com/ICESat2-SlideRule/sliderule) repository. This [sliderule-python](https://github.com/ICESat2-SlideRule/sliderule-python) repository continues to function as a collection of example notebooks that use the SlideRule Python client and demonstrate common workflows.
10+
> NOTE: As of 3/10/2023 the source code for SlideRule's Python client has moved to the [sliderule](https://github.com/SlideRuleEarth/sliderule) repository. This [sliderule-python](https://github.com/SlideRuleEarth/sliderule-python) repository continues to function as a collection of example notebooks that use the SlideRule Python client and demonstrate common workflows.
1111
1212
## Getting Started
1313

demo/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ demo-docker: # make the python client demo docker image; needs VERSION
1616
cp ../environment.yml $(DEMO_STAGE_DIR)
1717
cp voila_demo.ipynb $(DEMO_STAGE_DIR)
1818
cp docker/demo/* $(DEMO_STAGE_DIR)
19-
# cp -R ../../sliderule $(DEMO_STAGE_DIR) # used to install local copy of client (only if necessary during development, see dockerfile for additional steps)
19+
# used to install local copy of client (only if necessary during development, see dockerfile for additional steps)
20+
cp -R ../../sliderule $(DEMO_STAGE_DIR)
2021
chmod +x $(DEMO_STAGE_DIR)/docker-entrypoint.sh
2122
cd $(DEMO_STAGE_DIR) && docker build $(DOCKEROPTS) -t $(REPO)/demo-client:latest .
2223
docker tag $(REPO)/demo-client:latest $(REPO)/demo-client:$(VERSION)

demo/docker/demo/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ RUN conda install -c conda-forge voila
1616
COPY voila_demo.ipynb /voila_demo.ipynb
1717

1818
# Local install of client (only if necessary)
19-
# COPY sliderule /sliderule
20-
# RUN cd /sliderule/clients/python && pip install .
19+
COPY sliderule /sliderule
20+
RUN cd /sliderule/clients/python && pip install .
2121

2222
# Entry point
2323
COPY docker-entrypoint.sh /usr/local/etc/

demo/voila_demo.ipynb

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222
"\n",
2323
"#### SlideRule is an on-demand science data processing service that runs in the cloud and responds to REST API calls to process and return science results.\n",
2424
"\n",
25-
"This web page demonstrates a simple use of SlideRule to return elevations within a small region of interest using processing parameters specified at the time of the request. The web page is implemented inside a Jupyter Notebook using SlideRule's Python client, and is statically served using Voila. For more information on SlideRule, and how to install and use it for your own analysis applications, please see our website at [slideruleearth.io](https://slideruleearth.io).\n",
25+
"This web page is _not_ SlideRule but is a demonstration of using public SlideRule APIs to return elevations within a small region of interest. The web page is implemented inside a Jupyter Notebook using SlideRule's Python client, and is statically served using Voila. For more information on SlideRule, and how to install and use it for your own analysis applications, please see our website at [slideruleearth.io](https://slideruleearth.io).\n",
2626
"\n",
27-
"| Step 1 | Step 2 | Step 3 | Step 4 | Step 5 |\n",
28-
"|--------|--------|--------|--------|--------|\n",
29-
"| Select Region of Interest | Choose Processing Parameters and Run SlideRule | Explore Data Points and Refresh Plot | Plot Photon Cloud of Ground Track | Build Your Own Notebook |\n",
30-
"| Use the map to draw a polygon or bounding box around your region of interest. | Select the processing parameters to use to calculate geolocated elevations for the region of interest created above. Then click the \"Run SlideRule!\" button to initiate a https://github.com/ICESat2-SlideRule/sliderule-python/blob/main/examples/api_widgets_demo.ipynb request to SlideRule. Once all granules have been processed, the above map will be updated with a scatter plot of the different elevations. | The results are returned as a GeoDataFrame with multiple columns. Choose a field in the returned results to plot, and then click \"Refresh Plot\" to see the map updated with values from that column. | Enter the reference ground track, the cycle, and the individual ground track in the input boxes below. If you click on an individual elevation in the map, it will automatically populate these inputs with the correct values. | Check out our [API widgets demo](https://github.com/ICESat2-SlideRule/sliderule-python/blob/main/examples/api_widgets_demo.ipynb) for a guided walkthrough of how SlideRule works along with code you can use to start your own notebook. |"
27+
"For more detailed example notebooks that use SlideRule APIs, check out these example notebooks at [github.com/SlideRuleEarth/sliderule-python](https://github.com/SlideRuleEarth/sliderule-python/tree/main/examples)."
3128
]
3229
},
3330
{
@@ -45,7 +42,7 @@
4542
}
4643
},
4744
"source": [
48-
"## Segment Elevations ([atl06p](https://slideruleearth.io/rtd/api_reference/icesat2.html#atl06p))"
45+
"### Surface Elevations ([atl06p](https://slideruleearth.io/rtd/api_reference/icesat2.html#atl06p))"
4946
]
5047
},
5148
{
@@ -65,26 +62,8 @@
6562
},
6663
"outputs": [],
6764
"source": [
68-
"# load the necessary packages\n",
69-
"from io import BytesIO\n",
70-
"from sliderule import icesat2, ipysliderule, io, sliderule\n",
71-
"import ipywidgets as widgets\n",
72-
"import geopandas\n",
73-
"import logging\n",
7465
"import warnings\n",
75-
"import base64\n",
76-
"import time\n",
77-
"import copy\n",
78-
"import json\n",
79-
"import re\n",
80-
"from IPython import display\n",
81-
"# atl03 plotting imports\n",
82-
"import numpy as np\n",
83-
"import matplotlib.pyplot as plt\n",
84-
"# autoreload\n",
85-
"%load_ext autoreload\n",
86-
"%autoreload 2\n",
87-
"%matplotlib inline"
66+
"warnings.filterwarnings('ignore') # turn off warnings for demo"
8867
]
8968
},
9069
{
@@ -104,8 +83,25 @@
10483
},
10584
"outputs": [],
10685
"source": [
107-
"# turn off warnings for demo\n",
108-
"warnings.filterwarnings('ignore')"
86+
"# load the necessary packages\n",
87+
"from io import BytesIO\n",
88+
"from sliderule import icesat2, ipysliderule, io, sliderule\n",
89+
"import ipywidgets as widgets\n",
90+
"import geopandas\n",
91+
"import logging\n",
92+
"import base64\n",
93+
"import time\n",
94+
"import copy\n",
95+
"import json\n",
96+
"import re\n",
97+
"from IPython import display\n",
98+
"# atl03 plotting imports\n",
99+
"import numpy as np\n",
100+
"import matplotlib.pyplot as plt\n",
101+
"# autoreload\n",
102+
"%load_ext autoreload\n",
103+
"%autoreload 2\n",
104+
"%matplotlib inline"
109105
]
110106
},
111107
{
@@ -126,7 +122,6 @@
126122
"outputs": [],
127123
"source": [
128124
"# create global variables\n",
129-
"url_textbox = None\n",
130125
"atl06_rsps = None\n",
131126
"atl06_parms = None\n",
132127
"SRwidgets = ipysliderule.widgets()\n",
@@ -142,7 +137,7 @@
142137
"SRwidgets.file_format.options = [\"GeoJSON\",\"csv\",\"geoparquet\"]\n",
143138
"SRwidgets.file_format.value = 'geoparquet'\n",
144139
"show_code06_button = widgets.Button(description=\"Show Code\")\n",
145-
"show_code06_output = widgets.Output()\n"
140+
"show_code06_output = widgets.Output()"
146141
]
147142
},
148143
{
@@ -251,18 +246,18 @@
251246
"\n",
252247
"# build and transmit requests to SlideRule\n",
253248
"def runSlideRule():\n",
254-
" global url_textbox, atl06_parms, granule_count\n",
249+
" global atl06_parms, granule_count\n",
255250
"\n",
256251
" # reset granule count\n",
257252
" granule_count = 0\n",
258253
"\n",
259254
" # set the url for the sliderule service\n",
260-
" icesat2.init(url_textbox.value, loglevel=logging.ERROR, max_resources=1000)\n",
255+
" icesat2.init(\"slideruleearth.io\", loglevel=logging.ERROR, max_resources=1000)\n",
261256
"\n",
262257
" # build sliderule parameters using latest values from widget\n",
263258
" atl06_parms = {\n",
264259
" # surface type: 0-land, 1-ocean, 2-sea ice, 3-land ice, 4-inland water\n",
265-
" \"srt\": SRwidgets.surface_type.index,\n",
260+
" \"srt\": icesat2.SRT_DYNAMIC,\n",
266261
" # length of ATL06-SR segment in meters\n",
267262
" \"len\": SRwidgets.length.value,\n",
268263
" # step distance for successive ATL06-SR segments in meters\n",
@@ -362,7 +357,7 @@
362357
" global url_textbox, atl06_parms\n",
363358
" with show_code06_output:\n",
364359
" display.clear_output()\n",
365-
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
360+
" print(f'icesat2.init()')\n",
366361
" # validate boolean entries to be in title case\n",
367362
" atl06_json = json.dumps(atl06_parms, indent=4)\n",
368363
" atl06_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl06_json)\n",
@@ -428,15 +423,6 @@
428423
},
429424
"outputs": [],
430425
"source": [
431-
"# url input text box\n",
432-
"url_textbox = widgets.Text(\n",
433-
" value='slideruleearth.io',\n",
434-
" placeholder='Input box for SlideRule url',\n",
435-
" description='URL:',\n",
436-
" disabled=False\n",
437-
")\n",
438-
"display.display(url_textbox)\n",
439-
"\n",
440426
"# points to plot drop down\n",
441427
"points_dropdown = widgets.Dropdown(\n",
442428
" options = [\"10K\", \"100K\", \"all\"],\n",
@@ -447,7 +433,6 @@
447433
"\n",
448434
"# display widgets for setting SlideRule parameters\n",
449435
"display.display(widgets.VBox([\n",
450-
" SRwidgets.surface_type,\n",
451436
" SRwidgets.length,\n",
452437
" SRwidgets.step,\n",
453438
" SRwidgets.confidence,\n",
@@ -517,7 +502,7 @@
517502
}
518503
},
519504
"source": [
520-
"## Photon Cloud ([atl03sp](https://slideruleearth.io/rtd/api_reference/icesat2.html#atl03sp))"
505+
"### Photon Cloud ([atl03sp](https://slideruleearth.io/rtd/api_reference/icesat2.html#atl03sp))"
521506
]
522507
},
523508
{
@@ -543,19 +528,14 @@
543528
"%matplotlib widget\n",
544529
"# ATL03 Subsetter\n",
545530
"def runATL03Subsetter():\n",
546-
" global url_textbox, atl03_parms\n",
531+
" global atl03_parms\n",
547532
"\n",
548-
" # set the url for the sliderule service\n",
549-
" if url_textbox.value == 'local':\n",
550-
" url = 'host.docker.internal'\n",
551-
" else:\n",
552-
" url = url_textbox.value\n",
553-
" icesat2.init(url, loglevel=logging.ERROR)\n",
533+
" icesat2.init(\"slideruleearth.io\", loglevel=logging.ERROR)\n",
554534
"\n",
555535
" # build sliderule parameters using latest values from widget\n",
556536
" atl03_parms = {\n",
557537
" # processing parameters\n",
558-
" \"srt\": SRwidgets.surface_type.index,\n",
538+
" \"srt\": icesat2.SRT_DYNAMIC,\n",
559539
" \"len\": SRwidgets.length.value,\n",
560540
" \"res\": SRwidgets.step.value,\n",
561541
"\n",
@@ -638,7 +618,7 @@
638618
" global url_textbox, atl03_parms\n",
639619
" with show_code03_output:\n",
640620
" display.clear_output()\n",
641-
" print(f'icesat2.init(\"{url_textbox.value}\")')\n",
621+
" print(f'icesat2.init()')\n",
642622
" # validate boolean entries to be in title case\n",
643623
" atl03_json = json.dumps(atl03_parms, indent=4)\n",
644624
" atl03_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl03_json)\n",
@@ -694,6 +674,13 @@
694674
"display.display(SRwidgets.HBox([download_atl03_button, SRwidgets.file_format]))\n",
695675
"display.display(show_code03_button, show_code03_output)"
696676
]
677+
},
678+
{
679+
"cell_type": "code",
680+
"execution_count": null,
681+
"metadata": {},
682+
"outputs": [],
683+
"source": []
697684
}
698685
],
699686
"metadata": {
@@ -730,7 +717,7 @@
730717
"name": "python",
731718
"nbconvert_exporter": "python",
732719
"pygments_lexer": "ipython3",
733-
"version": "3.10.13"
720+
"version": "3.12.0"
734721
},
735722
"toc-showtags": false
736723
},

examples/atl03_subsetter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
parser.add_argument('--ignore_poly_for_cmr', type=bool, default=None)
3636
parser.add_argument('--name', type=str, default='output')
3737
parser.add_argument('--no_geo', action='store_true', default=False)
38-
parser.add_argument('--output_path', '-p', type=str, default="s3://sliderule/data/stage") # "hosted" tells sliderule to host results in a bucket it owns
38+
parser.add_argument('--output_path', '-p', type=str, default="hosted") # "hosted" tells sliderule to host results in a bucket it owns
3939
parser.add_argument('--timeout', '-t', type=int, default=600) # seconds
4040
parser.add_argument('--generate', action='store_true', default=False)
4141
parser.add_argument('--simulate_delay', type=float, default=1)

0 commit comments

Comments
 (0)