{ "cells": [ { "cell_type": "markdown", "id": "metropolitan-miracle", "metadata": {}, "source": [ "# Base run\n", "A simple run of `xagg`, aggregating gridded temperature data over US counties. For a deeper dive into `xagg`'s functionality, see the [Detailed Code Run](./full_run.ipynb). " ] }, { "cell_type": "code", "execution_count": 1, "id": "sound-choir", "metadata": {}, "outputs": [], "source": [ "import xagg as xa\n", "import xarray as xr\n", "import numpy as np\n", "import geopandas as gpd" ] }, { "cell_type": "markdown", "id": "disabled-ribbon", "metadata": {}, "source": [ "## Import\n", "The sample data in this example are:\n", "\n", "- gridded: month-of-year average temperature projections for the end-of-century from a climate model (CCSM4)\n", "- shapefiles: US counties" ] }, { "cell_type": "code", "execution_count": 2, "id": "simple-spelling", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (lon: 288, lat: 192, month: 12, bnds: 2)\n",
"Coordinates:\n",
" height float64 ...\n",
" * lon (lon) float64 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8\n",
" * lat (lat) float64 -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0\n",
" * month (month) int64 1 2 3 4 5 6 7 8 9 10 11 12\n",
"Dimensions without coordinates: bnds\n",
"Data variables:\n",
" lat_bnds (month, lat, bnds) float64 ...\n",
" lon_bnds (month, lon, bnds) float64 ...\n",
" tas (month, lat, lon) float32 ...| \n", " | NAME | \n", "STATE_NAME | \n", "STATE_FIPS | \n", "CNTY_FIPS | \n", "FIPS | \n", "geometry | \n", "
|---|---|---|---|---|---|---|
| 0 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "POLYGON ((-95.34283 48.54668, -95.34105 48.715... | \n", "
| 1 | \n", "Ferry | \n", "Washington | \n", "53 | \n", "019 | \n", "53019 | \n", "POLYGON ((-118.85163 47.94956, -118.84846 48.4... | \n", "
| 2 | \n", "Stevens | \n", "Washington | \n", "53 | \n", "065 | \n", "53065 | \n", "POLYGON ((-117.43883 48.04412, -117.54219 48.0... | \n", "
| 3 | \n", "Okanogan | \n", "Washington | \n", "53 | \n", "047 | \n", "53047 | \n", "POLYGON ((-118.97209 47.93915, -118.97406 47.9... | \n", "
| 4 | \n", "Pend Oreille | \n", "Washington | \n", "53 | \n", "051 | \n", "53051 | \n", "POLYGON ((-117.43858 48.99992, -117.03205 48.9... | \n", "
<xarray.Dataset>\n",
"Dimensions: (poly_idx: 3141, month: 12)\n",
"Coordinates:\n",
" * poly_idx (poly_idx) int64 0 1 2 3 4 5 6 ... 3135 3136 3137 3138 3139 3140\n",
" * month (month) int64 1 2 3 4 5 6 7 8 9 10 11 12\n",
"Data variables:\n",
" NAME (poly_idx) object 'Lake of the Woods' 'Ferry' ... 'Broomfield'\n",
" STATE_NAME (poly_idx) object 'Minnesota' 'Washington' ... 'Colorado'\n",
" STATE_FIPS (poly_idx) object '27' '53' '53' '53' ... '02' '02' '02' '08'\n",
" CNTY_FIPS (poly_idx) object '077' '019' '065' '047' ... '240' '068' '014'\n",
" FIPS (poly_idx) object '27077' '53019' '53065' ... '02068' '08014'\n",
" tas (poly_idx, month) float64 263.9 268.8 274.0 ... 276.4 270.4| \n", " | \n", " | NAME | \n", "STATE_NAME | \n", "STATE_FIPS | \n", "CNTY_FIPS | \n", "FIPS | \n", "tas | \n", "
|---|---|---|---|---|---|---|---|
| poly_idx | \n", "month | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
| 0 | \n", "1 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "263.918943 | \n", "
| 2 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "268.834073 | \n", "|
| 3 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "273.977533 | \n", "|
| 4 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "283.141960 | \n", "|
| 5 | \n", "Lake of the Woods | \n", "Minnesota | \n", "27 | \n", "077 | \n", "27077 | \n", "290.623952 | \n", "|
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 3140 | \n", "8 | \n", "Broomfield | \n", "Colorado | \n", "08 | \n", "014 | \n", "08014 | \n", "297.646820 | \n", "
| 9 | \n", "Broomfield | \n", "Colorado | \n", "08 | \n", "014 | \n", "08014 | \n", "292.368988 | \n", "|
| 10 | \n", "Broomfield | \n", "Colorado | \n", "08 | \n", "014 | \n", "08014 | \n", "283.544708 | \n", "|
| 11 | \n", "Broomfield | \n", "Colorado | \n", "08 | \n", "014 | \n", "08014 | \n", "276.383606 | \n", "|
| 12 | \n", "Broomfield | \n", "Colorado | \n", "08 | \n", "014 | \n", "08014 | \n", "270.444855 | \n", "
37692 rows × 6 columns
\n", "