Skip to content

Commit

Permalink
DOC: Update disturbance/recovery dates in example (#153)
Browse files Browse the repository at this point in the history
* Fix bad dates in README quick start

* Fix bad dates in MEE notebook
  • Loading branch information
szwiep authored Aug 26, 2024
1 parent ae03d36 commit 0ef8d43
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
68 changes: 34 additions & 34 deletions docs/notebooks/MEE_worked_example_32.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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"
]
},
{
Expand All @@ -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\"])"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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]"
]
},
{
Expand All @@ -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]"
]
},
{
Expand All @@ -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",
Expand Down

0 comments on commit 0ef8d43

Please sign in to comment.