Last active
March 8, 2019 21:36
-
-
Save andersy005/159eebd796935ef0e6d65d679cc37e58 to your computer and use it in GitHub Desktop.
https://binder.pangeo.io/v2/gist/andersy005/159eebd796935ef0e6d65d679cc37e58/master or https://mybinder.org/v2/gist/andersy005/159eebd796935ef0e6d65d679cc37e58/master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: esmlab | |
channels: | |
- conda-forge | |
- defaults | |
dependencies: | |
- numpy | |
- xesmf | |
- esmpy | |
- pyyaml | |
- pip: | |
- git+https://github.com/pydata/xarray.git | |
- git+https://github.com/NCAR/esmlab.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import esmlab" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.Dataset>\n", | |
"Dimensions: (d2: 2, nc: 5, ni: 6, nj: 6, nkbio: 5, nkice: 8, nksnow: 3, nvertices: 4, time: 365)\n", | |
"Coordinates:\n", | |
" TLON (nj, ni) float32 ...\n", | |
" TLAT (nj, ni) float32 ...\n", | |
" ULON (nj, ni) float32 ...\n", | |
" ULAT (nj, ni) float32 ...\n", | |
" NCAT (nc) float32 ...\n", | |
" * time (time) float32 21901.0 21902.0 21903.0 ... 22264.0 22265.0\n", | |
"Dimensions without coordinates: d2, nc, ni, nj, nkbio, nkice, nksnow, nvertices\n", | |
"Data variables:\n", | |
" VGRDi (nkice) float32 ...\n", | |
" VGRDs (nksnow) float32 ...\n", | |
" VGRDb (nkbio) float32 ...\n", | |
" tmask (nj, ni) float32 ...\n", | |
" tarea (nj, ni) float32 ...\n", | |
" uarea (nj, ni) float32 ...\n", | |
" dxt (nj, ni) float32 ...\n", | |
" dyt (nj, ni) float32 ...\n", | |
" dxu (nj, ni) float32 ...\n", | |
" dyu (nj, ni) float32 ...\n", | |
" HTN (nj, ni) float32 ...\n", | |
" HTE (nj, ni) float32 ...\n", | |
" ANGLE (nj, ni) float32 ...\n", | |
" ANGLET (nj, ni) float32 ...\n", | |
" lont_bounds (nj, ni, nvertices) float32 ...\n", | |
" latt_bounds (nj, ni, nvertices) float32 ...\n", | |
" lonu_bounds (nj, ni, nvertices) float32 ...\n", | |
" latu_bounds (nj, ni, nvertices) float32 ...\n", | |
" time_bounds (time, d2) float32 ...\n", | |
" aicen_d (time, nc, nj, ni) float32 ...\n", | |
"Attributes:\n", | |
" title: b.e21.B1850.f09_g17.CMIP6-piControl.001\n", | |
" contents: Diagnostic and Prognostic Variables\n", | |
" source: Los Alamos Sea Ice Model (CICE) Version 5\n", | |
" time_period_freq: day_1\n", | |
" model_doi_url: https://doi.org/10.5065/D67H1H0V\n", | |
" comment: All years have exactly 365 days\n", | |
" comment2: File written on model date 00610102\n", | |
" comment3: seconds elapsed into model date: 0\n", | |
" conventions: CF-1.0\n", | |
" history: This dataset was created on 2018-08-12 at 13:23\n", | |
" io_flavor: io_pio\n", | |
" Extracted_from: /gpfs/fs1/p/cesm/pcwg/timeseries-cmip6/b.e21.B1850.f09..." | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ds1 = esmlab.datasets.open_dataset('cesm_cice_daily', decode_times=False)\n", | |
"ds1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"tm = esmlab.utils.time.time_manager(ds1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"dset = tm.compute_time()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.Dataset>\n", | |
"Dimensions: (d2: 2, nc: 5, ni: 6, nj: 6, nkbio: 5, nkice: 8, nksnow: 3, nvertices: 4, time: 365)\n", | |
"Coordinates:\n", | |
" TLON (nj, ni) float32 ...\n", | |
" TLAT (nj, ni) float32 ...\n", | |
" ULON (nj, ni) float32 ...\n", | |
" ULAT (nj, ni) float32 ...\n", | |
" NCAT (nc) float32 ...\n", | |
" * time (time) object 0061-01-01 12:00:00 ... 0061-12-31 12:00:00\n", | |
"Dimensions without coordinates: d2, nc, ni, nj, nkbio, nkice, nksnow, nvertices\n", | |
"Data variables:\n", | |
" VGRDi (nkice) float32 ...\n", | |
" VGRDs (nksnow) float32 ...\n", | |
" VGRDb (nkbio) float32 ...\n", | |
" tmask (nj, ni) float32 ...\n", | |
" tarea (nj, ni) float32 ...\n", | |
" uarea (nj, ni) float32 ...\n", | |
" dxt (nj, ni) float32 ...\n", | |
" dyt (nj, ni) float32 ...\n", | |
" dxu (nj, ni) float32 ...\n", | |
" dyu (nj, ni) float32 ...\n", | |
" HTN (nj, ni) float32 ...\n", | |
" HTE (nj, ni) float32 ...\n", | |
" ANGLE (nj, ni) float32 ...\n", | |
" ANGLET (nj, ni) float32 ...\n", | |
" lont_bounds (nj, ni, nvertices) float32 ...\n", | |
" latt_bounds (nj, ni, nvertices) float32 ...\n", | |
" lonu_bounds (nj, ni, nvertices) float32 ...\n", | |
" latu_bounds (nj, ni, nvertices) float32 ...\n", | |
" time_bounds (time, d2) float32 21900.0 ... 22265.0\n", | |
" aicen_d (time, nc, nj, ni) float32 ...\n", | |
" t981cf06093e34f9f851bfbf525574671 (time) float32 21901.0 ... 22265.0" | |
] | |
}, | |
"execution_count": 24, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/srv/conda/lib/python3.6/site-packages/xarray/core/nanops.py:159: RuntimeWarning: Mean of empty slice\n", | |
" return np.nanmean(a, axis=axis, dtype=dtype)\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.Dataset>\n", | |
"Dimensions: (d2: 2, nc: 5, ni: 6, nj: 6, nkbio: 5, nkice: 8, nksnow: 3, nvertices: 4, time: 12)\n", | |
"Coordinates:\n", | |
" * time (time) object 0061-01-31 00:00:00 ... 0061-12-31 00:00:00\n", | |
" TLON (nj, ni) float32 320.5625 ... 326.1875\n", | |
" TLAT (nj, ni) float32 -79.22052 ... -76.54944\n", | |
" ULON (nj, ni) float32 321.125 ... 326.75\n", | |
" ULAT (nj, ni) float32 -78.952896 ... -76.28169\n", | |
" NCAT (nc) float32 0.6445072 ... 100000000.0\n", | |
"Dimensions without coordinates: d2, nc, ni, nj, nkbio, nkice, nksnow, nvertices\n", | |
"Data variables:\n", | |
" VGRDi (time, nkice) float32 1.0 2.0 ... 7.0 8.0\n", | |
" VGRDs (time, nksnow) float32 1.0 2.0 ... 3.0\n", | |
" VGRDb (time, nkbio) float32 1.0 2.0 ... 4.0 5.0\n", | |
" tmask (time, nj, ni) float32 0.0 0.0 ... 1.0\n", | |
" tarea (time, nj, ni) float32 1423619100.0 ... 1728060700.0\n", | |
" uarea (time, nj, ni) float32 1423489400.0 ... 1761744800.0\n", | |
" dxt (time, nj, ni) float32 23968.484 ... 29094.156\n", | |
" dyt (time, nj, ni) float32 59395.453 ... 59395.453\n", | |
" dxu (time, nj, ni) float32 23966.3 ... 29661.271\n", | |
" dyu (time, nj, ni) float32 59395.453 ... 59395.453\n", | |
" HTN (time, nj, ni) float32 23966.3 ... 29661.271\n", | |
" HTE (time, nj, ni) float32 59395.453 ... 59395.453\n", | |
" ANGLE (time, nj, ni) float32 0.0 0.0 ... 0.0\n", | |
" ANGLET (time, nj, ni) float32 0.0 0.0 ... 0.0\n", | |
" lont_bounds (time, nj, ni, nvertices) float32 320.0 ... 325.625\n", | |
" latt_bounds (time, nj, ni, nvertices) float32 -79.48714 ... -76.28169\n", | |
" lonu_bounds (time, nj, ni, nvertices) float32 320.5625 ... 326.1875\n", | |
" latu_bounds (time, nj, ni, nvertices) float32 -79.22052 ... -76.01522\n", | |
" time_bounds (time, d2) float32 21915.0 ... 22250.0\n", | |
" aicen_d (time, nc, nj, ni) float32 nan ... 0.01153829\n", | |
" t981cf06093e34f9f851bfbf525574671 (time) float32 21916.0 ... 22250.0" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"computed_dset = dset.resample(time='1M').mean()\n", | |
"computed_dset" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"restored_dset = tm.restore_dataset(computed_dset)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<xarray.Dataset>\n", | |
"Dimensions: (d2: 2, nc: 5, ni: 6, nj: 6, nkbio: 5, nkice: 8, nksnow: 3, nvertices: 4, time: 12)\n", | |
"Coordinates:\n", | |
" * time (time) float32 21916.0 21945.5 21975.0 ... 22219.5 22250.0\n", | |
" TLON (nj, ni) float32 320.5625 321.6875 ... 325.0625 326.1875\n", | |
" TLAT (nj, ni) float32 -79.22052 -79.22052 ... -76.54944 -76.54944\n", | |
" ULON (nj, ni) float32 321.125 322.25 323.375 ... 325.625 326.75\n", | |
" ULAT (nj, ni) float32 -78.952896 -78.952896 ... -76.28169 -76.28169\n", | |
" NCAT (nc) float32 0.6445072 1.3914335 2.4701793 4.567288 100000000.0\n", | |
"Dimensions without coordinates: d2, nc, ni, nj, nkbio, nkice, nksnow, nvertices\n", | |
"Data variables:\n", | |
" VGRDi (time, nkice) float32 1.0 2.0 3.0 4.0 5.0 ... 5.0 6.0 7.0 8.0\n", | |
" VGRDs (time, nksnow) float32 1.0 2.0 3.0 1.0 2.0 ... 3.0 1.0 2.0 3.0\n", | |
" VGRDb (time, nkbio) float32 1.0 2.0 3.0 4.0 5.0 ... 2.0 3.0 4.0 5.0\n", | |
" tmask (time, nj, ni) float32 0.0 0.0 0.0 0.0 0.0 ... 1.0 1.0 1.0 1.0\n", | |
" tarea (time, nj, ni) float32 1423619100.0 ... 1728060700.0\n", | |
" uarea (time, nj, ni) float32 1423489400.0 ... 1761744800.0\n", | |
" dxt (time, nj, ni) float32 23968.484 23968.484 ... 29094.156\n", | |
" dyt (time, nj, ni) float32 59395.453 59395.453 ... 59395.453\n", | |
" dxu (time, nj, ni) float32 23966.3 23966.3 ... 29661.271 29661.271\n", | |
" dyu (time, nj, ni) float32 59395.453 59395.453 ... 59395.453\n", | |
" HTN (time, nj, ni) float32 23966.3 23966.3 ... 29661.271 29661.271\n", | |
" HTE (time, nj, ni) float32 59395.453 59395.453 ... 59395.453\n", | |
" ANGLE (time, nj, ni) float32 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n", | |
" ANGLET (time, nj, ni) float32 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0\n", | |
" lont_bounds (time, nj, ni, nvertices) float32 320.0 321.125 ... 325.625\n", | |
" latt_bounds (time, nj, ni, nvertices) float32 -79.48714 ... -76.28169\n", | |
" lonu_bounds (time, nj, ni, nvertices) float32 320.5625 ... 326.1875\n", | |
" latu_bounds (time, nj, ni, nvertices) float32 -79.22052 ... -76.01522\n", | |
" time_bounds (time, d2) float32 21915.0 21916.0 21944.5 ... 22249.0 22250.0\n", | |
" aicen_d (time, nc, nj, ni) float32 nan nan ... 0.011669797 0.01153829" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"restored_dset" | |
] | |
} | |
], | |
"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.6.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment