{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Boulder Watershed Demo\n", "\n", "Process ATL03 data from the Boulder Watershed region and produce a customized ATL06 elevation dataset.\n", "\n", "### What is demonstrated\n", "\n", "* The `icesat2.atl06p` API is used to perform a SlideRule parallel processing request of the Boulder Watershed region\n", "* The `matplotlib` and `geopandas` packages are used to plot the data returned by SlideRule\n", "\n", "### Points of interest\n", "\n", "This is a simple notebook showing how a region of interest can be processed by SlideRule and the results analyzed using pandas DataFrames and Matplotlib." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "import logging\n", "import geopandas as gpd\n", "import matplotlib.pyplot as plt\n", "from sliderule import icesat2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SlideRule Configuration" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Configure ICESat-2 API\n", "icesat2.init(\"slideruleearth.io\")\n", "# Configure Region of Interest\n", "region = [ {\"lon\":-105.82971551223244, \"lat\": 39.81983728534918},\n", " {\"lon\":-105.30742121965137, \"lat\": 39.81983728534918},\n", " {\"lon\":-105.30742121965137, \"lat\": 40.164048017973755},\n", " {\"lon\":-105.82971551223244, \"lat\": 40.164048017973755},\n", " {\"lon\":-105.82971551223244, \"lat\": 39.81983728534918} ]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute ATL06 Algorithm using SlideRule" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "\n", "# Build ATL06 Request\n", "parms = {\n", " \"poly\": region,\n", " \"srt\": icesat2.SRT_LAND,\n", " \"cnf\": icesat2.CNF_SURFACE_HIGH,\n", " \"ats\": 10.0,\n", " \"cnt\": 10,\n", " \"len\": 40.0,\n", " \"res\": 20.0\n", "}\n", "\n", "# Request ATL06 Data\n", "gdf = icesat2.atl06p(parms)\n", "\n", "# Display Statistics\n", "print(\"Reference Ground Tracks: {}\".format(gdf[\"rgt\"].unique()))\n", "print(\"Cycles: {}\".format(gdf[\"cycle\"].unique()))\n", "print(\"Received {} elevations\".format(len(gdf)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot Region" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Calculate Extent\n", "lons = [p[\"lon\"] for p in region]\n", "lats = [p[\"lat\"] for p in region]\n", "lon_margin = (max(lons) - min(lons)) * 0.1\n", "lat_margin = (max(lats) - min(lats)) * 0.1\n", "\n", "# Create Plot\n", "fig,(ax1,ax2) = plt.subplots(num=None, ncols=2, figsize=(12, 6))\n", "box_lon = [e[\"lon\"] for e in region]\n", "box_lat = [e[\"lat\"] for e in region]\n", "\n", "# Plot SlideRule Ground Tracks\n", "ax1.set_title(\"SlideRule Zoomed Ground Tracks\")\n", "gdf.plot(ax=ax1, column=gdf[\"h_mean\"], cmap='winter_r', s=1.0, zorder=3)\n", "ax1.plot(box_lon, box_lat, linewidth=1.5, color='r', zorder=2)\n", "ax1.set_xlim(min(lons) - lon_margin, max(lons) + lon_margin)\n", "ax1.set_ylim(min(lats) - lat_margin, max(lats) + lat_margin)\n", "ax1.set_aspect('equal', adjustable='box')\n", "\n", "# Plot SlideRule Global View\n", "ax2.set_title(\"SlideRule Global Reference\")\n", "world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))\n", "world.plot(ax=ax2, color='0.8', edgecolor='black')\n", "gdf.plot(ax=ax2, marker='o', color='red', markersize=2.5, zorder=3)\n", "ax2.set_xlim(-180,180)\n", "ax2.set_ylim(-90,90)\n", "ax2.set_aspect('equal', adjustable='box')\n", "\n", "# Show Plot\n", "plt.tight_layout()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "d7f94b8b1e41b02170d45ac71ce2d6b011e7cd56207b4c480f5292088bcfab93" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.0" } }, "nbformat": 4, "nbformat_minor": 4 }