From 0ef8d43e5b6068210ad5ed534bd6a2d6d89a1672 Mon Sep 17 00:00:00 2001 From: Sarah Zwiep <57023024+szwiep@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:13:39 -0700 Subject: [PATCH] DOC: Update disturbance/recovery dates in example (#153) * Fix bad dates in README quick start * Fix bad dates in MEE notebook --- README.md | 2 +- docs/notebooks/MEE_worked_example_32.ipynb | 68 +++++++++++----------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index b3108fd..e15c7bb 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ index_ts = sr.compute_indices( # Read in restoration site(s) rest_site = sr.read_restoration_site( path=data.bc06_wildfire_restoration_site(), - dist_rest_years={0: [2006, 2007]}, + dist_rest_years={0: [2005, 2006]}, ) # Compute recovery target for restoration site median_hist = sr.recovery_targets.historic.median( diff --git a/docs/notebooks/MEE_worked_example_32.ipynb b/docs/notebooks/MEE_worked_example_32.ipynb index c9f715d..ec3f3aa 100644 --- a/docs/notebooks/MEE_worked_example_32.ipynb +++ b/docs/notebooks/MEE_worked_example_32.ipynb @@ -8,10 +8,10 @@ "\n", "The workflow can be broken down into 4 steps:\n", "\n", - "1. Read timeseries data/compute indices\n", - "2. Define the restoration site\n", - "3. Compute a recovery target\n", - "4. Compute recovery metrics" + "0. Read input data (timeseries and restoration site)\n", + "1. Compute spectral indices\n", + "2. Compute a recovery target\n", + "3. Compute recovery metrics" ] }, { @@ -39,12 +39,15 @@ "metadata": {}, "outputs": [], "source": [ - "# 1. Read in the timeseries data and compute indices\n", + "# 0. Read input data (timeseries and restoration site)\n", "ts = sr.read_timeseries(\n", - " paths=data.bc06_wildfire_landsat_bap_timeseries(),\n", + " path_to_tifs=data.bc06_wildfire_landsat_bap_timeseries(),\n", " band_names={1: \"blue\", 2: \"green\", 3: \"red\", 4: \"nir\", 5: \"swir16\", 6: \"swir22\"},\n", ")\n", - "indices = sr.compute_indices(ts, indices=[\"NBR\"])" + "rest_site = sr.read_restoration_sites(\n", + " path=data.bc06_wildfire_restoration_site(),\n", + " dist_rest_years={0: [2005, 2006]}\n", + ")\n" ] }, { @@ -53,11 +56,8 @@ "metadata": {}, "outputs": [], "source": [ - "# 2. Define the restoration site\n", - "rest_site = sr.read_restoration_sites(\n", - " path=data.bc06_wildfire_restoration_site(),\n", - " dist_rest_years={0: [2006, 2007]}\n", - ")" + "# 1. Compute spectral indices\n", + "indices = sr.compute_indices(ts, indices=[\"NBR\"])" ] }, { @@ -71,31 +71,31 @@ "fig, axs = plt.subplots(1, 5, figsize=(15, 12))\n", "axs = axs.flatten()\n", "\n", - "# Plot the band data\n", - "rgb1 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2005-01-01\")\n", + "rgb1 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2004-01-01\")\n", "rgb1.plot.imshow(ax=axs[0])\n", "rest_site.to_crs(indices.spatial_ref.crs_wkt).plot(ax=axs[0], edgecolor='red', facecolor='none', linewidth=2)\n", - "axs[0].set_title(\"2005\")\n", + "axs[0].set_title(\"2004\")\n", "\n", - "rgb1 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2006-01-01\")\n", - "rgb1.plot.imshow(ax=axs[1])\n", + "# Plot the band data\n", + "rgb2 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2005-01-01\")\n", + "rgb2.plot.imshow(ax=axs[1])\n", "rest_site.to_crs(indices.spatial_ref.crs_wkt).plot(ax=axs[1], edgecolor='red', facecolor='none', linewidth=2)\n", - "axs[1].set_title(\"2006\")\n", + "axs[1].set_title(\"2005 (pre-fire)\")\n", "\n", - "rgb2 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2007-01-01\")\n", - "rgb2.plot.imshow(ax=axs[2])\n", + "rgb3 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2006-01-01\")\n", + "rgb3.plot.imshow(ax=axs[2])\n", "rest_site.to_crs(indices.spatial_ref.crs_wkt).plot(ax=axs[2], edgecolor='red', facecolor='none', linewidth=2)\n", - "axs[2].set_title(\"2007 (post-fire)\")\n", + "axs[2].set_title(\"2006 (post-fire)\")\n", "\n", - "rgb3 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2008-01-01\")\n", - "rgb3.plot.imshow(ax=axs[3])\n", + "rgb4 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2007-01-01\")\n", + "rgb4.plot.imshow(ax=axs[3])\n", "rest_site.to_crs(indices.spatial_ref.crs_wkt).plot(ax=axs[3], edgecolor='red', facecolor='none', linewidth=2)\n", - "axs[3].set_title(\"2008\")\n", + "axs[3].set_title(\"2007\")\n", "\n", - "rgb4 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2009-01-01\")\n", - "rgb4.plot.imshow(ax=axs[4])\n", + "rgb5 = ts.sel(band=[\"R\", \"G\", \"B\"], time=\"2008-01-01\")\n", + "rgb5.plot.imshow(ax=axs[4])\n", "rest_site.to_crs(indices.spatial_ref.crs_wkt).plot(ax=axs[4], edgecolor='red', facecolor='none', linewidth=2)\n", - "axs[4].set_title(\"2009\")" + "axs[4].set_title(\"2008\")\n" ] }, { @@ -104,14 +104,14 @@ "metadata": {}, "outputs": [], "source": [ - "# 3. Compute a historic median recovery target\n", + "# 2. Compute a historic median recovery target\n", "target = sr.targets.historic.median(\n", " restoration_sites=rest_site,\n", " timeseries_data=indices,\n", " reference_years={0:[2003, 2005]},\n", " scale=\"pixel\"\n", ")\n", - "target" + "target[0]" ] }, { @@ -120,14 +120,14 @@ "metadata": {}, "outputs": [], "source": [ - "# 4. Compute R80P and Y2R recovery metrics \n", + "# 3. Compute R80P and Y2R recovery metrics \n", "metrics = sr.compute_metrics(\n", - " metrics=[\"dNBR\", \"R80P\", \"YrYr\", \"Y2R\"],\n", + " metrics=[\"deltaIR\", \"R80P\", \"YrYr\", \"Y2R\"],\n", " restoration_sites=rest_site,\n", " timeseries_data=indices,\n", " recovery_targets=target, \n", ")\n", - "metrics" + "metrics[0]" ] }, { @@ -144,9 +144,9 @@ "axs = axs.flatten()\n", "\n", "# Plot dIR\n", - "img = metrics[0].sel(metric=\"dNBR\", band=\"NBR\")\n", + "img = metrics[0].sel(metric=\"deltaIR\", band=\"NBR\")\n", "im = axs[0].imshow(img, cmap='RdYlGn', vmax=\"0.5\", vmin=\"-0.5\")\n", - "axs[0].set_title(\"dNBR (2007-2012)\")\n", + "axs[0].set_title(\"deltaIR (2007-2012)\")\n", "axs[0].axis('off')\n", "plt.colorbar(im, ax=axs[0], fraction=0.046, pad=0.04)\n", "\n",