Created
March 3, 2020 04:03
-
-
Save aaronspring/4c0b9b107fd53f93db44a2d916084018 to your computer and use it in GitHub Desktop.
This file contains 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", | |
"metadata": {}, | |
"source": [ | |
"## Applying unvectorized functions with `apply_ufunc`" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This example will illustrate how to conveniently apply an unvectorized function `func` to xarray objects using `apply_ufunc`.\n", | |
"\n", | |
"Resources:\n", | |
"- https://numba.pydata.org/numba-doc/dev/user/examples.html\n", | |
"- http://xarray.pydata.org/en/stable/examples/apply_ufunc_vectorize_1d.html\n", | |
"\n", | |
"We will illustrate this using `mse`: " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:51.659160Z", | |
"start_time": "2020-01-15T14:45:50.528742Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.core.options.set_options at 0x2b05e03333c8>" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import xarray as xr\n", | |
"import numpy as np\n", | |
"import dask\n", | |
"import xskillscore as xs\n", | |
"from xskillscore import mse as xs_mse\n", | |
"xr.set_options(display_style=\"html\") # fancy HTML repr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:51.659160Z", | |
"start_time": "2020-01-15T14:45:50.528742Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"def xs_mse(a,b,dim):\n", | |
" return xs_mse(a,b,dim)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def np_mse(a,b):\n", | |
" return np.mean((a-b)**2,axis=0)\n", | |
"\n", | |
"def np_mse_axis(a,b,axis=0):\n", | |
" return np.mean((a-b)**2,axis=axis)\n", | |
"\n", | |
"def mse(a,b,dim):\n", | |
" return ((a-b)**2).mean(dim)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#client.close()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Number of CPUs: 48, number of threads: 6, number of workers: 8\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table style=\"border: 2px solid white;\">\n", | |
"<tr>\n", | |
"<td style=\"vertical-align: top; border: 0px solid white\">\n", | |
"<h3 style=\"text-align: left;\">Client</h3>\n", | |
"<ul style=\"text-align: left; list-style: none; margin: 0; padding: 0;\">\n", | |
" <li><b>Scheduler: </b>inproc://10.50.39.242/45562/1</li>\n", | |
" <li><b>Dashboard: </b><a href='http://localhost:8888/proxy/8787/status' target='_blank'>http://localhost:8888/proxy/8787/status</a>\n", | |
"</ul>\n", | |
"</td>\n", | |
"<td style=\"vertical-align: top; border: 0px solid white\">\n", | |
"<h3 style=\"text-align: left;\">Cluster</h3>\n", | |
"<ul style=\"text-align: left; list-style:none; margin: 0; padding: 0;\">\n", | |
" <li><b>Workers: </b>8</li>\n", | |
" <li><b>Cores: </b>48</li>\n", | |
" <li><b>Memory: </b>515.40 GB</li>\n", | |
"</ul>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<Client: 'inproc://10.50.39.242/45562/1' processes=8 threads=48, memory=515.40 GB>" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from dask.distributed import Client\n", | |
"import multiprocessing\n", | |
"ncpu = multiprocessing.cpu_count()\n", | |
"threads = 6\n", | |
"nworker = ncpu//threads\n", | |
"print(f'Number of CPUs: {ncpu}, number of threads: {threads}, number of workers: {nworker}')\n", | |
"client = Client(\n", | |
" processes=False, threads_per_worker=threads, n_workers=nworker, memory_limit=\"128GB\"\n", | |
")\n", | |
"client" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:51.659160Z", | |
"start_time": "2020-01-15T14:45:50.528742Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"da = xr.tutorial.load_dataset(\"rasm\").Tair\n", | |
"da = da.isel(time=list(np.arange(da.time.size))*50)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#da = xr.DataArray(dask.array.random.random(\n", | |
"# (10,35,60,360//5,180//5)),\n", | |
"# dims=('time','member','init','lon','lat'))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:51.659160Z", | |
"start_time": "2020-01-15T14:45:50.528742Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"dim='time'\n", | |
"s = da[dim].size\n", | |
"a = da.isel({dim:list(np.arange(s))})#.persist()\n", | |
"b = da.isel({dim:list(np.arange(s)*-1+s-1)})#.persist()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Load data\n", | |
"\n", | |
"First lets load an example dataset" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:55.431708Z", | |
"start_time": "2020-01-15T14:45:55.104701Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"chunk_dim='x'\n", | |
"cs=a[chunk_dim].size//nworker+1\n", | |
"a[dim]=b[dim]\n", | |
"\n", | |
"a = a.chunk({chunk_dim:cs})\n", | |
"b = b.chunk({chunk_dim:cs})\n", | |
"#a=a.persist()\n", | |
"#b=b.persist()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"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", | |
"<title>Show/Hide data repr</title>\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", | |
"<title>Show/Hide attributes</title>\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", | |
".xr-wrap {\n", | |
" min-width: 300px;\n", | |
" max-width: 700px;\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, 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><div class='xr-wrap'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'Tair'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>time</span>: 1800</li><li><span>y</span>: 205</li><li><span>x</span>: 275</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-8662f3c2-d6cc-4b6a-b214-d588b49610a9' class='xr-array-in' type='checkbox' ><label for='section-8662f3c2-d6cc-4b6a-b214-d588b49610a9' 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>dask.array<chunksize=(1800, 205, 35), meta=np.ndarray></span></div><pre class='xr-array-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 811.80 MB </td> <td> 103.32 MB </td></tr>\n", | |
" <tr><th> Shape </th><td> (1800, 205, 275) </td> <td> (1800, 205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"171\" height=\"159\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"80\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"10\" y1=\"39\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"39\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"10.000000,0.000000 80.588235,70.588235 80.588235,109.892802 10.000000,39.304566\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"50\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"80\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"85\" y2=\"70\" />\n", | |
" <line x1=\"20\" y1=\"0\" x2=\"90\" y2=\"70\" />\n", | |
" <line x1=\"25\" y1=\"0\" x2=\"96\" y2=\"70\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"101\" y2=\"70\" />\n", | |
" <line x1=\"35\" y1=\"0\" x2=\"106\" y2=\"70\" />\n", | |
" <line x1=\"41\" y1=\"0\" x2=\"111\" y2=\"70\" />\n", | |
" <line x1=\"46\" y1=\"0\" x2=\"116\" y2=\"70\" />\n", | |
" <line x1=\"50\" y1=\"0\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"10.000000,0.000000 50.794624,0.000000 121.382860,70.588235 80.588235,70.588235\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"109\" x2=\"121\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"85\" y1=\"70\" x2=\"85\" y2=\"109\" />\n", | |
" <line x1=\"90\" y1=\"70\" x2=\"90\" y2=\"109\" />\n", | |
" <line x1=\"96\" y1=\"70\" x2=\"96\" y2=\"109\" />\n", | |
" <line x1=\"101\" y1=\"70\" x2=\"101\" y2=\"109\" />\n", | |
" <line x1=\"106\" y1=\"70\" x2=\"106\" y2=\"109\" />\n", | |
" <line x1=\"111\" y1=\"70\" x2=\"111\" y2=\"109\" />\n", | |
" <line x1=\"116\" y1=\"70\" x2=\"116\" y2=\"109\" />\n", | |
" <line x1=\"121\" y1=\"70\" x2=\"121\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"80.588235,70.588235 121.382860,70.588235 121.382860,109.892802 80.588235,109.892802\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"100.985547\" y=\"129.892802\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"141.382860\" y=\"90.240518\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,141.382860,90.240518)\">205</text>\n", | |
" <text x=\"35.294118\" y=\"94.598684\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,35.294118,94.598684)\">1800</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></div></li><li class='xr-section-item'><input id='section-3a4ddf92-36f3-431c-8934-7bc1334d4298' class='xr-section-summary-in' type='checkbox' checked><label for='section-3a4ddf92-36f3-431c-8934-7bc1334d4298' 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'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>1983-08-17 00:00:00 ... 1980-09-16 12:00:00</div><input id='attrs-aa182c5e-29c8-44eb-b158-773020220610' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-aa182c5e-29c8-44eb-b158-773020220610' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-555a3a9e-cc57-4f2e-a8e8-9d8668033217' class='xr-var-data-in' type='checkbox'><label for='data-555a3a9e-cc57-4f2e-a8e8-9d8668033217' 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>time</dd><dt><span>type_preferred :</span></dt><dd>int</dd></dl></div><pre class='xr-var-data'>array([cftime.DatetimeNoLeap(1983, 8, 17, 0, 0, 0, 0, 6, 229),\n", | |
" cftime.DatetimeNoLeap(1983, 7, 17, 0, 0, 0, 0, 3, 198),\n", | |
" cftime.DatetimeNoLeap(1983, 6, 16, 12, 0, 0, 0, 0, 167), ...,\n", | |
" cftime.DatetimeNoLeap(1980, 11, 16, 12, 0, 0, 0, 3, 320),\n", | |
" cftime.DatetimeNoLeap(1980, 10, 17, 0, 0, 0, 0, 1, 290),\n", | |
" cftime.DatetimeNoLeap(1980, 9, 16, 12, 0, 0, 0, 5, 259)], dtype=object)</pre></li><li class='xr-var-item'><div class='xr-var-name'><span>xc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-63c0a3ad-efd8-4c38-ae19-75f296dae055' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-63c0a3ad-efd8-4c38-ae19-75f296dae055' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-71d672cb-ef2a-4577-a746-072ebb7a080b' class='xr-var-data-in' type='checkbox'><label for='data-71d672cb-ef2a-4577-a746-072ebb7a080b' 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>longitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>bounds :</span></dt><dd>xv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li><li class='xr-var-item'><div class='xr-var-name'><span>yc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-7e498a28-3288-4d83-89e0-ee9a01e60996' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7e498a28-3288-4d83-89e0-ee9a01e60996' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-565f55a7-2144-4202-a61d-6835322863c5' class='xr-var-data-in' type='checkbox'><label for='data-565f55a7-2144-4202-a61d-6835322863c5' 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>latitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>bounds :</span></dt><dd>yv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li></ul></div></li><li class='xr-section-item'><input id='section-0d2d8495-0710-4474-bab1-776459009b32' class='xr-section-summary-in' type='checkbox' checked><label for='section-0d2d8495-0710-4474-bab1-776459009b32' class='xr-section-summary' >Attributes: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>C</dd><dt><span>long_name :</span></dt><dd>Surface air temperature</dd><dt><span>type_preferred :</span></dt><dd>double</dd><dt><span>time_rep :</span></dt><dd>instantaneous</dd></dl></div></li></ul></div></div>" | |
], | |
"text/plain": [ | |
"<xarray.DataArray 'Tair' (time: 1800, y: 205, x: 275)>\n", | |
"dask.array<xarray-<this-array>, shape=(1800, 205, 275), dtype=float64, chunksize=(1800, 205, 35), chunktype=numpy.ndarray>\n", | |
"Coordinates:\n", | |
" * time (time) object 1983-08-17 00:00:00 ... 1980-09-16 12:00:00\n", | |
" xc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
" yc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
"Dimensions without coordinates: y, x\n", | |
"Attributes:\n", | |
" units: C\n", | |
" long_name: Surface air temperature\n", | |
" type_preferred: double\n", | |
" time_rep: instantaneous" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 811.80 MB </td> <td> 103.32 MB </td></tr>\n", | |
" <tr><th> Shape </th><td> (1800, 205, 275) </td> <td> (1800, 205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"171\" height=\"159\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"80\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"10\" y1=\"39\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"39\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"10.000000,0.000000 80.588235,70.588235 80.588235,109.892802 10.000000,39.304566\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"50\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"10\" y1=\"0\" x2=\"80\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"85\" y2=\"70\" />\n", | |
" <line x1=\"20\" y1=\"0\" x2=\"90\" y2=\"70\" />\n", | |
" <line x1=\"25\" y1=\"0\" x2=\"96\" y2=\"70\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"101\" y2=\"70\" />\n", | |
" <line x1=\"35\" y1=\"0\" x2=\"106\" y2=\"70\" />\n", | |
" <line x1=\"41\" y1=\"0\" x2=\"111\" y2=\"70\" />\n", | |
" <line x1=\"46\" y1=\"0\" x2=\"116\" y2=\"70\" />\n", | |
" <line x1=\"50\" y1=\"0\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"10.000000,0.000000 50.794624,0.000000 121.382860,70.588235 80.588235,70.588235\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"121\" y2=\"70\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"80\" y1=\"109\" x2=\"121\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"80\" y1=\"70\" x2=\"80\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"85\" y1=\"70\" x2=\"85\" y2=\"109\" />\n", | |
" <line x1=\"90\" y1=\"70\" x2=\"90\" y2=\"109\" />\n", | |
" <line x1=\"96\" y1=\"70\" x2=\"96\" y2=\"109\" />\n", | |
" <line x1=\"101\" y1=\"70\" x2=\"101\" y2=\"109\" />\n", | |
" <line x1=\"106\" y1=\"70\" x2=\"106\" y2=\"109\" />\n", | |
" <line x1=\"111\" y1=\"70\" x2=\"111\" y2=\"109\" />\n", | |
" <line x1=\"116\" y1=\"70\" x2=\"116\" y2=\"109\" />\n", | |
" <line x1=\"121\" y1=\"70\" x2=\"121\" y2=\"109\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"80.588235,70.588235 121.382860,70.588235 121.382860,109.892802 80.588235,109.892802\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"100.985547\" y=\"129.892802\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"141.382860\" y=\"90.240518\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,141.382860,90.240518)\">205</text>\n", | |
" <text x=\"35.294118\" y=\"94.598684\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,35.294118,94.598684)\">1800</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"dask.array<xarray-<this-array>, shape=(1800, 205, 275), dtype=float64, chunksize=(1800, 205, 35), chunktype=numpy.ndarray>" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"a.data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import dask\n", | |
"assert dask.is_dask_collection(a)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"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", | |
"<title>Show/Hide data repr</title>\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", | |
"<title>Show/Hide attributes</title>\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", | |
".xr-wrap {\n", | |
" min-width: 300px;\n", | |
" max-width: 700px;\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, 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><div class='xr-wrap'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'Tair'</div><ul class='xr-dim-list'><li><span>y</span>: 205</li><li><span>x</span>: 275</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-86ec09f9-0024-48c6-81e3-b5eb9d66a247' class='xr-array-in' type='checkbox' ><label for='section-86ec09f9-0024-48c6-81e3-b5eb9d66a247' 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>dask.array<chunksize=(205, 35), meta=np.ndarray></span></div><pre class='xr-array-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 50 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></div></li><li class='xr-section-item'><input id='section-42f52967-434a-4d60-b8c6-90d3d50cf972' class='xr-section-summary-in' type='checkbox' checked><label for='section-42f52967-434a-4d60-b8c6-90d3d50cf972' 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>xc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-c460d0d2-643f-4e05-9b07-d6ddf904ddc0' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-c460d0d2-643f-4e05-9b07-d6ddf904ddc0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8b8dc992-dfc5-4bec-b1e2-951d2770886a' class='xr-var-data-in' type='checkbox'><label for='data-8b8dc992-dfc5-4bec-b1e2-951d2770886a' 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>longitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>bounds :</span></dt><dd>xv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li><li class='xr-var-item'><div class='xr-var-name'><span>yc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-41f7c6cd-dc26-4ecd-9e70-313b12fe79e6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-41f7c6cd-dc26-4ecd-9e70-313b12fe79e6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-862fb257-ea9b-4a9b-9d11-34cf184ec969' class='xr-var-data-in' type='checkbox'><label for='data-862fb257-ea9b-4a9b-9d11-34cf184ec969' 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>latitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>bounds :</span></dt><dd>yv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li></ul></div></li><li class='xr-section-item'><input id='section-ee8958e9-e735-48a7-b091-45ce83bb9206' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-ee8958e9-e735-48a7-b091-45ce83bb9206' 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.DataArray 'Tair' (y: 205, x: 275)>\n", | |
"dask.array<mean_agg-aggregate, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>\n", | |
"Coordinates:\n", | |
" xc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
" yc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
"Dimensions without coordinates: y, x" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"mse(a,b,dim)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Let's define a function that works with one vector of data along `lat` at a time." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:57.889496Z", | |
"start_time": "2020-01-15T14:45:57.792269Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"actual = np_mse_axis(a,b,axis=0)\n", | |
"expected = mse(a,b,'time')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:57.889496Z", | |
"start_time": "2020-01-15T14:45:57.792269Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n" | |
] | |
} | |
], | |
"source": [ | |
"# no errors are raised if values are equal to within floating point precision\n", | |
"np.testing.assert_allclose(expected, actual)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### No errors are raised so our interpolation is working.\n", | |
"\n", | |
"This function consumes and returns numpy arrays, which means we need to do a lot of work to convert the result back to an xarray object with meaningful metadata. This is where `apply_ufunc` is very useful.\n", | |
"\n", | |
"### `apply_ufunc`\n", | |
"\n", | |
" Apply a vectorized function for unlabeled arrays on xarray objects.\n", | |
"\n", | |
" The function will be mapped over the data variable(s) of the input arguments using \n", | |
" xarray’s standard rules for labeled computation, including alignment, broadcasting, \n", | |
" looping over GroupBy/Dataset variables, and merging of coordinates.\n", | |
" \n", | |
"`apply_ufunc` has many capabilities but for simplicity this example will focus on the common task of vectorizing 1D functions over nD xarray objects. We will iteratively build up the right set of arguments to `apply_ufunc` and read through many error messages in doing so." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:45:59.768626Z", | |
"start_time": "2020-01-15T14:45:59.543808Z" | |
} | |
}, | |
"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", | |
"<title>Show/Hide data repr</title>\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", | |
"<title>Show/Hide attributes</title>\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", | |
".xr-wrap {\n", | |
" min-width: 300px;\n", | |
" max-width: 700px;\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, 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><div class='xr-wrap'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'Tair'</div><ul class='xr-dim-list'><li><span>y</span>: 205</li><li><span>x</span>: 275</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-a91b36a6-6a57-4ef6-899c-31ee8e2693d8' class='xr-array-in' type='checkbox' ><label for='section-a91b36a6-6a57-4ef6-899c-31ee8e2693d8' 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>dask.array<chunksize=(205, 35), meta=np.ndarray></span></div><pre class='xr-array-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 42 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></div></li><li class='xr-section-item'><input id='section-00d060e9-b77d-47a5-9911-20fd6a489ce9' class='xr-section-summary-in' type='checkbox' checked><label for='section-00d060e9-b77d-47a5-9911-20fd6a489ce9' 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>xc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-d187fff1-0a63-449b-b539-7516b206f1ff' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-d187fff1-0a63-449b-b539-7516b206f1ff' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-cbd0a9c5-93d3-4ddd-8449-96fe49e234ec' class='xr-var-data-in' type='checkbox'><label for='data-cbd0a9c5-93d3-4ddd-8449-96fe49e234ec' 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>longitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>bounds :</span></dt><dd>xv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li><li class='xr-var-item'><div class='xr-var-name'><span>yc</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array<chunksize=(205, 35), meta=np.ndarray></div><input id='attrs-b556bc99-c9e5-4755-a753-6aac3c393b61' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-b556bc99-c9e5-4755-a753-6aac3c393b61' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-35f971a8-70b7-4696-ba82-24a2e96f3c77' class='xr-var-data-in' type='checkbox'><label for='data-35f971a8-70b7-4696-ba82-24a2e96f3c77' 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>latitude of grid cell center</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>bounds :</span></dt><dd>yv</dd></dl></div><pre class='xr-var-data'><table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 9 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table></pre></li></ul></div></li><li class='xr-section-item'><input id='section-5bdfada9-4fcf-4333-903e-fbc48ade50c0' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-5bdfada9-4fcf-4333-903e-fbc48ade50c0' 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.DataArray 'Tair' (y: 205, x: 275)>\n", | |
"dask.array<np_mse_axis, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>\n", | |
"Coordinates:\n", | |
" xc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
" yc (y, x) float64 dask.array<chunksize=(205, 35), meta=np.ndarray>\n", | |
"Dimensions without coordinates: y, x" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"def xr_mse_ufunc(a,b,dim, **kwargs):\n", | |
" return xr.apply_ufunc(\n", | |
" np_mse_axis,#interp1d_np, # first the function\n", | |
" a,\n", | |
" b,\n", | |
" input_core_dims=[[dim], [dim]],\n", | |
" kwargs={\"axis\": -1},\n", | |
" dask=\"parallelized\",\n", | |
" output_dtypes=[a.dtype],\n", | |
" **kwargs\n", | |
" )\n", | |
"xr_mse_ufunc(a,b,dim)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### High performance vectorization: gufuncs, numba & guvectorize\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 39, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:49:28.667528Z", | |
"start_time": "2020-01-15T14:49:28.103914Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"from numba import float64, guvectorize\n", | |
"\n", | |
"\n", | |
"@guvectorize(\n", | |
" \"(float64[:], float64[:], float64[:])\",\n", | |
" \"(n), (n) -> ()\",\n", | |
" nopython=True\n", | |
")\n", | |
"def np_mse_gufunc(a, b, out):\n", | |
" out[:] = np.mean((a-b)**2)\n", | |
"\n", | |
"def xr_mse_gufunc(a,b,dim):\n", | |
" return xr.apply_ufunc(\n", | |
" np_mse_gufunc, # first the function\n", | |
" a, # now arguments in the order expected\n", | |
" b,\n", | |
" input_core_dims=[[dim], [dim]], # list with one entry per arg\n", | |
" exclude_dims=set((dim,)), # dimensions allowed to change size. Must be a set!\n", | |
" # vectorize=True, # not needed since numba takes care of vectorizing\n", | |
" dask=\"parallelized\",\n", | |
" output_dtypes=[a.dtype], # one per output; could also be float or np.dtype(\"float64\")\n", | |
" )" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"assert dim not in xr_mse_gufunc(a,b,dim).dims" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 41, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2020-01-15T14:49:28.667528Z", | |
"start_time": "2020-01-15T14:49:28.103914Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n" | |
] | |
} | |
], | |
"source": [ | |
"xr.testing.assert_allclose(xr_mse_gufunc(a,b,dim),mse(a,b,dim))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"mse\n", | |
"Building the task graph ...\n", | |
"CPU times: user 5 ms, sys: 1e+03 µs, total: 6 ms\n", | |
"Wall time: 5.8 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 50 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"dask.array<mean_agg-aggregate, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Compute ...\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"CPU times: user 2.01 s, sys: 1.58 s, total: 3.59 s\n", | |
"Wall time: 674 ms\n", | |
"Time elapsed 0.6864221096038818s \n", | |
"\n", | |
"xr_mse_ufunc\n", | |
"Building the task graph ...\n", | |
"CPU times: user 4 ms, sys: 0 ns, total: 4 ms\n", | |
"Wall time: 4.08 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 42 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"dask.array<np_mse_axis, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Compute ...\n", | |
"CPU times: user 4.2 s, sys: 1.38 s, total: 5.58 s\n", | |
"Wall time: 904 ms\n", | |
"Time elapsed 0.9222097396850586s \n", | |
"\n", | |
"xr_mse_gufunc\n", | |
"Building the task graph ...\n", | |
"CPU times: user 11 ms, sys: 999 µs, total: 12 ms\n", | |
"Wall time: 12 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 42 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"dask.array<np_mse_gufunc, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Compute ...\n", | |
"CPU times: user 4.12 s, sys: 907 ms, total: 5.02 s\n", | |
"Wall time: 783 ms\n", | |
"Time elapsed 0.8119418621063232s \n", | |
"\n", | |
"mse\n", | |
"Building the task graph ...\n", | |
"CPU times: user 11 ms, sys: 2 ms, total: 13 ms\n", | |
"Wall time: 11.9 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
"<tr>\n", | |
"<td>\n", | |
"<table>\n", | |
" <thead>\n", | |
" <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr><th> Bytes </th><td> 451.00 kB </td> <td> 57.40 kB </td></tr>\n", | |
" <tr><th> Shape </th><td> (205, 275) </td> <td> (205, 35) </td></tr>\n", | |
" <tr><th> Count </th><td> 43 Tasks </td><td> 8 Chunks </td></tr>\n", | |
" <tr><th> Type </th><td> float64 </td><td> numpy.ndarray </td></tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</td>\n", | |
"<td>\n", | |
"<svg width=\"170\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n", | |
"\n", | |
" <!-- Horizontal lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"0\" y1=\"89\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Vertical lines -->\n", | |
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"89\" />\n", | |
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"89\" />\n", | |
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"89\" />\n", | |
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"89\" />\n", | |
" <line x1=\"76\" y1=\"0\" x2=\"76\" y2=\"89\" />\n", | |
" <line x1=\"91\" y1=\"0\" x2=\"91\" y2=\"89\" />\n", | |
" <line x1=\"106\" y1=\"0\" x2=\"106\" y2=\"89\" />\n", | |
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"89\" style=\"stroke-width:2\" />\n", | |
"\n", | |
" <!-- Colored Rectangle -->\n", | |
" <polygon points=\"0.000000,0.000000 120.000000,0.000000 120.000000,89.454545 0.000000,89.454545\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n", | |
"\n", | |
" <!-- Text -->\n", | |
" <text x=\"60.000000\" y=\"109.454545\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >275</text>\n", | |
" <text x=\"140.000000\" y=\"44.727273\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,44.727273)\">205</text>\n", | |
"</svg>\n", | |
"</td>\n", | |
"</tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"dask.array<mse, shape=(205, 275), dtype=float64, chunksize=(205, 35), chunktype=numpy.ndarray>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Compute ...\n", | |
"CPU times: user 4.17 s, sys: 1.4 s, total: 5.57 s\n", | |
"Wall time: 888 ms\n", | |
"Time elapsed 0.907597541809082s \n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"from time import time\n", | |
"names=[]\n", | |
"times=[]\n", | |
"for func in [mse, xr_mse_ufunc, xr_mse_gufunc, xs.mse]:\n", | |
" name=func.__name__\n", | |
" print(name)\n", | |
" s=time()\n", | |
" print('Building the task graph ...')\n", | |
" %time res = func(a,b,dim)\n", | |
" display(res.data)\n", | |
" print('Compute ...')\n", | |
" %time res = res.compute()\n", | |
" e=time()\n", | |
" elapsed=e-s\n", | |
" print(f'Time elapsed {elapsed}s \\n')\n", | |
" names.append(name)\n", | |
" times.append(elapsed)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "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\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"plt.bar(np.arange(len(names)),times)\n", | |
"plt.xticks(np.arange(len(names)),tuple(names))\n", | |
"plt.ylabel('Time [s]')\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 53, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def rmse(a,b,dim):\n", | |
" return ((a-b)**2).mean(dim)**.5\n", | |
"\n", | |
"from numba import float64, guvectorize\n", | |
"\n", | |
"\n", | |
"@guvectorize(\n", | |
" \"(float64[:], float64[:], float64[:])\",\n", | |
" \"(n), (n) -> ()\",\n", | |
" nopython=True,\n", | |
")\n", | |
"def np_rmse_gufunc(a, b, out):\n", | |
" out[:] = np.mean((a-b)**2)\n", | |
"\n", | |
"def xr_rmse_gufunc(a,b,dim):\n", | |
" return xr.apply_ufunc(\n", | |
" np_rmse_gufunc, # first the function\n", | |
" a, # now arguments in the order expected\n", | |
" b,\n", | |
" input_core_dims=[[dim], [dim]], # list with one entry per arg\n", | |
" exclude_dims=set((dim,)), # dimensions allowed to change size. Must be a set!\n", | |
" # vectorize=True, # not needed since numba takes care of vectorizing\n", | |
" dask=\"parallelized\",\n", | |
" output_dtypes=[a.dtype], # one per output; could also be float or np.dtype(\"float64\")\n", | |
" )**.5" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"798 ms ± 28.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit xr_rmse_gufunc(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1.05 s ± 11.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit xs.rmse(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"628 ms ± 15.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit rmse(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"771 ms ± 29.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit xr_mse_gufunc(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"924 ms ± 75.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit xs.mse(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n", | |
"/work/mh0727/m300524/miniconda3/envs/climpred-dev/lib/python3.6/site-packages/dask/array/numpy_compat.py:40: RuntimeWarning: invalid value encountered in true_divide\n", | |
" x = np.divide(x1, x2, out)\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"635 ms ± 21.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | |
] | |
} | |
], | |
"source": [ | |
"%timeit mse(a,b,dim).compute()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python [conda env:climpred-dev]", | |
"language": "python", | |
"name": "conda-env-climpred-dev-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.6.7" | |
}, | |
"nbsphinx": { | |
"allow_errors": true | |
}, | |
"org": null, | |
"toc": { | |
"base_numbering": 1, | |
"nav_menu": {}, | |
"number_sections": false, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": true | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment