Last active
January 9, 2025 23:24
-
-
Save j08lue/193291492504d61ad9f446e8459380ef to your computer and use it in GitHub Desktop.
Reformat OS-Climate Hazard model output from filename-based to multidimensional dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "7019a57c-c539-42b3-a6a4-cc043e3548cc", | |
"metadata": {}, | |
"source": [ | |
"# Transforming OS-C Hazard Zarr output to a multidimensional datacube" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "a8d31efb-aff5-4589-9ff1-8d9b887c8a69", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import re\n", | |
"\n", | |
"import xarray as xr\n", | |
"import numpy as np\n", | |
"import zarr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "bba9512c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"store = zarr.DirectoryStore(\"./os-climate-hazard/indicator\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "d5e37886-517f-45ed-9b06-6be918f42b01", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"INDICATOR_NAME = \"days_tas_above\"\n", | |
"INDICATOR_ATTRS = {\n", | |
" \"long_name\": \"Days per year for which the average near-surface temperature 'tas' is above a threshold\",\n", | |
" \"units\": \"Days per year\"\n", | |
"}\n", | |
"COORD_ATTRS = {\n", | |
" \"temperature\": {\n", | |
" \"long_name\": \"Temperature\",\n", | |
" \"units\": \"Degrees Celsius\"\n", | |
" },\n", | |
" \"gcm\": {\n", | |
" \"long_name\": \"General Circulation Model\"\n", | |
" },\n", | |
" \"scenario\": {\n", | |
" \"long_name\": \"Climate scenario\"\n", | |
" },\n", | |
" \"year\": {\n", | |
" \"long_name\": \"Predicted year\"\n", | |
" }\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "331d0c40-9654-4a98-8a25-39fb799a6d91", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"keys = [key for key in store.listdir(\"chronic_heat/osc/v2\") if key.endswith(\"_xarray\")]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "dbc7d2db-8fda-4d4e-9f29-fb265de436dd", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def parse_path(key):\n", | |
" temperature, gcm, scenario, year = re.match(f\"{INDICATOR_NAME}_([0-9]+)c_([a-zA-Z0-9]+)_([a-zA-Z0-9]+)_(\\d+)_xarray*\", key).groups()\n", | |
" index = dict(temperature=int(temperature), gcm=gcm, scenario=scenario, year=int(year))\n", | |
" return index" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4e263ac7-8b54-4ec2-b66f-15b53839a909", | |
"metadata": {}, | |
"source": [ | |
"## Read all arrays" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "b4cb885d-cb8f-4dc8-82f9-3647d15776fd", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/var/folders/fj/h7p8zmrs5pv538jqx4b0z7c80000gn/T/ipykernel_86170/69989137.py:6: RuntimeWarning: Failed to open Zarr store with consolidated metadata, but successfully read with non-consolidated metadata. This is typically much slower for opening a dataset. To silence this warning, consider:\n", | |
"1. Consolidating metadata in this existing store with zarr.consolidate_metadata().\n", | |
"2. Explicitly setting consolidated=False, to avoid trying to read consolidate metadata, or\n", | |
"3. Explicitly setting consolidated=True, to raise an error in this case instead of falling back to try reading non-consolidated metadata.\n", | |
" ds = xr.open_dataset(store, engine=\"zarr\")\n" | |
] | |
} | |
], | |
"source": [ | |
"arrs = []\n", | |
"indexes = []\n", | |
"\n", | |
"for key in keys:\n", | |
" store = zarr.DirectoryStore(f\"./os-climate-hazard/indicator/chronic_heat/osc/v2/{key}\")\n", | |
" ds = xr.open_dataset(store, engine=\"zarr\")\n", | |
" \n", | |
" da = ds[\"data\"]\n", | |
" arrs.append(da)\n", | |
"\n", | |
" index = parse_path(key)\n", | |
" indexes.append(index)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "76adc26f-5d8a-4842-a69e-47f9adbef2d8", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sample_array = arrs[0]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "57577121-c29f-4c71-9ae0-9074a8194920", | |
"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[data-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-index-preview {\n", | |
" grid-column: 2 / 5;\n", | |
" color: var(--xr-font-color2);\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", | |
".xr-index-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", | |
".xr-index-data-in:checked ~ .xr-index-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-index-name div,\n", | |
".xr-index-data,\n", | |
".xr-attrs {\n", | |
" padding-left: 25px !important;\n", | |
"}\n", | |
"\n", | |
".xr-attrs,\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-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", | |
".xr-no-icon {\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'><xarray.DataArray 'data' (latitude: 18, longitude: 26)>\n", | |
"[468 values with dtype=float64]\n", | |
"Coordinates:\n", | |
" * latitude (latitude) float64 60.86 60.13 59.41 ... 49.97 49.25 48.52\n", | |
" * longitude (longitude) float64 -13.41 -12.68 -11.95 ... 3.286 4.011 4.737\n", | |
" spatial_ref int64 ...\n", | |
"Attributes:\n", | |
" crs: EPSG:4326\n", | |
" dimensions: ['index', 'latitude', 'longitude']\n", | |
" transform_mat3x3: [0.7257341403403003, 0.0, -13.769194597728733, 0.0, -0...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'data'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>latitude</span>: 18</li><li><span class='xr-has-index'>longitude</span>: 26</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-55fdce1e-dbcd-4449-8b3f-f17e0a4ba8ca' class='xr-array-in' type='checkbox' checked><label for='section-55fdce1e-dbcd-4449-8b3f-f17e0a4ba8ca' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>...</span></div><div class='xr-array-data'><pre>[468 values with dtype=float64]</pre></div></div></li><li class='xr-section-item'><input id='section-df6703ab-f1bb-4a4b-a48a-e152613a9b63' class='xr-section-summary-in' type='checkbox' checked><label for='section-df6703ab-f1bb-4a4b-a48a-e152613a9b63' class='xr-section-summary' >Coordinates: <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 class='xr-has-index'>latitude</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>60.86 60.13 59.41 ... 49.25 48.52</div><input id='attrs-5a4ccad7-a4bb-4ab6-95b0-c3766083e20e' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-5a4ccad7-a4bb-4ab6-95b0-c3766083e20e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-6e6ce0e7-38e8-4251-90c9-aed0e6e8932e' class='xr-var-data-in' type='checkbox'><label for='data-6e6ce0e7-38e8-4251-90c9-aed0e6e8932e' 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'><dt><span>axis :</span></dt><dd>Y</dd><dt><span>long_name :</span></dt><dd>latitude</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([60.859008, 60.133274, 59.407539, 58.681805, 57.956071, 57.230337,\n", | |
" 56.504603, 55.778869, 55.053135, 54.327401, 53.601666, 52.875932,\n", | |
" 52.150198, 51.424464, 50.69873 , 49.972996, 49.247262, 48.521527])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>longitude</span></div><div class='xr-var-dims'>(longitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-13.41 -12.68 ... 4.011 4.737</div><input id='attrs-42c9e475-4b74-428e-aa97-6aff578ccdc6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-42c9e475-4b74-428e-aa97-6aff578ccdc6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ef0b3e23-ec91-416b-bdb8-b2c57bcb3d2f' class='xr-var-data-in' type='checkbox'><label for='data-ef0b3e23-ec91-416b-bdb8-b2c57bcb3d2f' 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'><dt><span>axis :</span></dt><dd>X</dd><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([-13.406328, -12.680593, -11.954859, -11.229125, -10.503391, -9.777657,\n", | |
" -9.051923, -8.326189, -7.600454, -6.87472 , -6.148986, -5.423252,\n", | |
" -4.697518, -3.971784, -3.24605 , -2.520315, -1.794581, -1.068847,\n", | |
" -0.343113, 0.382621, 1.108355, 1.834089, 2.559824, 3.285558,\n", | |
" 4.011292, 4.737026])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>spatial_ref</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-a8858c05-3ddc-4aec-a227-5f9a7178e40b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a8858c05-3ddc-4aec-a227-5f9a7178e40b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ae0fad1c-971c-4e54-aec8-c8b6bdb06dc3' class='xr-var-data-in' type='checkbox'><label for='data-ae0fad1c-971c-4e54-aec8-c8b6bdb06dc3' 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'><dt><span>GeoTransform :</span></dt><dd>-13.769194597728733 0.7257341403403003 0.0 61.22187484580277 0.0 -0.7257341403403003</dd><dt><span>crs_wkt :</span></dt><dd>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]</dd><dt><span>geographic_crs_name :</span></dt><dd>WGS 84</dd><dt><span>grid_mapping_name :</span></dt><dd>latitude_longitude</dd><dt><span>horizontal_datum_name :</span></dt><dd>World Geodetic System 1984</dd><dt><span>inverse_flattening :</span></dt><dd>298.257223563</dd><dt><span>longitude_of_prime_meridian :</span></dt><dd>0.0</dd><dt><span>prime_meridian_name :</span></dt><dd>Greenwich</dd><dt><span>reference_ellipsoid_name :</span></dt><dd>WGS 84</dd><dt><span>semi_major_axis :</span></dt><dd>6378137.0</dd><dt><span>semi_minor_axis :</span></dt><dd>6356752.314245179</dd><dt><span>spatial_ref :</span></dt><dd>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]</dd></dl></div><div class='xr-var-data'><pre>[1 values with dtype=int64]</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-3a2649cb-b391-42ec-9d20-a7e31869ff7c' class='xr-section-summary-in' type='checkbox' ><label for='section-3a2649cb-b391-42ec-9d20-a7e31869ff7c' class='xr-section-summary' >Indexes: <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-index-name'><div>latitude</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-1621ac0c-a66c-4ce0-8467-ff9496316dea' class='xr-index-data-in' type='checkbox'/><label for='index-1621ac0c-a66c-4ce0-8467-ff9496316dea' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([ 60.85900777563263, 60.133273635292326, 59.407539494952026,\n", | |
" 58.681805354611726, 57.956071214271425, 57.230337073931125,\n", | |
" 56.504602933590824, 55.778868793250524, 55.053134652910224,\n", | |
" 54.32740051256992, 53.60166637222962, 52.87593223188932,\n", | |
" 52.15019809154902, 51.42446395120872, 50.69872981086842,\n", | |
" 49.97299567052812, 49.24726153018782, 48.52152738984752],\n", | |
" dtype='float64', name='latitude'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>longitude</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-05d6106d-cbb5-4960-a4ec-34f0261e9b3b' class='xr-index-data-in' type='checkbox'/><label for='index-05d6106d-cbb5-4960-a4ec-34f0261e9b3b' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([-13.406327527558583, -12.680593387218282, -11.954859246877982,\n", | |
" -11.229125106537682, -10.503390966197381, -9.77765682585708,\n", | |
" -9.051922685516782, -8.326188545176482, -7.600454404836181,\n", | |
" -6.87472026449588, -6.14898612415558, -5.4232519838152795,\n", | |
" -4.69751784347498, -3.9717837031346797, -3.2460495627943793,\n", | |
" -2.520315422454079, -1.7945812821137785, -1.0688471417734782,\n", | |
" -0.3431130014331778, 0.38262113890712257, 1.108355279247423,\n", | |
" 1.8340894195877233, 2.5598235599280237, 3.2855577002683223,\n", | |
" 4.011291840608623, 4.737025980948923],\n", | |
" dtype='float64', name='longitude'))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-fdb37dbb-148f-4856-85b5-65336b7ac2b7' class='xr-section-summary-in' type='checkbox' checked><label for='section-fdb37dbb-148f-4856-85b5-65336b7ac2b7' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>crs :</span></dt><dd>EPSG:4326</dd><dt><span>dimensions :</span></dt><dd>['index', 'latitude', 'longitude']</dd><dt><span>transform_mat3x3 :</span></dt><dd>[0.7257341403403003, 0.0, -13.769194597728733, 0.0, -0.7257341403403004, 61.22187484580277, 0.0, 0.0, 1.0]</dd></dl></div></li></ul></div></div>" | |
], | |
"text/plain": [ | |
"<xarray.DataArray 'data' (latitude: 18, longitude: 26)>\n", | |
"[468 values with dtype=float64]\n", | |
"Coordinates:\n", | |
" * latitude (latitude) float64 60.86 60.13 59.41 ... 49.97 49.25 48.52\n", | |
" * longitude (longitude) float64 -13.41 -12.68 -11.95 ... 3.286 4.011 4.737\n", | |
" spatial_ref int64 ...\n", | |
"Attributes:\n", | |
" crs: EPSG:4326\n", | |
" dimensions: ['index', 'latitude', 'longitude']\n", | |
" transform_mat3x3: [0.7257341403403003, 0.0, -13.769194597728733, 0.0, -0..." | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"sample_array" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "8a60b8c9-70d6-44bd-b5ed-84d3ad0b4144", | |
"metadata": {}, | |
"source": [ | |
"## Create dimensions" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "1e716b41-56e7-4583-828f-29d8b3551294", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"coords = {key: set() for key in indexes[0]}\n", | |
"for index in indexes:\n", | |
" for key, value in index.items():\n", | |
" coords[key].add(value)\n", | |
"\n", | |
"for key in coords:\n", | |
" coords[key] = sorted(coords[key])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "f3eada04-927e-43f3-b821-93b0f78b8b3d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for key in sample_array.dims:\n", | |
" coords[key] = arrs[0].coords[key].values" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "3162b3f8-6c35-4f8e-834f-00f82dd0692c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'temperature': [20, 25, 28, 30, 32, 35, 40, 45, 50, 55],\n", | |
" 'gcm': ['ukcp18'],\n", | |
" 'scenario': ['rcp85'],\n", | |
" 'year': [2030, 2040, 2050, 2060, 2070, 2080, 2090],\n", | |
" 'latitude': array([60.85900778, 60.13327364, 59.40753949, 58.68180535, 57.95607121,\n", | |
" 57.23033707, 56.50460293, 55.77886879, 55.05313465, 54.32740051,\n", | |
" 53.60166637, 52.87593223, 52.15019809, 51.42446395, 50.69872981,\n", | |
" 49.97299567, 49.24726153, 48.52152739]),\n", | |
" 'longitude': array([-13.40632753, -12.68059339, -11.95485925, -11.22912511,\n", | |
" -10.50339097, -9.77765683, -9.05192269, -8.32618855,\n", | |
" -7.6004544 , -6.87472026, -6.14898612, -5.42325198,\n", | |
" -4.69751784, -3.9717837 , -3.24604956, -2.52031542,\n", | |
" -1.79458128, -1.06884714, -0.343113 , 0.38262114,\n", | |
" 1.10835528, 1.83408942, 2.55982356, 3.2855577 ,\n", | |
" 4.01129184, 4.73702598])}" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"coords" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "cae94675-5a36-4a23-8853-907920a29d32", | |
"metadata": {}, | |
"source": [ | |
"## Create a master array and fill it" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "49cedd07-c8e1-4947-91b6-12f10c3a4353", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"shape = [len(values) for values in coords.values()]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "d6632478-5463-43ef-8125-76ea5fcf99da", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"da = xr.DataArray(np.zeros(shape, dtype=arrs[0].dtype), coords=coords, name=INDICATOR_NAME)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "bfcb2de3-2df3-492a-a6c9-9cd511bdc48a", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for arr, index in zip(arrs, indexes):\n", | |
" da.loc[index] = arr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "b7d15c71-8fa3-4b0d-94b1-9b93e78ce8b0", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for key in sample_array.dims:\n", | |
" da.coords[key].attrs.update(sample_array.coords[key].attrs)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "ec568d37-4dd6-4391-9d70-bf47f56117ee", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"for key, attrs in COORD_ATTRS.items():\n", | |
" da.coords[key].attrs.update(attrs)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "855c411e-3910-4e3d-8e27-f90d613a515f", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"da.attrs.update(INDICATOR_ATTRS)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"id": "1569e775-3a20-4e4e-bf1a-d0574154db06", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ds = da.to_dataset()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "84caa6a0-f13b-4257-9628-5e7dc8f68a84", | |
"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[data-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-index-preview {\n", | |
" grid-column: 2 / 5;\n", | |
" color: var(--xr-font-color2);\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", | |
".xr-index-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", | |
".xr-index-data-in:checked ~ .xr-index-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-index-name div,\n", | |
".xr-index-data,\n", | |
".xr-attrs {\n", | |
" padding-left: 25px !important;\n", | |
"}\n", | |
"\n", | |
".xr-attrs,\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-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", | |
".xr-no-icon {\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'><xarray.Dataset>\n", | |
"Dimensions: (temperature: 10, gcm: 1, scenario: 1, year: 7,\n", | |
" latitude: 18, longitude: 26)\n", | |
"Coordinates:\n", | |
" * temperature (temperature) int64 20 25 28 30 32 35 40 45 50 55\n", | |
" * gcm (gcm) <U6 'ukcp18'\n", | |
" * scenario (scenario) <U5 'rcp85'\n", | |
" * year (year) int64 2030 2040 2050 2060 2070 2080 2090\n", | |
" * latitude (latitude) float64 60.86 60.13 59.41 ... 49.97 49.25 48.52\n", | |
" * longitude (longitude) float64 -13.41 -12.68 -11.95 ... 4.011 4.737\n", | |
"Data variables:\n", | |
" days_tas_above (temperature, gcm, scenario, year, latitude, longitude) float64 ...</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-4bb08e09-526d-4873-83ad-c1429dd78726' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-4bb08e09-526d-4873-83ad-c1429dd78726' 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'>temperature</span>: 10</li><li><span class='xr-has-index'>gcm</span>: 1</li><li><span class='xr-has-index'>scenario</span>: 1</li><li><span class='xr-has-index'>year</span>: 7</li><li><span class='xr-has-index'>latitude</span>: 18</li><li><span class='xr-has-index'>longitude</span>: 26</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-65e3fa19-f8b4-4735-baf0-804fb6d5fe67' class='xr-section-summary-in' type='checkbox' checked><label for='section-65e3fa19-f8b4-4735-baf0-804fb6d5fe67' class='xr-section-summary' >Coordinates: <span>(6)</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'>temperature</span></div><div class='xr-var-dims'>(temperature)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>20 25 28 30 32 35 40 45 50 55</div><input id='attrs-66a18b12-4696-4528-a8ec-753739b41252' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-66a18b12-4696-4528-a8ec-753739b41252' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-48d0bece-8359-4b60-804c-cb68319bf26e' class='xr-var-data-in' type='checkbox'><label for='data-48d0bece-8359-4b60-804c-cb68319bf26e' 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'><dt><span>long_name :</span></dt><dd>Temperature</dd><dt><span>units :</span></dt><dd>Degrees Celsius</dd></dl></div><div class='xr-var-data'><pre>array([20, 25, 28, 30, 32, 35, 40, 45, 50, 55])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>gcm</span></div><div class='xr-var-dims'>(gcm)</div><div class='xr-var-dtype'><U6</div><div class='xr-var-preview xr-preview'>'ukcp18'</div><input id='attrs-5a34c589-2215-472a-b556-91d71b638a3f' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-5a34c589-2215-472a-b556-91d71b638a3f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-5d2185d8-ac4b-4e9e-9cf5-7fa25a06819f' class='xr-var-data-in' type='checkbox'><label for='data-5d2185d8-ac4b-4e9e-9cf5-7fa25a06819f' 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'><dt><span>long_name :</span></dt><dd>General Climate Model</dd></dl></div><div class='xr-var-data'><pre>array(['ukcp18'], dtype='<U6')</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>scenario</span></div><div class='xr-var-dims'>(scenario)</div><div class='xr-var-dtype'><U5</div><div class='xr-var-preview xr-preview'>'rcp85'</div><input id='attrs-7a7b9bb1-1e4f-4b66-bd62-16d50b10ba54' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7a7b9bb1-1e4f-4b66-bd62-16d50b10ba54' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-5fffbfea-d09a-48a1-a7a3-2493429a2ac6' class='xr-var-data-in' type='checkbox'><label for='data-5fffbfea-d09a-48a1-a7a3-2493429a2ac6' 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'><dt><span>long_name :</span></dt><dd>Climate scenario</dd></dl></div><div class='xr-var-data'><pre>array(['rcp85'], dtype='<U5')</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>year</span></div><div class='xr-var-dims'>(year)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>2030 2040 2050 2060 2070 2080 2090</div><input id='attrs-55d89f71-f1dc-45a5-95dd-9fbf434721d0' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-55d89f71-f1dc-45a5-95dd-9fbf434721d0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f7ea5ade-c1a1-41aa-84de-5e16cca91f60' class='xr-var-data-in' type='checkbox'><label for='data-f7ea5ade-c1a1-41aa-84de-5e16cca91f60' 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'><dt><span>long_name :</span></dt><dd>Predicted year</dd></dl></div><div class='xr-var-data'><pre>array([2030, 2040, 2050, 2060, 2070, 2080, 2090])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>latitude</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>60.86 60.13 59.41 ... 49.25 48.52</div><input id='attrs-fc439bd1-1146-4c2c-b0b6-3df5d968aef1' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-fc439bd1-1146-4c2c-b0b6-3df5d968aef1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-74d057d4-3783-4f88-b3ae-ece281ac22b7' class='xr-var-data-in' type='checkbox'><label for='data-74d057d4-3783-4f88-b3ae-ece281ac22b7' 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'><dt><span>axis :</span></dt><dd>Y</dd><dt><span>long_name :</span></dt><dd>latitude</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([60.859008, 60.133274, 59.407539, 58.681805, 57.956071, 57.230337,\n", | |
" 56.504603, 55.778869, 55.053135, 54.327401, 53.601666, 52.875932,\n", | |
" 52.150198, 51.424464, 50.69873 , 49.972996, 49.247262, 48.521527])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>longitude</span></div><div class='xr-var-dims'>(longitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-13.41 -12.68 ... 4.011 4.737</div><input id='attrs-1ba6115f-9df0-49d3-8598-e0ae19e514ff' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-1ba6115f-9df0-49d3-8598-e0ae19e514ff' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7fffa591-7f3c-4212-9a3b-5a3755aed6eb' class='xr-var-data-in' type='checkbox'><label for='data-7fffa591-7f3c-4212-9a3b-5a3755aed6eb' 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'><dt><span>axis :</span></dt><dd>X</dd><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([-13.406328, -12.680593, -11.954859, -11.229125, -10.503391, -9.777657,\n", | |
" -9.051923, -8.326189, -7.600454, -6.87472 , -6.148986, -5.423252,\n", | |
" -4.697518, -3.971784, -3.24605 , -2.520315, -1.794581, -1.068847,\n", | |
" -0.343113, 0.382621, 1.108355, 1.834089, 2.559824, 3.285558,\n", | |
" 4.011292, 4.737026])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-6c6ab2b7-331d-483d-b90d-8007e5112daa' class='xr-section-summary-in' type='checkbox' checked><label for='section-6c6ab2b7-331d-483d-b90d-8007e5112daa' 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>days_tas_above</span></div><div class='xr-var-dims'>(temperature, gcm, scenario, year, latitude, longitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0</div><input id='attrs-676e0a6d-0543-4c7e-a133-de84d3d2dbbd' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-676e0a6d-0543-4c7e-a133-de84d3d2dbbd' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b1494650-6f47-4432-961c-d6024cb41db6' class='xr-var-data-in' type='checkbox'><label for='data-b1494650-6f47-4432-961c-d6024cb41db6' 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'><dt><span>long_name :</span></dt><dd>Days per year for which the average near-surface temperature 'tas' is above a threshold</dd><dt><span>units :</span></dt><dd>Days per year</dd></dl></div><div class='xr-var-data'><pre>array([[[[[[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" ...,\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 4.46111111e+01, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]],\n", | |
"\n", | |
" [[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
"...\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]],\n", | |
"\n", | |
" [[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" ...,\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n", | |
" [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n", | |
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]]]]]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-c26e6cbb-5cf1-4974-a5e0-88ddbb5163ef' class='xr-section-summary-in' type='checkbox' ><label for='section-c26e6cbb-5cf1-4974-a5e0-88ddbb5163ef' class='xr-section-summary' >Indexes: <span>(6)</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-index-name'><div>temperature</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-7cb9e972-c782-45a9-8411-df651e30c94c' class='xr-index-data-in' type='checkbox'/><label for='index-7cb9e972-c782-45a9-8411-df651e30c94c' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([20, 25, 28, 30, 32, 35, 40, 45, 50, 55], dtype='int64', name='temperature'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>gcm</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-f6951871-aa17-4726-970a-38c059824a3e' class='xr-index-data-in' type='checkbox'/><label for='index-f6951871-aa17-4726-970a-38c059824a3e' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index(['ukcp18'], dtype='object', name='gcm'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>scenario</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-06b0e879-a42e-49d1-9149-26d6a2e58c0a' class='xr-index-data-in' type='checkbox'/><label for='index-06b0e879-a42e-49d1-9149-26d6a2e58c0a' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index(['rcp85'], dtype='object', name='scenario'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>year</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-0b707a3a-43f3-4f23-b761-f4bec5934af9' class='xr-index-data-in' type='checkbox'/><label for='index-0b707a3a-43f3-4f23-b761-f4bec5934af9' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([2030, 2040, 2050, 2060, 2070, 2080, 2090], dtype='int64', name='year'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>latitude</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-6c5bde1a-271a-4d02-a236-d20f3963ad4d' class='xr-index-data-in' type='checkbox'/><label for='index-6c5bde1a-271a-4d02-a236-d20f3963ad4d' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([ 60.85900777563263, 60.133273635292326, 59.407539494952026,\n", | |
" 58.681805354611726, 57.956071214271425, 57.230337073931125,\n", | |
" 56.504602933590824, 55.778868793250524, 55.053134652910224,\n", | |
" 54.32740051256992, 53.60166637222962, 52.87593223188932,\n", | |
" 52.15019809154902, 51.42446395120872, 50.69872981086842,\n", | |
" 49.97299567052812, 49.24726153018782, 48.52152738984752],\n", | |
" dtype='float64', name='latitude'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>longitude</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-02356738-6dbc-4f29-aa23-00dc4ff56943' class='xr-index-data-in' type='checkbox'/><label for='index-02356738-6dbc-4f29-aa23-00dc4ff56943' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([-13.406327527558583, -12.680593387218282, -11.954859246877982,\n", | |
" -11.229125106537682, -10.503390966197381, -9.77765682585708,\n", | |
" -9.051922685516782, -8.326188545176482, -7.600454404836181,\n", | |
" -6.87472026449588, -6.14898612415558, -5.4232519838152795,\n", | |
" -4.69751784347498, -3.9717837031346797, -3.2460495627943793,\n", | |
" -2.520315422454079, -1.7945812821137785, -1.0688471417734782,\n", | |
" -0.3431130014331778, 0.38262113890712257, 1.108355279247423,\n", | |
" 1.8340894195877233, 2.5598235599280237, 3.2855577002683223,\n", | |
" 4.011291840608623, 4.737025980948923],\n", | |
" dtype='float64', name='longitude'))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-d0b9fbb9-bd12-443d-a35a-278a26bfd148' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-d0b9fbb9-bd12-443d-a35a-278a26bfd148' 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: (temperature: 10, gcm: 1, scenario: 1, year: 7,\n", | |
" latitude: 18, longitude: 26)\n", | |
"Coordinates:\n", | |
" * temperature (temperature) int64 20 25 28 30 32 35 40 45 50 55\n", | |
" * gcm (gcm) <U6 'ukcp18'\n", | |
" * scenario (scenario) <U5 'rcp85'\n", | |
" * year (year) int64 2030 2040 2050 2060 2070 2080 2090\n", | |
" * latitude (latitude) float64 60.86 60.13 59.41 ... 49.97 49.25 48.52\n", | |
" * longitude (longitude) float64 -13.41 -12.68 -11.95 ... 4.011 4.737\n", | |
"Data variables:\n", | |
" days_tas_above (temperature, gcm, scenario, year, latitude, longitude) float64 ..." | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ds" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "86297b43-a5b8-465b-8480-8f3d5ff6131f", | |
"metadata": {}, | |
"source": [ | |
"## Write to Zarr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "c83be201-e7d5-409e-aa4a-c07c367d36b9", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#ds = ds.chunk(dict(temperature=1, gcm=1, scenario=1))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "cf686e4b-9643-495b-8f24-2ca351734541", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.backends.zarr.ZarrStore at 0x134b272e0>" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ds.to_zarr(f\"./{INDICATOR_NAME}.zarr\", mode=\"w\", consolidated=True)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"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.9.12" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment