Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save larsbuntemeyer/105d83c1eb39b1462150d3fabca0b66b to your computer and use it in GitHub Desktop.
Save larsbuntemeyer/105d83c1eb39b1462150d3fabca0b66b to your computer and use it in GitHub Desktop.
using pyproj for rotated coordinate transformations
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "3e3fb963-f3ec-457a-bae7-5b195e6277e7",
"metadata": {
"tags": []
},
"source": [
"# Using pyproj for rotated coordinate transformations"
]
},
{
"cell_type": "markdown",
"id": "175917e5-99c3-411e-883a-ed6393fa1539",
"metadata": {},
"source": [
"Create a dataset that will have not precise coordinate bounds."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "62867888-81dd-4213-87bf-d4bd8eb756dc",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (rlat: 3, rlon: 3)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.1176 0.3468 0.3661</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-af14c25a-66d7-46d9-acc5-4e3d27f2474b' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-af14c25a-66d7-46d9-acc5-4e3d27f2474b' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>rlat</span>: 3</li><li><span class='xr-has-index'>rlon</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-9acd5f39-cbfe-4bd7-80cd-a7f6fdc3a29f' class='xr-section-summary-in' type='checkbox' checked><label for='section-9acd5f39-cbfe-4bd7-80cd-a7f6fdc3a29f' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlat</span></div><div class='xr-var-dims'>(rlat)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>21.61 21.73 21.84</div><input id='attrs-455a2719-2bd0-4ad4-8a8f-d6a5f7646cb0' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-455a2719-2bd0-4ad4-8a8f-d6a5f7646cb0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e532c620-5f3e-4742-9d80-3b2cc5b7e629' class='xr-var-data-in' type='checkbox'><label for='data-e532c620-5f3e-4742-9d80-3b2cc5b7e629' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([21.615, 21.725, 21.835])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlon</span></div><div class='xr-var-dims'>(rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>17.93 18.05 18.16</div><input id='attrs-d30aed4e-14b7-493f-96f4-5aba67a31d2f' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-d30aed4e-14b7-493f-96f4-5aba67a31d2f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-366e6a60-1c06-4cbf-bb4c-e8537e07ade3' class='xr-var-data-in' type='checkbox'><label for='data-366e6a60-1c06-4cbf-bb4c-e8537e07ade3' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([17.935, 18.045, 18.155])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-f342b85f-18c7-47f3-aa25-b63d9a19b39f' class='xr-section-summary-in' type='checkbox' checked><label for='section-f342b85f-18c7-47f3-aa25-b63d9a19b39f' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>dummy</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.284 0.8978 ... 0.3468 0.3661</div><input id='attrs-4b112626-cd9c-4c22-ab0b-e04437d6f21d' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-4b112626-cd9c-4c22-ab0b-e04437d6f21d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8c4d7dc2-726c-4dc1-90f2-98e2127d756d' class='xr-var-data-in' type='checkbox'><label for='data-8c4d7dc2-726c-4dc1-90f2-98e2127d756d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[0.28397272, 0.89775427, 0.43479115],\n",
" [0.28360206, 0.9023181 , 0.38709963],\n",
" [0.11759964, 0.34684183, 0.36607847]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-1aa30067-262b-44fe-bcfb-641a7bced018' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-1aa30067-262b-44fe-bcfb-641a7bced018' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (rlat: 3, rlon: 3)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.1176 0.3468 0.3661"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import cf_xarray as cfxr\n",
"import numpy as np\n",
"import xarray as xr\n",
"\n",
"ds = xr.Dataset(\n",
" coords=dict(\n",
" rlat=([\"rlat\"], [21.615, 21.725, 21.835]),\n",
" rlon=([\"rlon\"], [17.935, 18.045, 18.155]),\n",
" ),\n",
" data_vars=dict(dummy=([\"rlat\", \"rlon\"], np.random.rand(3, 3)),),\n",
")\n",
"\n",
"ds"
]
},
{
"cell_type": "markdown",
"id": "71674102-cc26-4712-afe6-0965ffa93a01",
"metadata": {},
"source": [
"Choose these numbers since actually this should be true, but isn't (due to floating point limitations):"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b2a07ed7-2292-4db9-88e0-e1274be77b86",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"21.615 + 0.055 == 21.725 - 0.055 # e.g. right boundary of i-1 should be the same as left boundary of i"
]
},
{
"cell_type": "markdown",
"id": "5ae621c3-00a1-4654-8627-88a2772b5863",
"metadata": {},
"source": [
"In our case, this means that boundaries of neigbhouring grid cells do not macht always, e.g."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f678626d-8f96-4f04-b5e0-3746b4b36378",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rlon_bounds = ds.cf.add_bounds(\"rlon\").rlon_bounds\n",
"np.all(rlon_bounds.isel(bounds=0).data[1:] == rlon_bounds.isel(bounds=1).data[:-1])"
]
},
{
"cell_type": "markdown",
"id": "28525787-88d8-4a4c-a75b-e54f7e85a10c",
"metadata": {},
"source": [
"... but they are close"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "03338004-e470-4759-b17a-4ec79f165d30",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.allclose(rlon_bounds.isel(bounds=0).data[1:], rlon_bounds.isel(bounds=1).data[:-1])"
]
},
{
"cell_type": "markdown",
"id": "4583ee43-a629-43f1-8caa-4f14c5c789a9",
"metadata": {},
"source": [
"Now, define xarray wrapper for computing transformed coordinates"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f3bc3a10-a7f1-4ab2-aa1f-bbaa857d5772",
"metadata": {},
"outputs": [],
"source": [
"import cordex as cx\n",
"import numpy as np\n",
"import xarray as xr\n",
"from pyproj import CRS, Transformer\n",
"\n",
"world = CRS(\"EPSG:4326\")\n",
"world\n",
"\n",
"rotated = CRS.from_cf(\n",
" {\n",
" \"grid_mapping_name\": \"rotated_latitude_longitude\",\n",
" \"grid_north_pole_latitude\": 39.25,\n",
" \"grid_north_pole_longitude\": -162.0,\n",
" }\n",
")\n",
"\n",
"\n",
"def _transform(x, y, src_crs, trg_crs):\n",
" \"\"\"helper function for transforming coordinates\"\"\"\n",
" x_stack = np.broadcast_to(x, (y.shape[0], x.shape[0])).T\n",
" y_stack = np.broadcast_to(y, (x.shape[0], y.shape[0]))\n",
" transformer = Transformer.from_crs(src_crs, trg_crs)\n",
" y_transform, x_transform = transformer.transform(x_stack, y_stack)\n",
" return x_transform.T, y_transform.T\n",
"\n",
"\n",
"def transform(x, y, src_crs, trg_crs=None):\n",
" \"\"\"coordinate transformation of x and y.\"\"\"\n",
" if trg_crs is None:\n",
" trg_crs = CRS(\"EPSG:4326\")\n",
" input_core_dims = [[x.dims[0]], [y.dims[0]]] + [[], []]\n",
" output_core_dims = 2 * [[y.dims[0], x.dims[0]]]\n",
" result = xr.apply_ufunc(\n",
" _transform,\n",
" x,\n",
" y,\n",
" src_crs,\n",
" trg_crs,\n",
" input_core_dims=input_core_dims,\n",
" output_core_dims=output_core_dims,\n",
" )\n",
" result[0].name = \"xt\"\n",
" result[1].name = \"yt\"\n",
" return result"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "4adf830b-e086-41df-8251-c184a1079957",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (rlat: 3, rlon: 3)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
" lon (rlat, rlon) float64 64.22 64.42 64.63 64.38 ... 64.55 64.76 64.96\n",
" lat (rlat, rlon) float64 66.64 66.58 66.52 66.73 ... 66.81 66.75 66.69\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.1176 0.3468 0.3661</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-5d5a0765-2804-4ac6-8d0d-4b1a251e3d23' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-5d5a0765-2804-4ac6-8d0d-4b1a251e3d23' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>rlat</span>: 3</li><li><span class='xr-has-index'>rlon</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-8815f0aa-7b64-4af9-9f37-f83cd2bf7ace' class='xr-section-summary-in' type='checkbox' checked><label for='section-8815f0aa-7b64-4af9-9f37-f83cd2bf7ace' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlat</span></div><div class='xr-var-dims'>(rlat)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>21.61 21.73 21.84</div><input id='attrs-65f287f7-61ef-497b-b0e6-a50891be1e38' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-65f287f7-61ef-497b-b0e6-a50891be1e38' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-452a32f3-f2a8-400b-acb5-66c6376207dd' class='xr-var-data-in' type='checkbox'><label for='data-452a32f3-f2a8-400b-acb5-66c6376207dd' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([21.615, 21.725, 21.835])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlon</span></div><div class='xr-var-dims'>(rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>17.93 18.05 18.16</div><input id='attrs-7937c195-b072-46e5-a311-9540831772fa' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-7937c195-b072-46e5-a311-9540831772fa' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c623ac56-3e17-423f-b4e4-5e005682fb88' class='xr-var-data-in' type='checkbox'><label for='data-c623ac56-3e17-423f-b4e4-5e005682fb88' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([17.935, 18.045, 18.155])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lon</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>64.22 64.42 64.63 ... 64.76 64.96</div><input id='attrs-3b7e0e15-4014-4998-98b0-836795c02d7b' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-3b7e0e15-4014-4998-98b0-836795c02d7b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ad68b5dc-9a7d-4710-99fa-ba0c9c1083f5' class='xr-var-data-in' type='checkbox'><label for='data-ad68b5dc-9a7d-4710-99fa-ba0c9c1083f5' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[64.21746364, 64.42305922, 64.62774455],\n",
" [64.38488381, 64.59063409, 64.79546746],\n",
" [64.55349992, 64.75940009, 64.96437667]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>66.64 66.58 66.52 ... 66.75 66.69</div><input id='attrs-29765151-b1fa-4f45-a9f7-e9ef4bcf84dc' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-29765151-b1fa-4f45-a9f7-e9ef4bcf84dc' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0111be63-3a9d-4ce7-afa5-982ee182eae7' class='xr-var-data-in' type='checkbox'><label for='data-0111be63-3a9d-4ce7-afa5-982ee182eae7' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[66.63852915, 66.57692365, 66.51510791],\n",
" [66.72632651, 66.66454929, 66.60256233],\n",
" [66.81394504, 66.75199541, 66.68983654]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-7d17f1b5-ba83-408c-acf9-76d30db2652e' class='xr-section-summary-in' type='checkbox' checked><label for='section-7d17f1b5-ba83-408c-acf9-76d30db2652e' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>dummy</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.284 0.8978 ... 0.3468 0.3661</div><input id='attrs-d0292274-6ad5-4c8a-8a3d-bca201da47bd' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-d0292274-6ad5-4c8a-8a3d-bca201da47bd' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-23b4a6ce-f35d-4d5a-9b21-e807ee5cb1e2' class='xr-var-data-in' type='checkbox'><label for='data-23b4a6ce-f35d-4d5a-9b21-e807ee5cb1e2' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[0.28397272, 0.89775427, 0.43479115],\n",
" [0.28360206, 0.9023181 , 0.38709963],\n",
" [0.11759964, 0.34684183, 0.36607847]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-b883b159-6988-4013-ae28-9860fd7ff2e6' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-b883b159-6988-4013-ae28-9860fd7ff2e6' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (rlat: 3, rlon: 3)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
" lon (rlat, rlon) float64 64.22 64.42 64.63 64.38 ... 64.55 64.76 64.96\n",
" lat (rlat, rlon) float64 66.64 66.58 66.52 66.73 ... 66.81 66.75 66.69\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.1176 0.3468 0.3661"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lon, lat = transform(ds.rlon, ds.rlat, rotated)\n",
"ds = ds.assign_coords(lon=lon, lat=lat)\n",
"ds"
]
},
{
"cell_type": "markdown",
"id": "a8faa825-fb61-472d-a552-32bbffb0baa4",
"metadata": {},
"source": [
"now we transform also the 1D boundaries into the global coordinates..."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "aa572704-f1b6-435b-a14f-74ab3dfb26cd",
"metadata": {},
"outputs": [],
"source": [
"def lon_lat_bounds(ds, src_crs):\n",
" # add 1d bounds\n",
" rlon_bounds = ds.cf.add_bounds(\"rlon\").rlon_bounds.drop(\"rlon_bounds\")\n",
" rlat_bounds = ds.cf.add_bounds(\"rlat\").rlat_bounds.drop(\"rlat_bounds\")\n",
" # counterclockwise transformed boundaries\n",
" bot_left = transform(\n",
" rlon_bounds.isel(bounds=0), rlat_bounds.isel(bounds=0), src_crs\n",
" )\n",
" bot_right = transform(\n",
" rlon_bounds.isel(bounds=1), rlat_bounds.isel(bounds=0), src_crs\n",
" )\n",
" top_right = transform(\n",
" rlon_bounds.isel(bounds=1), rlat_bounds.isel(bounds=1), src_crs\n",
" )\n",
" top_left = transform(\n",
" rlon_bounds.isel(bounds=0), rlat_bounds.isel(bounds=1), src_crs\n",
" )\n",
" lon_bounds = xr.concat(\n",
" [bot_left[0], bot_right[0], top_right[0], top_left[0]], dim=\"vertices\"\n",
" )\n",
" lat_bounds = xr.concat(\n",
" [bot_left[1], bot_right[1], top_right[1], top_left[1]], dim=\"vertices\"\n",
" )\n",
" return lon_bounds, lat_bounds"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "0a7a8ccc-c958-49f0-8b88-18b9eb997d7e",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (rlat: 3, rlon: 3, vertices: 4)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
" lon (rlat, rlon) float64 64.22 64.42 64.63 ... 64.55 64.76 64.96\n",
" lat (rlat, rlon) float64 66.64 66.58 66.52 ... 66.81 66.75 66.69\n",
"Dimensions without coordinates: vertices\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.3468 0.3661\n",
" lon_bounds (vertices, rlat, rlon) float64 64.03 64.24 64.44 ... 64.74 64.95\n",
" lat_bounds (vertices, rlat, rlon) float64 66.63 66.56 66.5 ... 66.83 66.76</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-77bf886b-c694-4381-8ee9-a5eb46fb3d67' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-77bf886b-c694-4381-8ee9-a5eb46fb3d67' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>rlat</span>: 3</li><li><span class='xr-has-index'>rlon</span>: 3</li><li><span>vertices</span>: 4</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-09d47900-2e5e-4765-8f17-43acda3b5558' class='xr-section-summary-in' type='checkbox' checked><label for='section-09d47900-2e5e-4765-8f17-43acda3b5558' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlat</span></div><div class='xr-var-dims'>(rlat)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>21.61 21.73 21.84</div><input id='attrs-98a35a76-e627-49cc-9b53-323d6c3ef615' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-98a35a76-e627-49cc-9b53-323d6c3ef615' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-3d11bf83-9656-4ffe-8417-025b60ced28a' class='xr-var-data-in' type='checkbox'><label for='data-3d11bf83-9656-4ffe-8417-025b60ced28a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([21.615, 21.725, 21.835])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>rlon</span></div><div class='xr-var-dims'>(rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>17.93 18.05 18.16</div><input id='attrs-1a290360-d916-4eae-b26a-26e65a32ac76' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-1a290360-d916-4eae-b26a-26e65a32ac76' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-97b9fb7d-b811-45a2-9321-e7013d29b14f' class='xr-var-data-in' type='checkbox'><label for='data-97b9fb7d-b811-45a2-9321-e7013d29b14f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([17.935, 18.045, 18.155])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lon</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>64.22 64.42 64.63 ... 64.76 64.96</div><input id='attrs-addeaebc-4058-48d2-b839-0e421fcda88e' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-addeaebc-4058-48d2-b839-0e421fcda88e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c0f07bbc-fcf4-40f9-9035-2b40ccb77a3f' class='xr-var-data-in' type='checkbox'><label for='data-c0f07bbc-fcf4-40f9-9035-2b40ccb77a3f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[64.21746364, 64.42305922, 64.62774455],\n",
" [64.38488381, 64.59063409, 64.79546746],\n",
" [64.55349992, 64.75940009, 64.96437667]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>66.64 66.58 66.52 ... 66.75 66.69</div><input id='attrs-0de7c072-1997-4bb2-a055-8a6ed090eeec' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0de7c072-1997-4bb2-a055-8a6ed090eeec' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a9161f11-50c0-43aa-9343-aec5cf4c0525' class='xr-var-data-in' type='checkbox'><label for='data-a9161f11-50c0-43aa-9343-aec5cf4c0525' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[66.63852915, 66.57692365, 66.51510791],\n",
" [66.72632651, 66.66454929, 66.60256233],\n",
" [66.81394504, 66.75199541, 66.68983654]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-c6d1cf6e-5637-451e-afc8-d3df4126097d' class='xr-section-summary-in' type='checkbox' checked><label for='section-c6d1cf6e-5637-451e-afc8-d3df4126097d' class='xr-section-summary' >Data variables: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>dummy</span></div><div class='xr-var-dims'>(rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.284 0.8978 ... 0.3468 0.3661</div><input id='attrs-0b4fa66f-3509-4b01-8d8c-af72825e963b' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0b4fa66f-3509-4b01-8d8c-af72825e963b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4609f2d7-d8d6-4a3c-a89c-3cb11e095150' class='xr-var-data-in' type='checkbox'><label for='data-4609f2d7-d8d6-4a3c-a89c-3cb11e095150' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[0.28397272, 0.89775427, 0.43479115],\n",
" [0.28360206, 0.9023181 , 0.38709963],\n",
" [0.11759964, 0.34684183, 0.36607847]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lon_bounds</span></div><div class='xr-var-dims'>(vertices, rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>64.03 64.24 64.44 ... 64.74 64.95</div><input id='attrs-03918a16-29b1-4708-aee3-1a5fbd4685d3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-03918a16-29b1-4708-aee3-1a5fbd4685d3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-cae594e5-8566-4585-a3a2-a3279d560c3b' class='xr-var-data-in' type='checkbox'><label for='data-cae594e5-8566-4585-a3a2-a3279d560c3b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[[64.03109896, 64.23707042, 64.44213291],\n",
" [64.19784426, 64.40397614, 64.60919235],\n",
" [64.36578232, 64.57206989, 64.77743506]],\n",
"\n",
" [[64.23707042, 64.44213291, 64.64629053],\n",
" [64.40397614, 64.60919235, 64.8134971 ],\n",
" [64.57206989, 64.77743506, 64.98188214]],\n",
"\n",
" [[64.40397614, 64.60919235, 64.8134971 ],\n",
" [64.57206989, 64.77743506, 64.98188214],\n",
" [64.74136272, 64.94687198, 65.15145647]],\n",
"\n",
" [[64.19784426, 64.40397614, 64.60919235],\n",
" [64.36578232, 64.57206989, 64.77743506],\n",
" [64.5349243 , 64.74136272, 64.94687198]]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat_bounds</span></div><div class='xr-var-dims'>(vertices, rlat, rlon)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>66.63 66.56 66.5 ... 66.83 66.76</div><input id='attrs-beca8b01-1e1a-444d-ba5e-b58796f21a54' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-beca8b01-1e1a-444d-ba5e-b58796f21a54' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e223afe6-2b4a-4093-812b-b4fb6f9ab290' class='xr-var-data-in' type='checkbox'><label for='data-e223afe6-2b4a-4093-812b-b4fb6f9ab290' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[[66.62524451, 66.5638305 , 66.50220514],\n",
" [66.71321641, 66.65163078, 66.58983429],\n",
" [66.80101082, 66.73925288, 66.67728458]],\n",
"\n",
" [[66.5638305 , 66.50220514, 66.44037017],\n",
" [66.65163078, 66.58983429, 66.52782867],\n",
" [66.73925288, 66.67728458, 66.61510765]],\n",
"\n",
" [[66.65163078, 66.58983429, 66.52782867],\n",
" [66.73925288, 66.67728458, 66.61510765],\n",
" [66.82669479, 66.76455399, 66.70220507]],\n",
"\n",
" [[66.71321641, 66.65163078, 66.58983429],\n",
" [66.80101082, 66.73925288, 66.67728458],\n",
" [66.88862573, 66.82669479, 66.76455399]]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-d218d564-aa77-4708-b2e6-7075ca3aee6c' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-d218d564-aa77-4708-b2e6-7075ca3aee6c' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (rlat: 3, rlon: 3, vertices: 4)\n",
"Coordinates:\n",
" * rlat (rlat) float64 21.61 21.73 21.84\n",
" * rlon (rlon) float64 17.93 18.05 18.16\n",
" lon (rlat, rlon) float64 64.22 64.42 64.63 ... 64.55 64.76 64.96\n",
" lat (rlat, rlon) float64 66.64 66.58 66.52 ... 66.81 66.75 66.69\n",
"Dimensions without coordinates: vertices\n",
"Data variables:\n",
" dummy (rlat, rlon) float64 0.284 0.8978 0.4348 ... 0.3468 0.3661\n",
" lon_bounds (vertices, rlat, rlon) float64 64.03 64.24 64.44 ... 64.74 64.95\n",
" lat_bounds (vertices, rlat, rlon) float64 66.63 66.56 66.5 ... 66.83 66.76"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lon_bounds, lat_bounds = lon_lat_bounds(ds, rotated)\n",
"ds = ds.assign(lon_bounds=lon_bounds, lat_bounds=lat_bounds)\n",
"ds"
]
},
{
"cell_type": "markdown",
"id": "cbf72114-8419-40bc-b942-ce37bfd0e122",
"metadata": {},
"source": [
"quick plot for convenience"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f1dea899-0983-43a3-991b-177dbd51b97f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.collections.PathCollection at 0x11923bdf0>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAASgAAADrCAYAAADaDAu3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZ2ElEQVR4nO3df5BV5Z3n8fe3GzpKRIHGwYZuMwblRydRggpaakEMAs4mcZywFXWTbJ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/xT3djMfgGMPRPHOtPKBpSISC1pZGERCZYCSkSCpYASkWApoEQkWAooEQnW/wd4IEEki6z5KwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"from cartopy import crs as ccrs\n",
"from matplotlib import pyplot as plt\n",
"\n",
"rotated = ccrs.RotatedPole(pole_longitude=-162.0, pole_latitude=39.25)\n",
"ax = plt.subplot(projection=rotated)\n",
"\n",
"# plot cell centers\n",
"ds.dummy.plot.pcolormesh(x=\"rlon\", y=\"rlat\", ax=ax)\n",
"# plot cell centers\n",
"# xr.plot.scatter(subset, x='lon', y='lat', transform=ccrs.PlateCarree())\n",
"xr.plot.scatter(ds, x=\"rlon\", y=\"rlat\", transform=rotated)\n",
"# plot cell vertices\n",
"xr.plot.scatter(ds, x=\"lon\", y=\"lat\", transform=ccrs.PlateCarree())\n",
"xr.plot.scatter(\n",
" ds, x=\"lon_bounds\", y=\"lat_bounds\", color=\"b\", transform=ccrs.PlateCarree()\n",
")"
]
},
{
"cell_type": "markdown",
"id": "9c38a8ac-0f69-4c77-843d-91f00ea054e1",
"metadata": {},
"source": [
"Now, let cf_xarray try to determine vertices order (`order=None`), [xesmf relies on this](https://github.com/pangeo-data/xESMF/blob/d48285b5f65bd97820154f0253386ef69f65a36b/xesmf/frontend.py#L84) for conservative regridding..."
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "5f1a4de7-5d11-47c9-a946-9d292ee12ca8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"counterclockwise\n"
]
}
],
"source": [
"lon_vertices = cfxr.bounds_to_vertices(\n",
" ds.lon_bounds, bounds_dim=\"vertices\", order=\"counterclockwise\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a0f53854-7a0b-4a3d-82f1-6c8557880593",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"clockwise\n"
]
}
],
"source": [
"# this should also result in counterclockwise but doesn't...\n",
"lon_vertices_ = cfxr.bounds_to_vertices(\n",
" ds.lon_bounds, bounds_dim=\"vertices\", order=None\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "6d6c09b3-3b8d-4fac-8c46-5f8ad5e65224",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lon_vertices.equals(lon_vertices_)"
]
},
{
"cell_type": "markdown",
"id": "e8e0cfae-28c0-4c4d-b7ea-94a724dd64d1",
"metadata": {},
"source": [
"because our curvilinear coordinate boundaries of neighbouring cells do not match exactly"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "a2cbb751-cc25-4755-8bae-8126d7d59da4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(<xarray.DataArray 'lon_bounds' ()>\n",
" array(64.40397614495)\n",
" Coordinates:\n",
" rlat float64 21.73\n",
" rlon float64 18.05\n",
" lon float64 64.59\n",
" lat float64 66.66,\n",
" <xarray.DataArray 'lon_bounds' ()>\n",
" array(64.40397614494998)\n",
" Coordinates:\n",
" rlat float64 21.73\n",
" rlon float64 17.93\n",
" lon float64 64.38\n",
" lat float64 66.73)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"\n",
"np.set_printoptions(precision=14)\n",
"ds.lon_bounds.isel(rlon=1, rlat=1, vertices=0), ds.lon_bounds.isel(\n",
" rlon=0, rlat=1, vertices=1\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:pygmt]",
"language": "python",
"name": "conda-env-pygmt-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment