From c18ede40df214caff053b7340707e3c4290adb83 Mon Sep 17 00:00:00 2001 From: Kevin Schwarzwald Date: Wed, 21 Aug 2024 14:03:17 -0400 Subject: [PATCH] update docs for diag_fig updates --- docs/source/notebooks/full_run.ipynb | 47 ++++++++-------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/docs/source/notebooks/full_run.ipynb b/docs/source/notebooks/full_run.ipynb index 1879f21..ab073cd 100644 --- a/docs/source/notebooks/full_run.ipynb +++ b/docs/source/notebooks/full_run.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "broken-labor", "metadata": {}, "outputs": [], @@ -237,36 +237,7 @@ "id": "a0ceaf52-bc04-4630-a017-8157b24ce9d0", "metadata": {}, "source": [ - "Let's verify if the aggregation was successful. The `weightmap` class can produce diagnostic figures that show a given polygon + the grid cells of the original raster dataset that overlap it. (This feature is still a bit experimental and finicky, and as of v0.3.2.0 needs a little bit of manual processing) " - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "d136f646-836b-4c0a-8d5c-e84e5e25a38b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "adjusting grid... (this may happen because only a subset of pixels were used for aggregation for efficiency - i.e. [subset_bbox=True] in xa.pixel_overlaps())\n", - "grid adjustment successful\n" - ] - } - ], - "source": [ - "# Load `subset_find()`, which allows you to find one grid within another\n", - "from xagg.auxfuncs import subset_find\n", - "\n", - "# weightmap.diag_fig() takes two required arguments: some information about\n", - "# a grid, and either the polygons of the raster grid, or the raster grid\n", - "# itself to calculate the polygons. \n", - "\n", - "# Let's get the raster grid.\n", - "# To match the internal indexing of `weightmap`, we need to subset the `ds`\n", - "# TODO: move this step internally to `weightmap.diag_fig()`\n", - "grid_polygon_info = subset_find(ds,weightmap.source_grid)" + "Let's verify if the aggregation was successful. The `weightmap` class can produce diagnostic figures that show a given polygon + the grid cells of the original raster dataset that overlap it." ] }, { @@ -290,7 +261,15 @@ "# Create diagnostic figure of the polygon with index 50 in `gdf` (in this \n", "# case, a county in Montana). You can verify this is the 50th row in `gdf`\n", "# by printing `gdf.loc[50]`. \n", - "weightmap.diag_fig(50,grid_polygon_info)" + "weightmap.diag_fig(50,ds)" + ] + }, + { + "cell_type": "markdown", + "id": "075f03b0-f099-44fe-a157-8b1825849bb6", + "metadata": {}, + "source": [ + "This diagnostic figure shows the weight used for each grid, relative to the grid cell with the largest overlap. For this county in Montana, the middle grid cell has the largest area overlap, followed by the grid cell to the left. The bottom right grid cell only barely touches the county and therefore has a much lower relative weight in the aggregation calculation. " ] }, { @@ -334,7 +313,7 @@ "source": [ "# Let's use the \"NAME\" (aka, county name) column to plot a \n", "# diagnostic plot of Los Angeles county\n", - "weightmap.diag_fig({'NAME':'Los Angeles'},grid_polygon_info)" + "weightmap.diag_fig({'NAME':'Los Angeles'},ds)" ] }, { @@ -1138,7 +1117,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.12.1" } }, "nbformat": 4,