From 0441c8b5228b23d46bab56f049af80dda8601ce7 Mon Sep 17 00:00:00 2001 From: tsutterley Date: Wed, 1 Sep 2021 13:58:25 -0700 Subject: [PATCH] add land class widget add nsidc-s3 asset option update plot 2 to be a scatter plot of all elevations --- examples/api_widgets_demo.ipynb | 72 +++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/examples/api_widgets_demo.ipynb b/examples/api_widgets_demo.ipynb index e9e0201..5be663b 100644 --- a/examples/api_widgets_demo.ipynb +++ b/examples/api_widgets_demo.ipynb @@ -141,7 +141,7 @@ "source": [ "# dropdown menu for setting asset\n", "AssetDropdown = widgets.Dropdown(\n", - " options=['atlas-local', 'atlas-s3'],\n", + " options=['atlas-local', 'atlas-s3', 'nsidc-s3'],\n", " value='atlas-s3',\n", " description='Asset:',\n", " disabled=False,\n", @@ -198,6 +198,20 @@ " readout_format='d'\n", ")\n", "\n", + "# selection for land surface classifications\n", + "land_options = [\n", + " 'atl08_noise',\n", + " 'atl08_ground',\n", + " 'atl08_canopy',\n", + " 'atl08_top_of_canopy',\n", + " 'atl08_unclassified'\n", + "]\n", + "ClassSelect = widgets.SelectMultiple(\n", + " options=land_options,\n", + " description='Land Class:',\n", + " disabled=False\n", + ")\n", + "\n", "# slider for setting maximum number of iterations\n", "# (not including initial least-squares-fit selection)\n", "IterationSlider = widgets.IntSlider(\n", @@ -275,6 +289,7 @@ " LengthSlider,\n", " StepSlider,\n", " ConfSlider,\n", + " ClassSelect,\n", " IterationSlider,\n", " SpreadSlider,\n", " CountSlider,\n", @@ -312,6 +327,8 @@ " \"res\": StepSlider.value,\n", " # confidence level for PE selection (default: 4)\n", " \"cnf\": ConfSlider.value,\n", + " # ATL08 land surface classifications\n", + " \"atl08_class\": list(ClassSelect.value),\n", " # maximum iterations, not including initial least-squares-fit selection (default: 1)\n", " \"maxi\": IterationSlider.value,\n", " # minimum along track spread (default: 20.0)\n", @@ -359,31 +376,42 @@ "# adjust subplot within figure\n", "f1.subplots_adjust(left=0.02,right=0.98,bottom=0.05,top=0.98)\n", "\n", - "# output plot of fit height for each segment\n", - "spots = rsps['spot'].unique()\n", - "f2, ax2 = plt.subplots(num=2,ncols=len(spots),sharey=True,figsize=(8,6))\n", - "for j,spot in enumerate(spots):\n", - " rsps_per_spot = rsps[rsps[\"spot\"]==spot]\n", - " ax2[j].plot(rsps_per_spot['segment_id'],rsps_per_spot['h_mean'],'r')\n", - " ax2[j].set_xlabel('Segment ID')\n", - " ax2[j].set_title('Spot {0:d}'.format(spot))\n", - "ax2[0].set_ylabel('Along Track Elevation [m]')\n", - "title = 'SlideRule ATL06 Segment Fits\\nSegment Length {0:d}m, Step Size {1:d}m'\n", - "f2.suptitle(title.format(LengthSlider.value,StepSlider.value))\n", - "f2.subplots_adjust(wspace=0.05)\n", - "\n", - "# show plots\n", + "# output map of heights\n", + "f2, ax2 = plt.subplots(num=2, nrows=1, ncols=1, figsize=(10,6),\n", + " subplot_kw=dict(projection=cartopy.crs.PlateCarree()))\n", + "# create scatter plot of elevations\n", + "sc = ax2.scatter(gdf.geometry.x,gdf.geometry.y,c=gdf.h_mean,\n", + " s=1,edgecolor='none',cmap=plt.cm.viridis,\n", + " transform=cartopy.crs.PlateCarree())\n", + "# extract latitude and longitude of polygon\n", + "lon = [r['lon'] for r in regions[0]]\n", + "lat = [r['lat'] for r in regions[0]]\n", + "ax2.plot(lon, lat, 'r', lw=1.5, transform=cartopy.crs.PlateCarree())\n", + "# add coastlines with filled land and lakes\n", + "ax2.add_feature(cartopy.feature.LAND, zorder=0, edgecolor='black')\n", + "ax2.add_feature(cartopy.feature.LAKES)\n", + "#-- Add colorbar axes at position rect [left, bottom, width, height]\n", + "cbar_ax = f2.add_axes([0.87, 0.015, 0.0325, 0.94])\n", + "#-- add extension triangles to upper and lower bounds\n", + "cbar = f2.colorbar(sc, cax=cbar_ax, extend='both', extendfrac=0.0375,\n", + " drawedges=False, orientation='vertical')\n", + "#-- rasterized colorbar to remove lines\n", + "cbar.solids.set_rasterized(True)\n", + "#-- Add label to the colorbar and adjust coordinates\n", + "cbar.ax.set_ylabel('Height above WGS84 Ellipsoid',labelpad=10)\n", + "cbar.ax.set_xlabel('m', rotation=0)\n", + "cbar.ax.xaxis.set_label_coords(0.5, 1.05)\n", + "cbar.ax.tick_params(which='both', width=1, direction='in')\n", + "# stronger linewidth on frame\n", + "ax2.spines['geo'].set_linewidth(2.0)\n", + "ax2.spines['geo'].set_capstyle('projecting')\n", + "# adjust subplot within figure\n", + "f2.subplots_adjust(left=0.02,right=0.86,bottom=0.05,top=0.98)\n", + "# show the figures\n", "plt.show()" ], "outputs": [], "metadata": {} - }, - { - "cell_type": "code", - "execution_count": null, - "source": [], - "outputs": [], - "metadata": {} } ], "metadata": {