Skip to content

Commit

Permalink
update docs for diag_fig updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ks905383 committed Aug 21, 2024
1 parent 7ceb441 commit c18ede4
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions docs/source/notebooks/full_run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "broken-labor",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -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."
]
},
{
Expand All @@ -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. "
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -1138,7 +1117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c18ede4

Please sign in to comment.