Skip to content

Instantly share code, notes, and snippets.

@andersy005
Last active November 19, 2020 00:42
Show Gist options
  • Select an option

  • Save andersy005/de62c4e986e3c272e0e888fe0b430889 to your computer and use it in GitHub Desktop.

Select an option

Save andersy005/de62c4e986e3c272e0e888fe0b430889 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2020-11-18 17:01:27-- https://data.nodc.noaa.gov/ghrsst/L4/GLOB/JPL/MUR25/2002/152/20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc.bz2\n",
"Resolving data.nodc.noaa.gov (data.nodc.noaa.gov)... 140.90.235.40\n",
"Connecting to data.nodc.noaa.gov (data.nodc.noaa.gov)|140.90.235.40|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 228539731 (218M) [application/x-bzip2]\n",
"Saving to: '20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc.bz2'\n",
"\n",
"100%[======================================>] 228,539,731 694KB/s in 7m 23s \n",
"\n",
"2020-11-18 17:08:54 (504 KB/s) - '20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc.bz2' saved [228539731/228539731]\n",
"\n"
]
}
],
"source": [
"!wget https://data.nodc.noaa.gov/ghrsst/L4/GLOB/JPL/MUR25/2002/152/20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc.bz2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"!bzip2 -dk 20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc.bz2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import numpy as np\n",
"from datetime import datetime"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt, dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (lat: 16384, lon: 32768, time: 1)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2002-06-01T09:00:00\n",
" * lat (lat) float32 -89.9945 -89.9835 ... 89.9835 89.9945\n",
" * lon (lon) float32 -179.995 -179.984 ... 179.984 179.995\n",
"Data variables:\n",
" analysed_sst (time, lat, lon) float32 ...\n",
" analysis_error (time, lat, lon) float32 ...\n",
" mask (time, lat, lon) float32 ...\n",
" sea_ice_fraction (time, lat, lon) float32 ...\n",
"Attributes:\n",
" title: Daily MUR SST, Final product\n",
" comment: MUR = &quot;Multi-scale Ultra-high Reolution&quot;; produce...\n",
" Conventions: CF-1.5\n",
" DSD_entry_id: JPL-L4UHfnd-GLOB-MUR\n",
" references: ftp://mariana.jpl.nasa.gov/mur_sst/tmchin/docs/ATBD/\n",
" source_data: AMSRE-REMSS, AVHRR_Pathfinder-PFV5.2-NODC_day, AV...\n",
" institution: Jet Propulsion Laboratory\n",
" contact: ghrsst@podaac.jpl.nasa.gov\n",
" GDS_version_id: GDS-v1.0-rev1.6\n",
" netcdf_version_id: 3.5\n",
" creation_date: 2014-06-20\n",
" product_version: 04\n",
" history: Final version created at nominal 4-day latency; r...\n",
" spatial_resolution: 0.011 degrees\n",
" start_date: 2002-06-01\n",
" start_time: 09:00:00 UTC\n",
" stop_date: 2002-06-01\n",
" stop_time: 09:00:00 UTC\n",
" southernmost_latitude: -90.0\n",
" northernmost_latitude: 90.0\n",
" westernmost_longitude: -180.0\n",
" easternmost_longitude: 180.0\n",
" file_quality_index: 0</pre><div class='xr-wrap' hidden><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-b59ef690-2f1a-4800-ab0a-6e842c2cbccf' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-b59ef690-2f1a-4800-ab0a-6e842c2cbccf' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>lat</span>: 16384</li><li><span class='xr-has-index'>lon</span>: 32768</li><li><span class='xr-has-index'>time</span>: 1</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-135cc761-d03a-4cd0-a345-fee257230987' class='xr-section-summary-in' type='checkbox' checked><label for='section-135cc761-d03a-4cd0-a345-fee257230987' 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'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2002-06-01T09:00:00</div><input id='attrs-5b6878ea-5b95-4a75-9b9a-b5d4596e6b6e' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-5b6878ea-5b95-4a75-9b9a-b5d4596e6b6e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8b6a7b56-a0b8-4902-b699-0bb3ae6a92ee' class='xr-var-data-in' type='checkbox'><label for='data-8b6a7b56-a0b8-4902-b699-0bb3ae6a92ee' 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>reference time of sst field</dd><dt><span>standard_name :</span></dt><dd>time</dd><dt><span>axis :</span></dt><dd>T</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;2002-06-01T09:00:00.000000000&#x27;], dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>-89.9945 -89.9835 ... 89.9945</div><input id='attrs-7d3ed353-e5cf-4b11-b390-5679b274d6cf' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7d3ed353-e5cf-4b11-b390-5679b274d6cf' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e840811f-aa13-456f-b747-c7191e4d8853' class='xr-var-data-in' type='checkbox'><label for='data-e840811f-aa13-456f-b747-c7191e4d8853' 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</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>axis :</span></dt><dd>Y</dd><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>valid_min :</span></dt><dd>-90.0</dd><dt><span>valid_max :</span></dt><dd>90.0</dd></dl></div><div class='xr-var-data'><pre>array([-89.9945, -89.9835, -89.9725, ..., 89.9725, 89.9835, 89.9945],\n",
" dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>-179.995 -179.984 ... 179.995</div><input id='attrs-91ee6a0c-4bc7-438a-aa38-8817267d931f' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-91ee6a0c-4bc7-438a-aa38-8817267d931f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-663a3b54-78ec-4dab-8750-9dc091fd6977' class='xr-var-data-in' type='checkbox'><label for='data-663a3b54-78ec-4dab-8750-9dc091fd6977' 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</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>axis :</span></dt><dd>X</dd><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>valid_min :</span></dt><dd>-180.0</dd><dt><span>valid_max :</span></dt><dd>180.0</dd></dl></div><div class='xr-var-data'><pre>array([-179.995, -179.984, -179.973, ..., 179.973, 179.984, 179.995],\n",
" dtype=float32)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-828e2579-0928-4a91-a530-5b01dbcd60a6' class='xr-section-summary-in' type='checkbox' checked><label for='section-828e2579-0928-4a91-a530-5b01dbcd60a6' class='xr-section-summary' >Data variables: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>analysed_sst</span></div><div class='xr-var-dims'>(time, lat, lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-08de6c0d-0c01-45a0-8680-bdeb6856a56c' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-08de6c0d-0c01-45a0-8680-bdeb6856a56c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-15a8e721-1a26-4d9c-a4c2-ea39ed54d619' class='xr-var-data-in' type='checkbox'><label for='data-15a8e721-1a26-4d9c-a4c2-ea39ed54d619' 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>analysed sea surface temperature</dd><dt><span>standard_name :</span></dt><dd>sea_surface_foundation_temperature</dd><dt><span>units :</span></dt><dd>kelvin</dd><dt><span>valid_min :</span></dt><dd>-32767</dd><dt><span>valid_max :</span></dt><dd>32767</dd></dl></div><div class='xr-var-data'><pre>[536870912 values with dtype=float32]</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>analysis_error</span></div><div class='xr-var-dims'>(time, lat, lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-bdf8caff-0df0-4d95-a53e-c1404c1761e6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-bdf8caff-0df0-4d95-a53e-c1404c1761e6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-966333cc-663d-4a7b-bb64-4a7021d2983a' class='xr-var-data-in' type='checkbox'><label for='data-966333cc-663d-4a7b-bb64-4a7021d2983a' 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>estimated error standard deviation of analysed_sst</dd><dt><span>units :</span></dt><dd>kelvin</dd><dt><span>valid_min :</span></dt><dd>0</dd><dt><span>valid_max :</span></dt><dd>32767</dd></dl></div><div class='xr-var-data'><pre>[536870912 values with dtype=float32]</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>mask</span></div><div class='xr-var-dims'>(time, lat, lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-10372cb6-06ff-4855-b8a7-11f664c19ebe' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-10372cb6-06ff-4855-b8a7-11f664c19ebe' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-200ed3ac-16ac-42d8-840a-186eb117fb4e' class='xr-var-data-in' type='checkbox'><label for='data-200ed3ac-16ac-42d8-840a-186eb117fb4e' 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>sea/land field composite mask</dd><dt><span>flag_values :</span></dt><dd>[ 1 2 3 5 9 11 13]</dd><dt><span>flag_meanings :</span></dt><dd>1=open-sea; 2=land; 3=coast/shore; 5=open-lake; 9=open-sea with ice in the grid; 11=coast/shore with ice in the grid; 13=open-lake with ice in the grid</dd></dl></div><div class='xr-var-data'><pre>[536870912 values with dtype=float32]</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>sea_ice_fraction</span></div><div class='xr-var-dims'>(time, lat, lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-706bcc0c-e798-43f7-aea8-1fccb9fdc366' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-706bcc0c-e798-43f7-aea8-1fccb9fdc366' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-201d47e7-2c45-45d3-9c8b-ad3c9c479b1b' class='xr-var-data-in' type='checkbox'><label for='data-201d47e7-2c45-45d3-9c8b-ad3c9c479b1b' 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>sea ice area fraction</dd><dt><span>standard_name :</span></dt><dd>sea ice area fraction</dd><dt><span>units :</span></dt><dd>fraction (between 0 and 1)</dd><dt><span>valid_min :</span></dt><dd>0</dd><dt><span>valid_max :</span></dt><dd>100</dd><dt><span>source :</span></dt><dd>EUMETSAT OSI-SAF, copyright EUMETSAT</dd></dl></div><div class='xr-var-data'><pre>[536870912 values with dtype=float32]</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-95a2a622-c90b-44ef-909f-b28bb6df6372' class='xr-section-summary-in' type='checkbox' ><label for='section-95a2a622-c90b-44ef-909f-b28bb6df6372' class='xr-section-summary' >Attributes: <span>(23)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>title :</span></dt><dd>Daily MUR SST, Final product</dd><dt><span>comment :</span></dt><dd>MUR = &quot;Multi-scale Ultra-high Reolution&quot;; produced under NASA MEaSUREs program</dd><dt><span>Conventions :</span></dt><dd>CF-1.5</dd><dt><span>DSD_entry_id :</span></dt><dd>JPL-L4UHfnd-GLOB-MUR</dd><dt><span>references :</span></dt><dd>ftp://mariana.jpl.nasa.gov/mur_sst/tmchin/docs/ATBD/</dd><dt><span>source_data :</span></dt><dd>AMSRE-REMSS, AVHRR_Pathfinder-PFV5.2-NODC_day, AVHRR_Pathfinder-PFV5.2-NODC_night, MODIS_T-JPL, iQUAM-NOAA/NESDIS, Ice_Conc-OSISAF</dd><dt><span>institution :</span></dt><dd>Jet Propulsion Laboratory</dd><dt><span>contact :</span></dt><dd>ghrsst@podaac.jpl.nasa.gov</dd><dt><span>GDS_version_id :</span></dt><dd>GDS-v1.0-rev1.6</dd><dt><span>netcdf_version_id :</span></dt><dd>3.5</dd><dt><span>creation_date :</span></dt><dd>2014-06-20</dd><dt><span>product_version :</span></dt><dd>04</dd><dt><span>history :</span></dt><dd>Final version created at nominal 4-day latency; replaced Interim nrt (1-day latency) version.</dd><dt><span>spatial_resolution :</span></dt><dd>0.011 degrees</dd><dt><span>start_date :</span></dt><dd>2002-06-01</dd><dt><span>start_time :</span></dt><dd>09:00:00 UTC</dd><dt><span>stop_date :</span></dt><dd>2002-06-01</dd><dt><span>stop_time :</span></dt><dd>09:00:00 UTC</dd><dt><span>southernmost_latitude :</span></dt><dd>-90.0</dd><dt><span>northernmost_latitude :</span></dt><dd>90.0</dd><dt><span>westernmost_longitude :</span></dt><dd>-180.0</dd><dt><span>easternmost_longitude :</span></dt><dd>180.0</dd><dt><span>file_quality_index :</span></dt><dd>0</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (lat: 16384, lon: 32768, time: 1)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2002-06-01T09:00:00\n",
" * lat (lat) float32 -89.9945 -89.9835 ... 89.9835 89.9945\n",
" * lon (lon) float32 -179.995 -179.984 ... 179.984 179.995\n",
"Data variables:\n",
" analysed_sst (time, lat, lon) float32 ...\n",
" analysis_error (time, lat, lon) float32 ...\n",
" mask (time, lat, lon) float32 ...\n",
" sea_ice_fraction (time, lat, lon) float32 ...\n",
"Attributes:\n",
" title: Daily MUR SST, Final product\n",
" comment: MUR = \"Multi-scale Ultra-high Reolution\"; produce...\n",
" Conventions: CF-1.5\n",
" DSD_entry_id: JPL-L4UHfnd-GLOB-MUR\n",
" references: ftp://mariana.jpl.nasa.gov/mur_sst/tmchin/docs/ATBD/\n",
" source_data: AMSRE-REMSS, AVHRR_Pathfinder-PFV5.2-NODC_day, AV...\n",
" institution: Jet Propulsion Laboratory\n",
" contact: ghrsst@podaac.jpl.nasa.gov\n",
" GDS_version_id: GDS-v1.0-rev1.6\n",
" netcdf_version_id: 3.5\n",
" creation_date: 2014-06-20\n",
" product_version: 04\n",
" history: Final version created at nominal 4-day latency; r...\n",
" spatial_resolution: 0.011 degrees\n",
" start_date: 2002-06-01\n",
" start_time: 09:00:00 UTC\n",
" stop_date: 2002-06-01\n",
" stop_time: 09:00:00 UTC\n",
" southernmost_latitude: -90.0\n",
" northernmost_latitude: 90.0\n",
" westernmost_longitude: -180.0\n",
" easternmost_longitude: 180.0\n",
" file_quality_index: 0"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds = xr.open_dataset(\"20020601-JPL-L4UHfnd-GLOB-v01-fv04-MUR.nc\")\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def latlon_to_scrip(nx, ny, lon0=-180., grid_imask=None, file_out=None):\n",
" \"\"\"Generate a SCRIP grid file for a regular lat x lon grid.\n",
" \n",
" Parameters\n",
" ----------\n",
" \n",
" nx : int\n",
" Number of points in x (longitude).\n",
" ny : int\n",
" Number of points in y (latitude).\n",
" lon0 : float, optional [default=-180]\n",
" Longitude on lefthand grid boundary.\n",
" grid_imask : array-like, optional [default=None] \n",
" If the value is set to 0 for a grid point, then that point is\n",
" considered masked out and won't be used in the weights \n",
" generated by the application. \n",
" file_out : string, optional [default=None]\n",
" File to which to write the grid.\n",
" Returns\n",
" -------\n",
" \n",
" ds : xarray.Dataset\n",
" The grid file dataset. \n",
" \"\"\"\n",
" \n",
" # compute coordinates of regular grid\n",
" dx = 360. / nx\n",
" dy = 180. / ny\n",
" lat = np.arange(-90. + dy / 2., 90., dy)\n",
" lon = np.arange(lon0 + dx / 2., lon0 + 360., dx)\n",
"\n",
" # make 2D\n",
" y_center = np.broadcast_to(lat[:, None], (ny, nx))\n",
" x_center = np.broadcast_to(lon[None, :], (ny, nx))\n",
"\n",
" # compute corner points: must be counterclockwise\n",
" y_corner = np.stack((y_center - dy / 2., # SW\n",
" y_center - dy / 2., # SE\n",
" y_center + dy / 2., # NE\n",
" y_center + dy / 2.), # NW\n",
" axis=2)\n",
"\n",
" x_corner = np.stack((x_center - dx / 2., # SW\n",
" x_center + dx / 2., # SE\n",
" x_center + dx / 2., # NE\n",
" x_center - dx / 2.), # NW\n",
" axis=2)\n",
"\n",
" # compute area\n",
" y0 = np.sin(y_corner[:, :, 0] * np.pi / 180.) # south\n",
" y1 = np.sin(y_corner[:, :, 3] * np.pi / 180.) # north\n",
" x0 = x_corner[:, :, 0] * np.pi / 180. # west\n",
" x1 = x_corner[:, :, 1] * np.pi / 180. # east\n",
" grid_area = (y1 - y0) * (x1 - x0)\n",
" \n",
" # sum of area should be equal to area of sphere\n",
" np.testing.assert_allclose(grid_area.sum(), 4.*np.pi)\n",
" \n",
" # construct mask\n",
" if grid_imask is None:\n",
" grid_imask = np.ones((ny, nx), dtype=np.int32)\n",
" \n",
" # generate output dataset\n",
" dso = xr.Dataset() \n",
" dso['grid_dims'] = xr.DataArray(np.array([nx, ny], dtype=np.int32), \n",
" dims=('grid_rank',)) \n",
" dso.grid_dims.encoding = {'dtype': np.int32}\n",
"\n",
" dso['grid_center_lat'] = xr.DataArray(y_center.reshape((-1,)), \n",
" dims=('grid_size'),\n",
" attrs={'units': 'degrees'})\n",
"\n",
" dso['grid_center_lon'] = xr.DataArray(x_center.reshape((-1,)), \n",
" dims=('grid_size'),\n",
" attrs={'units': 'degrees'})\n",
" \n",
" dso['grid_corner_lat'] = xr.DataArray(y_corner.reshape((-1, 4)), \n",
" dims=('grid_size', 'grid_corners'), \n",
" attrs={'units': 'degrees'})\n",
" dso['grid_corner_lon'] = xr.DataArray(x_corner.reshape((-1, 4)), \n",
" dims=('grid_size', 'grid_corners'), \n",
" attrs={'units': 'degrees'}) \n",
"\n",
" dso['grid_imask'] = xr.DataArray(grid_imask.reshape((-1,)), \n",
" dims=('grid_size'),\n",
" attrs={'units': 'unitless'})\n",
" dso.grid_imask.encoding = {'dtype': np.int32}\n",
" \n",
" dso['grid_area'] = xr.DataArray(grid_area.reshape((-1,)), \n",
" dims=('grid_size'),\n",
" attrs={'units': 'radians^2',\n",
" 'long_name': 'area weights'})\n",
" \n",
" # force no '_FillValue' if not specified\n",
" for v in dso.variables:\n",
" if '_FillValue' not in dso[v].encoding:\n",
" dso[v].encoding['_FillValue'] = None\n",
"\n",
" dso.attrs = {'title': f'{dy} x {dx} (lat x lon) grid',\n",
" 'created_by': 'latlon_to_scrip',\n",
" 'date_created': f'{datetime.now()}',\n",
" 'conventions': 'SCRIP',\n",
" }\n",
" \n",
" # write output file\n",
" if file_out is not None:\n",
" print(f'writing {file_out}')\n",
" dso.to_netcdf(file_out)\n",
" \n",
" return dso\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 38 s, sys: 21.6 s, total: 59.6 s\n",
"Wall time: 59.6 s\n"
]
}
],
"source": [
"%%time\n",
"scrip = latlon_to_scrip(nx=ds.sizes['lon'], ny=ds.sizes['lat'])"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt, dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (grid_corners: 4, grid_rank: 2, grid_size: 536870912)\n",
"Dimensions without coordinates: grid_corners, grid_rank, grid_size\n",
"Data variables:\n",
" grid_dims (grid_rank) int32 32768 16384\n",
" grid_center_lat (grid_size) float64 -89.99 -89.99 -89.99 ... 89.99 89.99\n",
" grid_center_lon (grid_size) float64 -180.0 -180.0 -180.0 ... 180.0 180.0\n",
" grid_corner_lat (grid_size, grid_corners) float64 -90.0 -90.0 ... 90.0 90.0\n",
" grid_corner_lon (grid_size, grid_corners) float64 -180.0 -180.0 ... 180.0\n",
" grid_imask (grid_size) int32 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1\n",
" grid_area (grid_size) float64 3.525e-12 3.525e-12 ... 3.525e-12\n",
"Attributes:\n",
" title: 0.010986328125 x 0.010986328125 (lat x lon) grid\n",
" created_by: latlon_to_scrip\n",
" date_created: 2020-11-18 17:36:39.688327\n",
" conventions: SCRIP</pre><div class='xr-wrap' hidden><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-35cb5254-6652-44cc-98ab-5eb299413355' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-35cb5254-6652-44cc-98ab-5eb299413355' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>grid_corners</span>: 4</li><li><span>grid_rank</span>: 2</li><li><span>grid_size</span>: 536870912</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-7aef867c-1a4d-4b20-be92-42e5d9026b0a' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-7aef867c-1a4d-4b20-be92-42e5d9026b0a' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-7859088a-acfb-4b3d-833c-a28096803445' class='xr-section-summary-in' type='checkbox' checked><label for='section-7859088a-acfb-4b3d-833c-a28096803445' class='xr-section-summary' >Data variables: <span>(7)</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>grid_dims</span></div><div class='xr-var-dims'>(grid_rank)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>32768 16384</div><input id='attrs-979542fe-8f8c-4135-8a4f-86c945a7d5d3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-979542fe-8f8c-4135-8a4f-86c945a7d5d3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f50caea2-783a-4d4c-afe6-d6372fff03a8' class='xr-var-data-in' type='checkbox'><label for='data-f50caea2-783a-4d4c-afe6-d6372fff03a8' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([32768, 16384], dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_center_lat</span></div><div class='xr-var-dims'>(grid_size)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-89.99 -89.99 ... 89.99 89.99</div><input id='attrs-3f295cbf-3738-485a-bec0-35c3527792aa' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-3f295cbf-3738-485a-bec0-35c3527792aa' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-85710b25-23de-4e9a-a6c7-3d4e957d0817' class='xr-var-data-in' type='checkbox'><label for='data-85710b25-23de-4e9a-a6c7-3d4e957d0817' 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>units :</span></dt><dd>degrees</dd></dl></div><div class='xr-var-data'><pre>array([-89.99450684, -89.99450684, -89.99450684, ..., 89.99450684,\n",
" 89.99450684, 89.99450684])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_center_lon</span></div><div class='xr-var-dims'>(grid_size)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-180.0 -180.0 ... 180.0 180.0</div><input id='attrs-3ea49fce-0362-41ad-b068-bf0be3149105' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-3ea49fce-0362-41ad-b068-bf0be3149105' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-be2d4da7-8414-485b-a246-c98022f5092a' class='xr-var-data-in' type='checkbox'><label for='data-be2d4da7-8414-485b-a246-c98022f5092a' 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>units :</span></dt><dd>degrees</dd></dl></div><div class='xr-var-data'><pre>array([-179.99450684, -179.98352051, -179.97253418, ..., 179.97253418,\n",
" 179.98352051, 179.99450684])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_corner_lat</span></div><div class='xr-var-dims'>(grid_size, grid_corners)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-90.0 -90.0 -89.99 ... 90.0 90.0</div><input id='attrs-880f9610-e0b3-4ace-8bff-2799c9acee9d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-880f9610-e0b3-4ace-8bff-2799c9acee9d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-bed9e8b3-f6c5-4f12-8c35-aa5ef4f55ea0' class='xr-var-data-in' type='checkbox'><label for='data-bed9e8b3-f6c5-4f12-8c35-aa5ef4f55ea0' 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>units :</span></dt><dd>degrees</dd></dl></div><div class='xr-var-data'><pre>array([[-90. , -90. , -89.98901367, -89.98901367],\n",
" [-90. , -90. , -89.98901367, -89.98901367],\n",
" [-90. , -90. , -89.98901367, -89.98901367],\n",
" ...,\n",
" [ 89.98901367, 89.98901367, 90. , 90. ],\n",
" [ 89.98901367, 89.98901367, 90. , 90. ],\n",
" [ 89.98901367, 89.98901367, 90. , 90. ]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_corner_lon</span></div><div class='xr-var-dims'>(grid_size, grid_corners)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-180.0 -180.0 ... 180.0 180.0</div><input id='attrs-03fd2e11-d4b5-4cc3-95d7-86bb3d62a4e4' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-03fd2e11-d4b5-4cc3-95d7-86bb3d62a4e4' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0f4b4f50-862c-4fcd-be18-f933fc51f7ba' class='xr-var-data-in' type='checkbox'><label for='data-0f4b4f50-862c-4fcd-be18-f933fc51f7ba' 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>units :</span></dt><dd>degrees</dd></dl></div><div class='xr-var-data'><pre>array([[-180. , -179.98901367, -179.98901367, -180. ],\n",
" [-179.98901367, -179.97802734, -179.97802734, -179.98901367],\n",
" [-179.97802734, -179.96704102, -179.96704102, -179.97802734],\n",
" ...,\n",
" [ 179.96704102, 179.97802734, 179.97802734, 179.96704102],\n",
" [ 179.97802734, 179.98901367, 179.98901367, 179.97802734],\n",
" [ 179.98901367, 180. , 180. , 179.98901367]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_imask</span></div><div class='xr-var-dims'>(grid_size)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1</div><input id='attrs-c70e994d-9747-4e28-aa72-938c807cd648' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-c70e994d-9747-4e28-aa72-938c807cd648' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8b9ce006-1910-4b51-b944-b05e0ec156ea' class='xr-var-data-in' type='checkbox'><label for='data-8b9ce006-1910-4b51-b944-b05e0ec156ea' 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>units :</span></dt><dd>unitless</dd></dl></div><div class='xr-var-data'><pre>array([1, 1, 1, ..., 1, 1, 1], dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>grid_area</span></div><div class='xr-var-dims'>(grid_size)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>3.525e-12 3.525e-12 ... 3.525e-12</div><input id='attrs-fe2a6486-88cc-446b-b6af-24b4d2e9494f' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-fe2a6486-88cc-446b-b6af-24b4d2e9494f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2bf9ba86-32ed-442c-a194-5e2f104dac68' class='xr-var-data-in' type='checkbox'><label for='data-2bf9ba86-32ed-442c-a194-5e2f104dac68' 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>units :</span></dt><dd>radians^2</dd><dt><span>long_name :</span></dt><dd>area weights</dd></dl></div><div class='xr-var-data'><pre>array([3.52500553e-12, 3.52500553e-12, 3.52500553e-12, ...,\n",
" 3.52500553e-12, 3.52500553e-12, 3.52500553e-12])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-9a285c3b-23a5-4136-b763-20e82309b062' class='xr-section-summary-in' type='checkbox' checked><label for='section-9a285c3b-23a5-4136-b763-20e82309b062' 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>title :</span></dt><dd>0.010986328125 x 0.010986328125 (lat x lon) grid</dd><dt><span>created_by :</span></dt><dd>latlon_to_scrip</dd><dt><span>date_created :</span></dt><dd>2020-11-18 17:36:39.688327</dd><dt><span>conventions :</span></dt><dd>SCRIP</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (grid_corners: 4, grid_rank: 2, grid_size: 536870912)\n",
"Dimensions without coordinates: grid_corners, grid_rank, grid_size\n",
"Data variables:\n",
" grid_dims (grid_rank) int32 32768 16384\n",
" grid_center_lat (grid_size) float64 -89.99 -89.99 -89.99 ... 89.99 89.99\n",
" grid_center_lon (grid_size) float64 -180.0 -180.0 -180.0 ... 180.0 180.0\n",
" grid_corner_lat (grid_size, grid_corners) float64 -90.0 -90.0 ... 90.0 90.0\n",
" grid_corner_lon (grid_size, grid_corners) float64 -180.0 -180.0 ... 180.0\n",
" grid_imask (grid_size) int32 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1\n",
" grid_area (grid_size) float64 3.525e-12 3.525e-12 ... 3.525e-12\n",
"Attributes:\n",
" title: 0.010986328125 x 0.010986328125 (lat x lon) grid\n",
" created_by: latlon_to_scrip\n",
" date_created: 2020-11-18 17:36:39.688327\n",
" conventions: SCRIP"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scrip"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"xarray.Dataset {\n",
"dimensions:\n",
"\tgrid_corners = 4 ;\n",
"\tgrid_rank = 2 ;\n",
"\tgrid_size = 536870912 ;\n",
"\n",
"variables:\n",
"\tint32 grid_dims(grid_rank) ;\n",
"\tfloat64 grid_center_lat(grid_size) ;\n",
"\t\tgrid_center_lat:units = degrees ;\n",
"\tfloat64 grid_center_lon(grid_size) ;\n",
"\t\tgrid_center_lon:units = degrees ;\n",
"\tfloat64 grid_corner_lat(grid_size, grid_corners) ;\n",
"\t\tgrid_corner_lat:units = degrees ;\n",
"\tfloat64 grid_corner_lon(grid_size, grid_corners) ;\n",
"\t\tgrid_corner_lon:units = degrees ;\n",
"\tint32 grid_imask(grid_size) ;\n",
"\t\tgrid_imask:units = unitless ;\n",
"\tfloat64 grid_area(grid_size) ;\n",
"\t\tgrid_area:units = radians^2 ;\n",
"\t\tgrid_area:long_name = area weights ;\n",
"\n",
"// global attributes:\n",
"\t:title = 0.010986328125 x 0.010986328125 (lat x lon) grid ;\n",
"\t:created_by = latlon_to_scrip ;\n",
"\t:date_created = 2020-11-18 17:36:39.688327 ;\n",
"\t:conventions = SCRIP ;\n",
"}"
]
}
],
"source": [
"scrip.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.8"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment