From 17cc174a423012f2b7fc055dfa545e6fa0a0a6fb Mon Sep 17 00:00:00 2001 From: Dhavide Aruliah Date: Thu, 31 Oct 2024 20:51:30 +0000 Subject: [PATCH] Updates Case Study notebooks to make sure collections work as needed. --- 04_Case_Studies/1a-Flooding-case-study.ipynb | 92 +++++++++--- .../1b-BhakraNangal-Reservoir.ipynb | 76 +++++++--- 04_Case_Studies/1c-Lake-Mead-study.ipynb | 131 ++++++++++++++---- 04_Case_Studies/1d-Lake-Mead-mosaicking.ipynb | 97 ++++++++++--- 04_Case_Studies/2a-Greece-Wildfires.ipynb | 93 ++++++++++--- .../2b-Maranhao-Deforestation.ipynb | 66 +++++++-- 04_Case_Studies/2c-GreenWall-Senegal.ipynb | 60 ++++++-- 7 files changed, 487 insertions(+), 128 deletions(-) diff --git a/04_Case_Studies/1a-Flooding-case-study.ipynb b/04_Case_Studies/1a-Flooding-case-study.ipynb index 04e105d..bea0f90 100644 --- a/04_Case_Studies/1a-Flooding-case-study.ipynb +++ b/04_Case_Studies/1a-Flooding-case-study.ipynb @@ -18,7 +18,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -55,7 +59,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Study location\n", @@ -69,7 +77,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Visualize location of area of study\n", @@ -92,9 +104,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# The flooding event primarily happened during 04/30 - 05/02\n", "# We will search for data before and after the event\n", "start_date = datetime(year=2024, month=4, day=1)\n", @@ -106,12 +123,8 @@ "\n", "# Setup PySTAC client\n", "# POCLOUD refers to the PO DAAC cloud environment that hosts earth observation data\n", - "catalog = Client.open(f'{STAC_URL}/POCLOUD/') \n", - "\n", - "# Setup PySTAC client\n", - "provider_cat = Client.open(STAC_URL)\n", "catalog = Client.open(f'{STAC_URL}/POCLOUD/')\n", - "collections = [\"OPERA_L3_DSWX-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DSWX-HLS_V1_1.0\"]\n", "\n", "search_opts = {\n", " 'bbox' : Point(*livingston_tx_lonlat).buffer(0.01).bounds, \n", @@ -127,7 +140,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "def search_to_df(results, layer_name):\n", @@ -150,16 +167,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ - "granules = search_to_df(results=results, layer_name='0_B01_WTR')" + "%time granules = search_to_df(results=results, layer_name='0_B01_WTR')" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# We now filter the dataframe to restrict our results to a single tile_id\n", @@ -171,7 +196,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "def urls_to_dataset(granule_dataframe):\n", @@ -225,16 +254,37 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ - "dataset= urls_to_dataset(granules)" + "%time dataset= urls_to_dataset(granules)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "dataset # Examine the attributes of the dataset object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define a colormap\n", @@ -247,7 +297,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'DSWx data for May 2024 Texas floods',\n", @@ -280,7 +334,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/04_Case_Studies/1b-BhakraNangal-Reservoir.ipynb b/04_Case_Studies/1b-BhakraNangal-Reservoir.ipynb index d076925..b4991be 100644 --- a/04_Case_Studies/1b-BhakraNangal-Reservoir.ipynb +++ b/04_Case_Studies/1b-BhakraNangal-Reservoir.ipynb @@ -17,7 +17,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -57,7 +61,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "bhakra_dam = (76.46, 31.42)\n", @@ -70,7 +78,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "bhakra_dam_gv = gv.Points([bhakra_dam])\n", @@ -92,9 +104,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# We will query the DSWx product record to understand variations in water levels in the reservoir\n", "start_date = datetime(year=2023, month=4, day=1)\n", "stop_date = datetime(year=2024, month=4, day=1)\n", @@ -105,12 +122,8 @@ "\n", "# Setup PySTAC client\n", "# POCLOUD refers to the PO DAAC cloud environment that hosts earth observation data\n", - "catalog = Client.open(f'{STAC_URL}/POCLOUD/') \n", - "\n", - "# Setup PySTAC client\n", - "provider_cat = Client.open(STAC_URL)\n", "catalog = Client.open(f'{STAC_URL}/POCLOUD/')\n", - "collections = [\"OPERA_L3_DSWX-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DSWX-HLS_V1_1.0\"]\n", "\n", "# Setup search options\n", "opts = {\n", @@ -128,7 +141,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "def filter_search_by_cc(results, cloud_threshold=10):\n", @@ -160,9 +177,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# let's filter our results so that only scenes with less than 10% cloud cover are returned\n", "results = filter_search_by_cc(results)\n", "\n", @@ -172,7 +194,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Load results into dataframe\n", @@ -182,16 +208,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ - "dataset= urls_to_dataset(granules)" + "%time dataset= urls_to_dataset(granules)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define a colormap\n", @@ -204,7 +238,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'Bhakra Nangal Dam, India - water extent over a year',\n", @@ -225,7 +263,7 @@ ], "metadata": { "kernelspec": { - "display_name": "climaterisk", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -239,9 +277,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/04_Case_Studies/1c-Lake-Mead-study.ipynb b/04_Case_Studies/1c-Lake-Mead-study.ipynb index 4bb3f74..dbcd2bf 100644 --- a/04_Case_Studies/1c-Lake-Mead-study.ipynb +++ b/04_Case_Studies/1c-Lake-Mead-study.ipynb @@ -17,7 +17,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -64,7 +68,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "lake_mead = (-114.348, 36.423)\n", @@ -77,7 +85,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "lake_mead_gv = gv.Points([lake_mead])\n", @@ -99,9 +111,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# We will search the available product record\n", "start_date = datetime(year=2023, month=3, day=1)\n", "stop_date = datetime.now()\n", @@ -112,12 +129,8 @@ "\n", "# Setup PySTAC client\n", "# POCLOUD refers to the PO DAAC cloud environment that hosts earth observation data\n", - "catalog = Client.open(f'{STAC_URL}/POCLOUD/') \n", - "\n", - "# Setup PySTAC client\n", - "provider_cat = Client.open(STAC_URL)\n", "catalog = Client.open(f'{STAC_URL}/POCLOUD/')\n", - "collections = [\"OPERA_L3_DSWX-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DSWX-HLS_V1_1.0\"]\n", "\n", "# Setup search options\n", "search_opts = {\n", @@ -132,12 +145,24 @@ "print(f\"Number of tiles found intersecting given AOI: {len(results)}\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note: This next step can take a long time." + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# let's filter our results so that only scenes with less than 10% cloud cover are returned\n", "results = filter_search_by_cc(results)\n", "\n", @@ -147,7 +172,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Load results into dataframe\n", @@ -157,27 +186,41 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Let's filter by tile id so that we can study changes over the same spatial extent\n", - "granules = granules[granules.tile_id=='T11SQA']" + "granules = granules[granules.tile_id=='T11SQA']\n", + "display(granules.head())\n", + "print(granules.shape)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Similarly, loading a year's worth of data will take a few minutes\n", - "dataset= urls_to_dataset(granules[::5])" + "%time dataset= urls_to_dataset(granules)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define a colormap\n", @@ -190,7 +233,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Let's load the vector shapefile of the Lake\n", @@ -201,7 +248,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "gdf.head()" @@ -209,7 +260,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "The shapefile contains a lot of features, but we're interested only in the overall outline of the reservoir. We can use the `dissolve` method to combine the geometry column into a single `Polygon`" ] @@ -217,17 +272,25 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "gdf_dissolved = gdf.dissolve() # dissove all geometries into a single polygon\n", - "gdf_dissolved.plot() # geopandas has inbuilt methods to plot the geometry column" + "gdf_dissolved.plot(); # geopandas has inbuilt methods to plot the geometry column" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "gdf_dissolved.to_crs(dst_crs, inplace=True) # project shape to web mercator to help with plotting" @@ -236,7 +299,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "lake_mead_usgs_shape = gv.Polygons(gdf)" @@ -245,7 +312,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "basemap = gv.tile_sources.OSM\n", @@ -262,7 +333,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'Lake Mead, NV USA - water extent over a year',\n", @@ -283,7 +358,7 @@ ], "metadata": { "kernelspec": { - "display_name": "climaterisk", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -297,9 +372,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.1.-1" + "version": "3.12.4" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/04_Case_Studies/1d-Lake-Mead-mosaicking.ipynb b/04_Case_Studies/1d-Lake-Mead-mosaicking.ipynb index 4702ab3..85a3acd 100644 --- a/04_Case_Studies/1d-Lake-Mead-mosaicking.ipynb +++ b/04_Case_Studies/1d-Lake-Mead-mosaicking.ipynb @@ -19,7 +19,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -61,7 +65,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "lake_mead = (-114.754, 36.131)\n", @@ -74,7 +82,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "lake_mead_gv = gv.Points([lake_mead])\n", @@ -96,9 +108,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# We will search the available product record\n", "start_date = datetime(year=2023, month=3, day=1)\n", "stop_date = datetime(year=2023, month=4, day=15) # datetime.now() # \n", @@ -114,7 +131,7 @@ "# Setup PySTAC client\n", "provider_cat = Client.open(STAC_URL)\n", "catalog = Client.open(f'{STAC_URL}/POCLOUD/')\n", - "collections = [\"OPERA_L3_DSWX-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DSWX-HLS_V1_1.0\"]\n", "\n", "# Setup search options\n", "search_opts = {\n", @@ -132,7 +149,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# let's filter our results so that only scenes with less than 10% cloud cover are returned\n", @@ -144,7 +165,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Load results into dataframe\n", @@ -154,7 +179,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "granules.tile_id.unique()" @@ -163,16 +192,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ - "mosaicked_img, mosaic_transform = merge(list(granules.hrefs))" + "%time mosaicked_img, mosaic_transform = merge(list(granules.hrefs))" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "bounds = array_bounds(6994, 6992, mosaic_transform)" @@ -181,7 +218,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "bounds" @@ -190,7 +231,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "def mosaic_and_dataset(granule_dataframe):\n", @@ -236,16 +281,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ - "dataset = mosaic_and_dataset(granules)" + "%time dataset = mosaic_and_dataset(granules)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define a colormap\n", @@ -258,7 +311,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'Lake Mead, NV USA - mosaicked water extent',\n", @@ -279,7 +336,7 @@ ], "metadata": { "kernelspec": { - "display_name": "climaterisk", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -293,9 +350,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/04_Case_Studies/2a-Greece-Wildfires.ipynb b/04_Case_Studies/2a-Greece-Wildfires.ipynb index e8817db..69dfb01 100644 --- a/04_Case_Studies/2a-Greece-Wildfires.ipynb +++ b/04_Case_Studies/2a-Greece-Wildfires.ipynb @@ -12,7 +12,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Plotting imports\n", @@ -61,7 +65,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "### 2023 Greece wildfires\n", "\n", @@ -73,7 +81,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define AOI as a point, to which we will apply a buffer\n", @@ -87,7 +99,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "dadia_forest_gv = gv.Points([dadia_forest])\n", @@ -109,7 +125,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define data search parameters\n", @@ -125,7 +145,7 @@ "# LPCLOUD refers to the LP DAAC cloud environment that hosts earth observation data\n", "catalog = Client.open(f'{STAC_URL}/LPCLOUD/') \n", "\n", - "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1_1\"]\n", "\n", "# We would like to search data for August-September 2023\n", "date_range = f'{start_date.strftime(\"%Y-%m-%d\")}/{stop_date.strftime(\"%Y-%m-%d\")}'\n", @@ -136,15 +156,20 @@ " 'datetime' : date_range,\n", "}\n", "\n", - "search = catalog.search(**search_opts)" + "%time search = catalog.search(**search_opts)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "results = list(search.items_as_dicts())\n", "print(f\"Number of tiles found intersecting given AOI: {len(results)}\")" ] @@ -152,7 +177,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Let's load results into a pandas dataframe\n", @@ -163,7 +192,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Let's refine the dataframe a bit more so that we group together granules by \n", @@ -181,7 +214,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# The wildfire near Alexandroupolis started on August 21st and rapidly spread, particularly affecting the nearby Dadia Forest\n", @@ -197,7 +234,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define color map to generate plot (Red, Green, Blue, Alpha)\n", @@ -211,9 +252,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "fig, ax = plt.subplots(1, 3, figsize = (30, 10))\n", "crs = None\n", "\n", @@ -261,9 +307,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "damage_area = []\n", "conversion_factor = (30*1e-3)**2 # to convert pixel count to area in km^2; each pixel is 30x30 meters\n", "\n", @@ -278,7 +329,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "fig, ax = plt.subplots(1, 1, figsize=(20, 10))\n", @@ -287,13 +342,13 @@ "plt.ylabel('Area damaged by wildfire (km$^2$)', size=15)\n", "plt.xlabel('Date', size=15)\n", "plt.xticks([datetime(year=2023, month=8, day=1) + timedelta(days=6*i) for i in range(11)], size=14)\n", - "plt.title('2023 Dadia forest wildfire detected extent', size=14)" + "plt.title('2023 Dadia forest wildfire detected extent', size=14);" ] } ], "metadata": { "kernelspec": { - "display_name": "climaterisk", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -307,9 +362,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/04_Case_Studies/2b-Maranhao-Deforestation.ipynb b/04_Case_Studies/2b-Maranhao-Deforestation.ipynb index d5065f6..bd539bb 100644 --- a/04_Case_Studies/2b-Maranhao-Deforestation.ipynb +++ b/04_Case_Studies/2b-Maranhao-Deforestation.ipynb @@ -14,7 +14,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -55,7 +59,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "maranhao = (-43.65, -3.00)\n", @@ -68,7 +76,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# visualize AOI as a sanity check\n", @@ -90,7 +102,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "NOTE: The OPERA DIST data product is hosted on [LP DAAC](https://lpdaac.usgs.gov/news/lp-daac-releases-opera-land-surface-disturbance-alert-version-1-data-product/), and this is specified when setting up the PySTAC client to search their catalog of data products in the above code cell." ] @@ -98,9 +114,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# We will search data through the product record\n", "start_date = datetime(year=2022, month=1, day=1)\n", "stop_date = datetime(year=2024, month=3, day=31)\n", @@ -112,7 +133,7 @@ "# LPCLOUD refers to the LP DAAC cloud environment that hosts earth observation data\n", "catalog = Client.open(f'{STAC_URL}/LPCLOUD/') \n", "\n", - "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1_1\"]\n", "\n", "# We would like to search data for August-September 2023\n", "date_range = f'{start_date.strftime(\"%Y-%m-%d\")}/{stop_date.strftime(\"%Y-%m-%d\")}'\n", @@ -131,7 +152,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# let's filter our results so that only scenes with less than 10% cloud cover are returned\n", @@ -143,9 +168,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# Load results into a pandas dataframe\n", "granules = search_to_df(results, layer_name='VEG-DIST-STATUS')\n", "\n", @@ -158,7 +188,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "**Values in the VEG-DIST-STATUS of the DIST-ALERT product is interpreted as follows:**\n", "\n", @@ -176,7 +210,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define color map to generate plot (Red, Green, Blue, Alpha)\n", @@ -190,7 +228,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'Deforestation in Maranhão, Brazil. Disturbance Alerts',\n", @@ -225,7 +267,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/04_Case_Studies/2c-GreenWall-Senegal.ipynb b/04_Case_Studies/2c-GreenWall-Senegal.ipynb index 5203ee5..7722824 100644 --- a/04_Case_Studies/2c-GreenWall-Senegal.ipynb +++ b/04_Case_Studies/2c-GreenWall-Senegal.ipynb @@ -14,7 +14,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "from warnings import filterwarnings\n", @@ -55,7 +59,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "ndiaye_senegal = (-16.0913, 16.528)\n", @@ -68,7 +76,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# visualize AOI as a sanity check\n", @@ -98,9 +110,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# We will search data through the product record\n", "start_date = datetime(year=2022, month=1, day=1)\n", "stop_date = datetime.now()\n", @@ -112,7 +129,7 @@ "# LPCLOUD refers to the LP DAAC cloud environment that hosts earth observation data\n", "catalog = Client.open(f'{STAC_URL}/LPCLOUD/') \n", "\n", - "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1\"]\n", + "collections = [\"OPERA_L3_DIST-ALERT-HLS_V1_1\"]\n", "\n", "# We would like to search data for August-September 2023\n", "date_range = f'{start_date.strftime(\"%Y-%m-%d\")}/{stop_date.strftime(\"%Y-%m-%d\")}'\n", @@ -131,7 +148,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# let's filter our results so that only scenes with less than 10% cloud cover are returned\n", @@ -143,9 +164,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ + "%%time\n", "# Load results into a pandas dataframe\n", "granules = search_to_df(results, layer_name='VEG-DIST-STATUS')\n", "\n", @@ -158,7 +184,11 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "source": [ "**Values in the VEG-DIST-STATUS of the DIST-ALERT product is interpreted as follows:**\n", "\n", @@ -176,7 +206,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "# Define color map to generate plot (Red, Green, Blue, Alpha)\n", @@ -190,7 +224,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "img = dataset.hvplot.image(title = 'Great Green Wall, Sahel Region, Africa. Disturbance Alerts',\n", @@ -225,7 +263,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4,