|
241 | 241 | " text = ' '.join(tokens)\n", |
242 | 242 | " print(f'{text} \\r', end=\"\")\n", |
243 | 243 | " granule_count += 1\n", |
244 | | - " \n", |
| 244 | + "\n", |
245 | 245 | "# build and transmit requests to SlideRule\n", |
246 | 246 | "def runSlideRule():\n", |
247 | 247 | " global url_textbox, atl06_parms, granule_count\n", |
248 | | - " \n", |
| 248 | + "\n", |
249 | 249 | " # reset granule count\n", |
250 | 250 | " granule_count = 0\n", |
251 | | - " \n", |
| 251 | + "\n", |
252 | 252 | " # set the url for the sliderule service\n", |
253 | 253 | " icesat2.init(url_textbox.value, loglevel=logging.ERROR, max_resources=1000)\n", |
254 | 254 | "\n", |
|
282 | 282 | " # for each region of interest\n", |
283 | 283 | " for poly in m.regions:\n", |
284 | 284 | " # add polygon from map to sliderule parameters\n", |
285 | | - " atl06_parms[\"poly\"] = poly \n", |
| 285 | + " atl06_parms[\"poly\"] = poly\n", |
286 | 286 | " # make the request to the SlideRule (ATL06-SR) endpoint\n", |
287 | 287 | " # and pass it the request parameters to request ATL06 Data\n", |
288 | 288 | " elevations.append(icesat2.atl06p(atl06_parms, callbacks={'eventrec': demo_logeventrec, 'exceptrec': demo_exceptrec}))\n", |
|
309 | 309 | " if max_plot_points > atl06_rsps.shape[0]:\n", |
310 | 310 | " max_plot_points = atl06_rsps.shape[0]\n", |
311 | 311 | " print(f'Plotting {max_plot_points} of {atl06_rsps.shape[0]} elevations. This may take 10-60+ seconds for larger point datasets.')\n", |
312 | | - " m.GeoData(atl06_rsps, column_name=SRwidgets.variable.value, cmap=SRwidgets.colormap, max_plot_points=max_plot_points)\n", |
| 312 | + " fields = m.default_atl06_fields()\n", |
| 313 | + " atl06_rsps.leaflet.GeoData(m.map, column_name=SRwidgets.variable.value,\n", |
| 314 | + " cmap=SRwidgets.colormap, max_plot_points=max_plot_points, tooltip=True,\n", |
| 315 | + " colorbar=True, fields=fields)\n", |
| 316 | + " # install handlers and callbacks\n", |
| 317 | + " atl06_rsps.leaflet.add_selected_callback(SRwidgets.atl06_click_handler)\n", |
| 318 | + " m.add_region_callback(atl06_rsps.leaflet.handle_region)\n", |
313 | 319 | "\n", |
314 | 320 | "# refresh action\n", |
315 | 321 | "def on_refresh_clicked(b):\n", |
|
324 | 330 | " if max_plot_points > atl06_rsps.shape[0]:\n", |
325 | 331 | " max_plot_points = atl06_rsps.shape[0]\n", |
326 | 332 | " print(f'Plotting {max_plot_points} of {atl06_rsps.shape[0]} elevations. This may take 10-60+ seconds for larger point datasets.')\n", |
327 | | - " m.GeoData(atl06_rsps, column_name=SRwidgets.variable.value, cmap=SRwidgets.colormap, max_plot_points=max_plot_points)\n", |
| 333 | + " fields = m.default_atl06_fields()\n", |
| 334 | + " atl06_rsps.leaflet.GeoData(m.map, column_name=SRwidgets.variable.value,\n", |
| 335 | + " cmap=SRwidgets.colormap, max_plot_points=max_plot_points, tooltip=True,\n", |
| 336 | + " colorbar=True, fields=fields)\n", |
| 337 | + " # install handlers and callbacks\n", |
| 338 | + " atl06_rsps.leaflet.add_selected_callback(SRwidgets.atl06_click_handler)\n", |
| 339 | + " m.add_region_callback(atl06_rsps.leaflet.handle_region)\n", |
328 | 340 | "\n", |
329 | 341 | "# show code action\n", |
330 | 342 | "def on_show_code06_clicked(b):\n", |
|
337 | 349 | " atl06_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl06_json)\n", |
338 | 350 | " print('parms = ', atl06_json, sep='')\n", |
339 | 351 | " print('gdf = icesat2.atl06p(parms)')\n", |
340 | | - " \n", |
| 352 | + "\n", |
341 | 353 | "# link buttons\n", |
342 | 354 | "run_button.on_click(on_run_clicked)\n", |
343 | 355 | "refresh_button.on_click(on_refresh_clicked)\n", |
|
480 | 492 | "# ATL03 Subsetter\n", |
481 | 493 | "def runATL03Subsetter():\n", |
482 | 494 | " global url_textbox, atl03_parms\n", |
483 | | - " \n", |
| 495 | + "\n", |
484 | 496 | " # set the url for the sliderule service\n", |
485 | 497 | " if url_textbox.value == 'local':\n", |
486 | 498 | " url = 'host.docker.internal'\n", |
|
505 | 517 | " \"yapc\": {\"score\": 0}, # all photons\n", |
506 | 518 | " \"ats\": SRwidgets.spread.value,\n", |
507 | 519 | " \"cnt\": SRwidgets.count.value,\n", |
508 | | - " \n", |
| 520 | + "\n", |
509 | 521 | " # region of interest\n", |
510 | 522 | " \"poly\": m.regions[0],\n", |
511 | | - " \n", |
| 523 | + "\n", |
512 | 524 | " # track selection\n", |
513 | 525 | " \"rgt\": int(SRwidgets.rgt.value),\n", |
514 | 526 | " \"cycle\": int(SRwidgets.cycle.value),\n", |
|
517 | 529 | "\n", |
518 | 530 | " # make call to sliderule\n", |
519 | 531 | " rsps = icesat2.atl03sp(atl03_parms)\n", |
520 | | - " \n", |
| 532 | + "\n", |
521 | 533 | " # return geodataframe\n", |
522 | 534 | " return rsps\n", |
523 | 535 | "\n", |
|
526 | 538 | " global atl03_rsps, atl06_rsps, elev_dropdown\n", |
527 | 539 | " with pc_output:\n", |
528 | 540 | " pc_output.clear_output(True)\n", |
529 | | - " \n", |
| 541 | + "\n", |
530 | 542 | " # Run ATL03 Subsetter\n", |
531 | 543 | " print(f'SlideRule processing request... initiated\\r', end=\"\")\n", |
532 | 544 | " perf_start = time.perf_counter()\n", |
|
540 | 552 | " fig.set_facecolor('white')\n", |
541 | 553 | " fig.canvas.header_visible = False\n", |
542 | 554 | " ax.set_title(\"Photon Cloud\")\n", |
543 | | - " ax.set_xlabel('UTC')\n", |
544 | 555 | " ax.set_ylabel('height (m)')\n", |
545 | | - " SRwidgets.plot(atl06_rsps, ax=ax, kind='scatter',\n", |
546 | | - " atl03=atl03_rsps, cmap=SRwidgets.colormap,\n", |
| 556 | + " # start at the first segment\n", |
| 557 | + " x_offset = atl03_rsps['segment_dist'].min()\n", |
| 558 | + " # plot ATL03 and ATL06 data\n", |
| 559 | + " atl03_rsps.icesat2.plot(ax=ax, kind='scatter',\n", |
| 560 | + " data_type='atl03', cmap=SRwidgets.colormap,\n", |
547 | 561 | " classification=SRwidgets.plot_classification.value,\n", |
548 | | - " segments=(elev_dropdown.value == 'enabled'),\n", |
549 | | - " legend=True, legend_frameon=True)\n", |
| 562 | + " x_offset=x_offset, legend=True, legend_frameon=True,\n", |
| 563 | + " **SRwidgets.plot_kwargs)\n", |
| 564 | + " if (elev_dropdown.value == 'enabled'):\n", |
| 565 | + " atl06_rsps.icesat2.plot(ax=ax, kind='scatter',\n", |
| 566 | + " data_type='atl06', x_offset=x_offset,\n", |
| 567 | + " legend=True, legend_frameon=True,\n", |
| 568 | + " **SRwidgets.plot_kwargs)\n", |
550 | 569 | " # draw and show plot\n", |
551 | 570 | " plt.show()\n", |
552 | 571 | " plt.draw()\n", |
553 | | - " \n", |
554 | | - "# create button to display geodataframe \n", |
| 572 | + "\n", |
| 573 | + "# create button to display geodataframe\n", |
555 | 574 | "pc_button.on_click(on_pc_clicked)\n", |
556 | 575 | "\n", |
557 | 576 | "# click handler for individual photons\n", |
|
576 | 595 | " atl03_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl03_json)\n", |
577 | 596 | " print('parms = ', atl03_json, sep='')\n", |
578 | 597 | " print('gdf = icesat2.atl03sp(parms)')\n", |
579 | | - " \n", |
| 598 | + "\n", |
580 | 599 | "# install click handler callback\n", |
581 | 600 | "show_code03_button.on_click(on_show_code03_clicked)" |
582 | 601 | ] |
|
619 | 638 | "display.display(pc_output)\n", |
620 | 639 | "display.display(show_code03_button, show_code03_output)" |
621 | 640 | ] |
622 | | - }, |
623 | | - { |
624 | | - "cell_type": "code", |
625 | | - "execution_count": null, |
626 | | - "metadata": {}, |
627 | | - "outputs": [], |
628 | | - "source": [] |
629 | 641 | } |
630 | 642 | ], |
631 | 643 | "metadata": { |
|
662 | 674 | "name": "python", |
663 | 675 | "nbconvert_exporter": "python", |
664 | 676 | "pygments_lexer": "ipython3", |
665 | | - "version": "3.11.5" |
| 677 | + "version": "3.10.13" |
666 | 678 | }, |
667 | 679 | "toc-showtags": false |
668 | 680 | }, |
|
0 commit comments