Skip to content

Instantly share code, notes, and snippets.

@suvarchal
Last active July 18, 2021 05:23
Show Gist options
  • Save suvarchal/13dadf9c1b65a7394f706b858f3e5418 to your computer and use it in GitHub Desktop.
Save suvarchal/13dadf9c1b65a7394f706b858f3e5418 to your computer and use it in GitHub Desktop.
Generate FESOM2 mesh information for spatial subsets
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:58:04.650798Z",
"start_time": "2021-07-07T00:58:04.644992Z"
}
},
"outputs": [],
"source": [
"from pyfesom2.datasets import fesom_mesh_to_xr\n",
"import pandas as pd\n",
"import numpy as np\n",
"#import csv\n",
"import shutil\n",
"import os.path"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:55:58.042355Z",
"start_time": "2021-07-07T00:55:58.040407Z"
}
},
"outputs": [],
"source": [
"# a few utils to write mesh info"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:55:58.053946Z",
"start_time": "2021-07-07T00:55:58.045941Z"
}
},
"outputs": [],
"source": [
"def write_nod2d(da, outfile=\"./nod2d.out\"):\n",
" \n",
" with open(outfile, 'w') as fout:\n",
" nodes = f\"{da.nod2.size:>8}\"\n",
" fout.write(nodes)\n",
" fout.write('\\n')\n",
" \n",
" inds = da.nod2.values+1 # indices using fortran indexing convention\n",
" # lon values are only allowed to be in 0-360 range?\n",
" lons = np.where(da.lon.values>0, da.lon.values, da.lon.values+360.0)\n",
" lats = da.lat.values\n",
" \n",
" # create dataframe with required data as strings\n",
" nod2_df = pd.DataFrame({'indexes': inds,\n",
" 'lon': lons,\n",
" 'lat': lats,\n",
" 'flag': inds*0}, dtype='string') # not sure what is flag setting it to 0\n",
" \n",
" # now format string to percived formatting\n",
" # \n",
" nod2_df['indexes'] = nod2_df['indexes'].apply(lambda x: f\"{x:>8}\")\n",
" \n",
" nod2_df['lon'] = nod2_df['lon'].apply(lambda x: f\"{x[0:11]:>11}\")\n",
" \n",
" nod2_df['lat'] = nod2_df['lat'].apply(lambda x: f\"{x[0:12]:>12}\" if x.startswith('-') else f\"{x[0:11]:>12}\")\n",
" \n",
" nod2_df['flag'] = nod2_df['flag'].apply(lambda x: f\"{x:>8}\")\n",
" \n",
" #not sure how to use space (and not \\t) as delimiter \n",
" #nod2_df.to_csv(outfile, sep=\" \", index=False, header=False, escapechar=' ', quoting=csv.QUOTE_NONE, mode='a') \n",
" \n",
" nod2_df.to_csv(outfile, index=False, header=False, mode='a')\n",
" \n",
" # hacky sed-like way to replace , with space\n",
" with open(outfile, 'rt') as fin:\n",
" contents = fin.read()\n",
" with open(outfile, 'wt') as fout:\n",
" fout.write(contents.replace(\",\", \" \"))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:55:58.062132Z",
"start_time": "2021-07-07T00:55:58.055219Z"
}
},
"outputs": [],
"source": [
"def write_elem2d(da, outfile=\"./elem2d.out\"):\n",
" with open(outfile, 'w') as fout:\n",
" elems = f\"{da.nelem.size:>8}\"\n",
" fout.write(elems)\n",
" fout.write('\\n')\n",
" elem1, elem2, elem3 = (da.faces+1).T.values # +1 for fortran indexing\n",
" df=pd.DataFrame({'elem1': elem1, 'elem2': elem2, 'elem3': elem3 }, dtype='string')\n",
" #return df\n",
" df= df.applymap(lambda val: f\"{val:>8}\")\n",
" df.to_csv(outfile, index=None, header=None, mode='a')\n",
" # hacky sed-like way to replace , with space\n",
" with open(outfile, 'rt') as fin:\n",
" contents = fin.read()\n",
" with open(outfile, 'wt') as fout:\n",
" fout.write(contents.replace(\",\", \" \"))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:55:58.069563Z",
"start_time": "2021-07-07T00:55:58.063259Z"
}
},
"outputs": [],
"source": [
"# aux3d can be copied as is for region selection in lon-lat"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:55:58.075360Z",
"start_time": "2021-07-07T00:55:58.071110Z"
}
},
"outputs": [],
"source": [
"def mesh_info_from_selection(mesh_path, region=None):\n",
" mesh_dataset=fesom_mesh_to_xr(mesh_path)\n",
" if region is None: # useful for testing to regenerate nod2d.out ... and compare\n",
" mesh_subset_dataset = mesh_dataset\n",
" else: # do region selection\n",
" mesh_subset_dataset = mesh_dataset.pyfesom2.select(region=region)\n",
" \n",
" write_nod2d(mesh_subset_dataset)\n",
" write_elem2d(mesh_subset_dataset)\n",
" # aux3d can be copied as is\n",
" shutil.copyfile(os.path.join(mesh_path,\"aux3d.out\"), \"aux3d.out\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:57:26.938701Z",
"start_time": "2021-07-07T00:57:26.936172Z"
}
},
"outputs": [],
"source": [
"######"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:56:51.693551Z",
"start_time": "2021-07-07T00:56:51.690787Z"
}
},
"outputs": [],
"source": [
"mesh_path = \"../pyfesom2_temp/pyfesom2_fixes_may/tests/data/pi-grid\""
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:57:05.264819Z",
"start_time": "2021-07-07T00:57:05.243820Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/suvarchal/AWI/pyfesom2_temp/pyfesom2_fixes_may/tests/data/pi-grid/pickle_mesh_py3_fesom2\n",
"The usepickle == True)\n",
"The pickle file for FESOM2 exists.\n",
"The mesh will be loaded from /home/suvarchal/AWI/pyfesom2_temp/pyfesom2_fixes_may/tests/data/pi-grid/pickle_mesh_py3_fesom2\n"
]
},
{
"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,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (nelem: 5839, nod2: 3140, nz: 48, nz1: 47, three: 3)\n",
"Coordinates:\n",
" lon (nod2) float64 -60.6 -60.73 -62.15 -60.71 ... 127.2 122.0 124.5\n",
" lat (nod2) float64 74.28 73.91 74.05 74.63 ... -66.25 -66.73 -66.46\n",
" faces (nelem, three) uint32 0 11 1 1 11 9 ... 3134 3133 3139 3136 3137\n",
" * nz (nz) float64 -0.0 5.0 10.0 20.0 ... 5.4e+03 5.65e+03 6e+03 6.25e+03\n",
" * nz1 (nz1) float64 2.5 7.5 15.0 25.0 ... 5.525e+03 5.825e+03 6.125e+03\n",
"Dimensions without coordinates: nelem, nod2, three\n",
"Data variables:\n",
" *empty*\n",
"Attributes:\n",
" Conventions: CF-1.7</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-950b460e-43c1-4461-8e94-fa5abdb0b3b5' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-950b460e-43c1-4461-8e94-fa5abdb0b3b5' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>nelem</span>: 5839</li><li><span>nod2</span>: 3140</li><li><span class='xr-has-index'>nz</span>: 48</li><li><span class='xr-has-index'>nz1</span>: 47</li><li><span>three</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-df4e3bbd-487b-485a-86bf-d2303fed0586' class='xr-section-summary-in' type='checkbox' checked><label for='section-df4e3bbd-487b-485a-86bf-d2303fed0586' class='xr-section-summary' >Coordinates: <span>(5)</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>lon</span></div><div class='xr-var-dims'>(nod2)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-60.6 -60.73 -62.15 ... 122.0 124.5</div><input id='attrs-7c95b119-bcd8-4e8d-b72f-20f8c99b698b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7c95b119-bcd8-4e8d-b72f-20f8c99b698b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e9be92be-7c5a-4ecc-b946-748e7168178e' class='xr-var-data-in' type='checkbox'><label for='data-e9be92be-7c5a-4ecc-b946-748e7168178e' 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>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([-60.6011834, -60.7301373, -62.1527131, ..., 127.2248174,\n",
" 121.9987517, 124.5142243])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat</span></div><div class='xr-var-dims'>(nod2)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>74.28 73.91 74.05 ... -66.73 -66.46</div><input id='attrs-9c487724-79e7-4a59-b24b-bb70bf5adba7' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-9c487724-79e7-4a59-b24b-bb70bf5adba7' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a321b2c8-f2fd-4ce0-b403-a8713398f5b2' class='xr-var-data-in' type='checkbox'><label for='data-a321b2c8-f2fd-4ce0-b403-a8713398f5b2' 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>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([ 74.28292396, 73.91183809, 74.05145544, ..., -66.24740724,\n",
" -66.73281897, -66.46269918])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>faces</span></div><div class='xr-var-dims'>(nelem, three)</div><div class='xr-var-dtype'>uint32</div><div class='xr-var-preview xr-preview'>0 11 1 1 11 ... 3133 3139 3136 3137</div><input id='attrs-7a0dfe94-e9cc-4426-9ab6-aaa61f90b7b9' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-7a0dfe94-e9cc-4426-9ab6-aaa61f90b7b9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-994c980a-2998-4f7a-8590-25f25b7428a9' class='xr-var-data-in' type='checkbox'><label for='data-994c980a-2998-4f7a-8590-25f25b7428a9' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[ 0, 11, 1],\n",
" [ 1, 11, 9],\n",
" [ 1, 9, 8],\n",
" ...,\n",
" [3138, 3135, 3139],\n",
" [3138, 3134, 3133],\n",
" [3139, 3136, 3137]], dtype=uint32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>nz</span></div><div class='xr-var-dims'>(nz)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-0.0 5.0 10.0 ... 6e+03 6.25e+03</div><input id='attrs-6aecc767-658c-4837-bff5-9a7858b53d9d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-6aecc767-658c-4837-bff5-9a7858b53d9d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f6634c74-fa18-408b-ad3b-bf1f64b130a5' class='xr-var-data-in' type='checkbox'><label for='data-f6634c74-fa18-408b-ad3b-bf1f64b130a5' 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>depth</dd><dt><span>units :</span></dt><dd>m</dd></dl></div><div class='xr-var-data'><pre>array([-0.00e+00, 5.00e+00, 1.00e+01, 2.00e+01, 3.00e+01, 4.00e+01,\n",
" 5.00e+01, 6.00e+01, 7.00e+01, 8.00e+01, 9.00e+01, 1.00e+02,\n",
" 1.15e+02, 1.35e+02, 1.60e+02, 1.90e+02, 2.30e+02, 2.80e+02,\n",
" 3.40e+02, 4.10e+02, 4.90e+02, 5.80e+02, 6.80e+02, 7.90e+02,\n",
" 9.10e+02, 1.04e+03, 1.18e+03, 1.33e+03, 1.50e+03, 1.70e+03,\n",
" 1.92e+03, 2.15e+03, 2.40e+03, 2.65e+03, 2.90e+03, 3.15e+03,\n",
" 3.40e+03, 3.65e+03, 3.90e+03, 4.15e+03, 4.40e+03, 4.65e+03,\n",
" 4.90e+03, 5.15e+03, 5.40e+03, 5.65e+03, 6.00e+03, 6.25e+03])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>nz1</span></div><div class='xr-var-dims'>(nz1)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>2.5 7.5 ... 5.825e+03 6.125e+03</div><input id='attrs-42766a3b-d6c0-4ea2-96cf-b6b68abf20a6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-42766a3b-d6c0-4ea2-96cf-b6b68abf20a6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2c473935-9cf3-4fda-a50f-d931c4719035' class='xr-var-data-in' type='checkbox'><label for='data-2c473935-9cf3-4fda-a50f-d931c4719035' 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>depth at half level</dd><dt><span>units :</span></dt><dd>m</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>axis :</span></dt><dd>Z</dd></dl></div><div class='xr-var-data'><pre>array([2.500e+00, 7.500e+00, 1.500e+01, 2.500e+01, 3.500e+01, 4.500e+01,\n",
" 5.500e+01, 6.500e+01, 7.500e+01, 8.500e+01, 9.500e+01, 1.075e+02,\n",
" 1.250e+02, 1.475e+02, 1.750e+02, 2.100e+02, 2.550e+02, 3.100e+02,\n",
" 3.750e+02, 4.500e+02, 5.350e+02, 6.300e+02, 7.350e+02, 8.500e+02,\n",
" 9.750e+02, 1.110e+03, 1.255e+03, 1.415e+03, 1.600e+03, 1.810e+03,\n",
" 2.035e+03, 2.275e+03, 2.525e+03, 2.775e+03, 3.025e+03, 3.275e+03,\n",
" 3.525e+03, 3.775e+03, 4.025e+03, 4.275e+03, 4.525e+03, 4.775e+03,\n",
" 5.025e+03, 5.275e+03, 5.525e+03, 5.825e+03, 6.125e+03])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-cc5bb0be-e9b2-4e1e-aef6-f45ce6049d8d' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-cc5bb0be-e9b2-4e1e-aef6-f45ce6049d8d' class='xr-section-summary' title='Expand/collapse section'>Data variables: <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-d207bb9d-71bb-4a64-969e-dd2e141197f5' class='xr-section-summary-in' type='checkbox' checked><label for='section-d207bb9d-71bb-4a64-969e-dd2e141197f5' class='xr-section-summary' >Attributes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>Conventions :</span></dt><dd>CF-1.7</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (nelem: 5839, nod2: 3140, nz: 48, nz1: 47, three: 3)\n",
"Coordinates:\n",
" lon (nod2) float64 -60.6 -60.73 -62.15 -60.71 ... 127.2 122.0 124.5\n",
" lat (nod2) float64 74.28 73.91 74.05 74.63 ... -66.25 -66.73 -66.46\n",
" faces (nelem, three) uint32 0 11 1 1 11 9 ... 3134 3133 3139 3136 3137\n",
" * nz (nz) float64 -0.0 5.0 10.0 20.0 ... 5.4e+03 5.65e+03 6e+03 6.25e+03\n",
" * nz1 (nz1) float64 2.5 7.5 15.0 25.0 ... 5.525e+03 5.825e+03 6.125e+03\n",
"Dimensions without coordinates: nelem, nod2, three\n",
"Data variables:\n",
" *empty*\n",
"Attributes:\n",
" Conventions: CF-1.7"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fesom_mesh_to_xr(mesh_path) # check orig mesh dataset"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:58:08.427426Z",
"start_time": "2021-07-07T00:58:08.240710Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/suvarchal/AWI/pyfesom2_temp/pyfesom2_fixes_may/tests/data/pi-grid/pickle_mesh_py3_fesom2\n",
"The usepickle == True)\n",
"The pickle file for FESOM2 exists.\n",
"The mesh will be loaded from /home/suvarchal/AWI/pyfesom2_temp/pyfesom2_fixes_may/tests/data/pi-grid/pickle_mesh_py3_fesom2\n"
]
}
],
"source": [
"mesh_info_from_selection(mesh_path, region=(-32, 62, 20, 85)) # select and save meshinfo"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:58:10.811670Z",
"start_time": "2021-07-07T00:58:10.668629Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"aux3d.out elem2d.out nod2d.out\r\n"
]
}
],
"source": [
"!ls *.out"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-07T00:59:17.451491Z",
"start_time": "2021-07-07T00:59:17.405487Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/suvarchal/AWI/claudia/pickle_mesh_py3_fesom2\n",
"The usepickle == True)\n",
"The pickle file for FESOM2 exists.\n",
"The mesh will be loaded from /home/suvarchal/AWI/claudia/pickle_mesh_py3_fesom2\n"
]
},
{
"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,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (nelem: 677, nod2: 380, nz: 48, nz1: 47, three: 3)\n",
"Coordinates:\n",
" lon (nod2) float64 -17.59 -19.35 -20.19 -21.36 ... -22.34 -29.81 -26.84\n",
" lat (nod2) float64 74.63 74.23 73.73 73.31 ... 62.33 62.05 62.42 62.14\n",
" faces (nelem, three) uint32 1 0 10 3 2 13 4 ... 378 373 379 379 373 374\n",
" * nz (nz) float64 -0.0 5.0 10.0 20.0 ... 5.4e+03 5.65e+03 6e+03 6.25e+03\n",
" * nz1 (nz1) float64 2.5 7.5 15.0 25.0 ... 5.525e+03 5.825e+03 6.125e+03\n",
"Dimensions without coordinates: nelem, nod2, three\n",
"Data variables:\n",
" *empty*\n",
"Attributes:\n",
" Conventions: CF-1.7</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-276af0bc-ab1c-4a16-a45e-09785ce5f417' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-276af0bc-ab1c-4a16-a45e-09785ce5f417' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>nelem</span>: 677</li><li><span>nod2</span>: 380</li><li><span class='xr-has-index'>nz</span>: 48</li><li><span class='xr-has-index'>nz1</span>: 47</li><li><span>three</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-18c873e8-3026-44e9-b8b6-a690a1c32b7e' class='xr-section-summary-in' type='checkbox' checked><label for='section-18c873e8-3026-44e9-b8b6-a690a1c32b7e' class='xr-section-summary' >Coordinates: <span>(5)</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>lon</span></div><div class='xr-var-dims'>(nod2)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-17.59 -19.35 ... -29.81 -26.84</div><input id='attrs-6023763d-4d2c-4897-bf2e-027477d2cbaa' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-6023763d-4d2c-4897-bf2e-027477d2cbaa' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7bb7bdeb-d963-4587-a054-6b29e0c83861' class='xr-var-data-in' type='checkbox'><label for='data-7bb7bdeb-d963-4587-a054-6b29e0c83861' 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>units :</span></dt><dd>degrees_east</dd></dl></div><div class='xr-var-data'><pre>array([-17.5874553 , -19.3452906 , -20.193573 , -21.360015 ,\n",
" -22.0731905 , -17.3615116 , -19.3179929 , -22.18846 ,\n",
" -15.864382 , -16.1900108 , -17.5943849 , -16.4992691 ,\n",
" -18.3352937 , -19.1510128 , -19.8841271 , -20.3914312 ,\n",
" -20.4190573 , -13.6900725 , -15.5560981 , -15.1247163 ,\n",
" -17.036157 , -19.2260797 , -22.1996439 , -14.1161798 ,\n",
" -11.8392219 , -14.5308735 , -16.9977566 , -15.025801 ,\n",
" -16.124723 , -17.7226524 , -18.3999858 , -19.0649617 ,\n",
" -20.4970192 , -19.112055 , -13.9599745 , -11.8450116 ,\n",
" -9.1694136 , -14.6966179 , -16.6985999 , -15.9290375 ,\n",
" -18.7397895 , -20.7797504 , -22.6670453 , -1.5853535 ,\n",
" -12.4263837 , -6.0493124 , -9.6092251 , -13.2663248 ,\n",
" -15.9613088 , -14.6798822 , -16.6669006 , -17.4474142 ,\n",
" -19.1897004 , -17.8368444 , -19.3548334 , -12.3760669 ,\n",
" -9.6979538 , -6.4331004 , -3.1219469 , 2.008429 ,\n",
" 0.4296224 , -13.6148019 , -12.7583639 , -15.5062587 ,\n",
" -16.5914894 , -18.4818266 , -21.3752065 , -20.0591997 ,\n",
" -23.2249839 , 1.0707213 , -3.7223039 , -10.8254549 ,\n",
" -7.6320001 , -12.5802433 , -14.3086191 , -15.1316649 ,\n",
" -16.0453705 , -17.4577491 , -18.4756751 , 4.7999724 ,\n",
"...\n",
" -1.2103593 , -4.5090919 , -7.2464883 , -11.3685371 ,\n",
" -8.8979098 , -24.3123049 , 19.7043256 , 13.14722559,\n",
" 0.4093574 , 6.5790349 , -4.1990852 , -10.2343198 ,\n",
" -12.104976 , -18.4701417 , -29.2964342 , -27.8875048 ,\n",
" -30.9898969 , -26.6819482 , -24.6141314 , -13.7785336 ,\n",
" 5.7267255 , 11.1841375 , 2.7716015 , -0.2209567 ,\n",
" -3.2612002 , -6.384853 , -11.3130095 , -9.2566874 ,\n",
" -25.4813191 , 18.0121471 , 10.1636111 , 2.4787846 ,\n",
" -4.6578869 , -11.5685418 , -19.1055557 , -29.7478526 ,\n",
" -28.3932184 , -31.3421868 , -27.5487178 , -25.6624552 ,\n",
" -23.1443797 , -16.5904941 , -13.692722 , 3.7747607 ,\n",
" 7.5488629 , 0.8985477 , 1.8260477 , -11.5272717 ,\n",
" -1.9038018 , -4.700496 , -7.3836646 , -9.2317349 ,\n",
" -24.9415772 , 14.608028 , 4.8029058 , -3.0046197 ,\n",
" -29.8638878 , -31.9190301 , -28.7478505 , -26.7165052 ,\n",
" -24.584036 , -20.4223153 , -22.5932098 , -18.0637806 ,\n",
" -15.2591444 , -13.0685336 , -0.7631325 , -10.5742171 ,\n",
" -3.4522832 , -6.2258395 , -8.0254895 , 9.8820769 ,\n",
" -30.719841 , -28.1970493 , -26.1170894 , -24.4799837 ,\n",
" -20.289292 , -22.3403919 , -29.8054757 , -26.8445248 ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat</span></div><div class='xr-var-dims'>(nod2)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>74.63 74.23 73.73 ... 62.42 62.14</div><input id='attrs-3a137ea7-bcd6-49a2-b378-0c1a4d795813' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-3a137ea7-bcd6-49a2-b378-0c1a4d795813' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0de70d4a-722b-422f-8285-e08080a80127' class='xr-var-data-in' type='checkbox'><label for='data-0de70d4a-722b-422f-8285-e08080a80127' 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>units :</span></dt><dd>degrees_north</dd></dl></div><div class='xr-var-data'><pre>array([74.63089965, 74.23311831, 73.72578431, 73.3059939 , 72.83643713,\n",
" 75.13751959, 74.81065657, 72.27578009, 75.31507733, 74.86862726,\n",
" 74.11558163, 74.4243604 , 73.6849668 , 73.26135665, 72.91346502,\n",
" 72.53918457, 72.14103337, 75.98437592, 75.78140956, 76.22642993,\n",
" 75.62681974, 75.41733055, 71.77343952, 75.44714944, 75.63901508,\n",
" 74.92504915, 73.69157942, 74.43916123, 74.00804222, 73.27853244,\n",
" 72.87730762, 72.51788268, 71.71634844, 72.10689653, 76.57175585,\n",
" 76.34008695, 75.98329449, 76.99406378, 76.15509365, 76.60579874,\n",
" 76.01698165, 71.26515974, 71.22716977, 75.28851671, 74.96691448,\n",
" 75.43640791, 75.1537768 , 74.32130367, 73.38647381, 73.81184016,\n",
" 72.89157443, 72.40480384, 71.5956532 , 71.84734551, 71.16779682,\n",
" 76.98757348, 76.79831832, 76.47457025, 76.16561266, 75.51309257,\n",
" 76.36023231, 77.4290385 , 77.85181103, 77.43516372, 77.0385591 ,\n",
" 76.63717714, 70.78536878, 70.72908566, 70.57819201, 74.34468606,\n",
" 74.47816103, 74.32812194, 74.43625815, 73.61045587, 73.11313728,\n",
" 72.51485531, 71.8905508 , 71.26316684, 70.71018749, 74.87522781,\n",
" 77.50360658, 77.31696124, 77.11365678, 75.99582153, 77.22245171,\n",
" 76.71220208, 78.23989788, 78.34841816, 77.92360071, 77.7995947 ,\n",
" 77.37105695, 78.74530316, 70.31109586, 70.2188522 , 70.08395143,\n",
" 69.92464045, 69.47936316, 74.37509669, 73.77278865, 70.10046319,\n",
"...\n",
" 82.32089153, 81.10466265, 81.42502403, 81.30599539, 81.35078438,\n",
" 81.94218435, 82.40152164, 82.35133971, 83.07695206, 66.57442363,\n",
" 66.35113146, 66.36390681, 66.02184364, 66.27831934, 65.849925 ,\n",
" 66.53746761, 67.15028629, 65.48193122, 65.48957191, 65.68436973,\n",
" 66.06081826, 66.15472708, 66.23303183, 65.33295719, 65.4734158 ,\n",
" 83.20564742, 81.64948169, 81.9633047 , 82.13078494, 82.07881314,\n",
" 82.74652033, 82.97049084, 83.55588256, 83.77575438, 66.00974555,\n",
" 65.71217103, 65.80851343, 65.20407644, 65.36762671, 64.70342579,\n",
" 64.39696466, 64.59826097, 64.47514181, 64.70049769, 64.94429139,\n",
" 65.03943879, 64.1541366 , 64.54323095, 84.16807225, 82.58455606,\n",
" 82.8355609 , 82.96463885, 83.58586392, 84.20067817, 84.43263241,\n",
" 65.36044426, 65.04539843, 65.03493801, 64.49060431, 64.47217646,\n",
" 64.4387254 , 63.82500798, 63.49512782, 63.11619883, 62.9986537 ,\n",
" 63.50711116, 62.0965321 , 63.11436943, 63.60100204, 63.83075942,\n",
" 63.92270621, 63.2516342 , 84.88636083, 83.64636368, 83.86190874,\n",
" 84.5532517 , 64.49359861, 64.27334762, 63.87144211, 63.79679448,\n",
" 63.58932147, 63.61723904, 63.08808256, 62.71689526, 62.60102842,\n",
" 62.35306079, 62.33253145, 62.1646472 , 62.47976482, 62.72909126,\n",
" 62.05481102, 84.93091088, 63.47221434, 63.03721687, 63.03301261,\n",
" 62.54564952, 62.33260488, 62.05045674, 62.4206587 , 62.14331346])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>faces</span></div><div class='xr-var-dims'>(nelem, three)</div><div class='xr-var-dtype'>uint32</div><div class='xr-var-preview xr-preview'>1 0 10 3 2 ... 373 379 379 373 374</div><input id='attrs-920caf22-0a04-43d0-b488-6466a93fef69' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-920caf22-0a04-43d0-b488-6466a93fef69' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d4c384cd-e284-4b1e-af7e-6e3868c11e78' class='xr-var-data-in' type='checkbox'><label for='data-d4c384cd-e284-4b1e-af7e-6e3868c11e78' 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([[ 1, 0, 10],\n",
" [ 3, 2, 13],\n",
" [ 4, 3, 14],\n",
" ...,\n",
" [378, 372, 373],\n",
" [378, 373, 379],\n",
" [379, 373, 374]], dtype=uint32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>nz</span></div><div class='xr-var-dims'>(nz)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-0.0 5.0 10.0 ... 6e+03 6.25e+03</div><input id='attrs-4ab84cfc-c4d0-42f8-a195-02d4836e0695' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-4ab84cfc-c4d0-42f8-a195-02d4836e0695' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c155a28e-e1f3-4295-b2e7-38556c2e7b0e' class='xr-var-data-in' type='checkbox'><label for='data-c155a28e-e1f3-4295-b2e7-38556c2e7b0e' 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>depth</dd><dt><span>units :</span></dt><dd>m</dd></dl></div><div class='xr-var-data'><pre>array([-0.00e+00, 5.00e+00, 1.00e+01, 2.00e+01, 3.00e+01, 4.00e+01,\n",
" 5.00e+01, 6.00e+01, 7.00e+01, 8.00e+01, 9.00e+01, 1.00e+02,\n",
" 1.15e+02, 1.35e+02, 1.60e+02, 1.90e+02, 2.30e+02, 2.80e+02,\n",
" 3.40e+02, 4.10e+02, 4.90e+02, 5.80e+02, 6.80e+02, 7.90e+02,\n",
" 9.10e+02, 1.04e+03, 1.18e+03, 1.33e+03, 1.50e+03, 1.70e+03,\n",
" 1.92e+03, 2.15e+03, 2.40e+03, 2.65e+03, 2.90e+03, 3.15e+03,\n",
" 3.40e+03, 3.65e+03, 3.90e+03, 4.15e+03, 4.40e+03, 4.65e+03,\n",
" 4.90e+03, 5.15e+03, 5.40e+03, 5.65e+03, 6.00e+03, 6.25e+03])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>nz1</span></div><div class='xr-var-dims'>(nz1)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>2.5 7.5 ... 5.825e+03 6.125e+03</div><input id='attrs-d1359527-03a2-4dba-b39a-4ba8fee5a776' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-d1359527-03a2-4dba-b39a-4ba8fee5a776' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4d7faff8-8d6d-4ca3-89b3-fda10bd38f82' class='xr-var-data-in' type='checkbox'><label for='data-4d7faff8-8d6d-4ca3-89b3-fda10bd38f82' 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>depth at half level</dd><dt><span>units :</span></dt><dd>m</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>axis :</span></dt><dd>Z</dd></dl></div><div class='xr-var-data'><pre>array([2.500e+00, 7.500e+00, 1.500e+01, 2.500e+01, 3.500e+01, 4.500e+01,\n",
" 5.500e+01, 6.500e+01, 7.500e+01, 8.500e+01, 9.500e+01, 1.075e+02,\n",
" 1.250e+02, 1.475e+02, 1.750e+02, 2.100e+02, 2.550e+02, 3.100e+02,\n",
" 3.750e+02, 4.500e+02, 5.350e+02, 6.300e+02, 7.350e+02, 8.500e+02,\n",
" 9.750e+02, 1.110e+03, 1.255e+03, 1.415e+03, 1.600e+03, 1.810e+03,\n",
" 2.035e+03, 2.275e+03, 2.525e+03, 2.775e+03, 3.025e+03, 3.275e+03,\n",
" 3.525e+03, 3.775e+03, 4.025e+03, 4.275e+03, 4.525e+03, 4.775e+03,\n",
" 5.025e+03, 5.275e+03, 5.525e+03, 5.825e+03, 6.125e+03])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-f638c97f-3371-40e9-99d2-b2529e3f2edc' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-f638c97f-3371-40e9-99d2-b2529e3f2edc' class='xr-section-summary' title='Expand/collapse section'>Data variables: <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-8f28c0c5-7543-4d0a-afe5-ed88ce689807' class='xr-section-summary-in' type='checkbox' checked><label for='section-8f28c0c5-7543-4d0a-afe5-ed88ce689807' class='xr-section-summary' >Attributes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>Conventions :</span></dt><dd>CF-1.7</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (nelem: 677, nod2: 380, nz: 48, nz1: 47, three: 3)\n",
"Coordinates:\n",
" lon (nod2) float64 -17.59 -19.35 -20.19 -21.36 ... -22.34 -29.81 -26.84\n",
" lat (nod2) float64 74.63 74.23 73.73 73.31 ... 62.33 62.05 62.42 62.14\n",
" faces (nelem, three) uint32 1 0 10 3 2 13 4 ... 378 373 379 379 373 374\n",
" * nz (nz) float64 -0.0 5.0 10.0 20.0 ... 5.4e+03 5.65e+03 6e+03 6.25e+03\n",
" * nz1 (nz1) float64 2.5 7.5 15.0 25.0 ... 5.525e+03 5.825e+03 6.125e+03\n",
"Dimensions without coordinates: nelem, nod2, three\n",
"Data variables:\n",
" *empty*\n",
"Attributes:\n",
" Conventions: CF-1.7"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fesom_mesh_to_xr(\".\") # use generated nod2d to make new mesh dataset to verify "
]
},
{
"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"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment