From 27ca63b48da40813589d35f238c01ddfff53118e Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 25 Sep 2019 11:10:43 -0600 Subject: [PATCH 01/18] Add xgcm as a dependency --- ci/docs.yml | 12 ++++++------ ci/environment-dev-3.6.yml | 10 +++------- ci/environment-dev-3.7.yml | 11 ++++------- requirements.txt | 4 +--- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/ci/docs.yml b/ci/docs.yml index 1fd7d0e8..7ed252f7 100644 --- a/ci/docs.yml +++ b/ci/docs.yml @@ -3,16 +3,16 @@ channels: - conda-forge dependencies: - nbsphinx + - netcdf4 + - numba=0.45.1 - numpy=1.17.0 - numpydoc=0.8.0 - pip - python=3.7 - recommonmark - - sphinx_rtd_theme=0.4.2 - - sphinx=1.8.2 - - sphinx-gallery=0.2.0 - - xarray - - netcdf4 - - numba=0.45.1 - scipy=1.3.1 + - sphinx_rtd_theme=0.4.2 - sphinx-copybutton=0.2.5 + - sphinx-gallery=0.2.0 + - sphinx=1.8.2 + - xgcm diff --git a/ci/environment-dev-3.6.yml b/ci/environment-dev-3.6.yml index e6b485ab..68587db3 100644 --- a/ci/environment-dev-3.6.yml +++ b/ci/environment-dev-3.6.yml @@ -4,20 +4,16 @@ channels: dependencies: - bottleneck - codecov - - dask - - distributed - jupyterlab - matplotlib - netcdf4 - numba - - numpy - pip - pytest - pytest-cov + - pytest-lazy-fixture + - pytest-xdist - python=3.6 - scipy - - xarray>=0.12 + - xgcm - zarr - - docrep - - pytest-lazy-fixture - - pytest-xdist diff --git a/ci/environment-dev-3.7.yml b/ci/environment-dev-3.7.yml index 0c7cac9e..e5f97feb 100644 --- a/ci/environment-dev-3.7.yml +++ b/ci/environment-dev-3.7.yml @@ -6,7 +6,6 @@ dependencies: - black - bottleneck - codecov - - dask - flake8 - isort - jupyterlab @@ -15,19 +14,17 @@ dependencies: - nbsphinx - netcdf4 - numba - - numpy - numpydoc - pip - pytest - pytest-cov + - pytest-lazy-fixture + - pytest-xdist - python=3.7 - recommonmark - scipy - sphinx_rtd_theme=0.4.2 + - sphinx-copybutton - sphinx=1.8.2 - - xarray>=0.12 + - xgcm - zarr - - docrep - - pytest-lazy-fixture - - pytest-xdist - - sphinx-copybutton diff --git a/requirements.txt b/requirements.txt index 0b7ff6a9..6c564bc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ jinja2 -numpy numba pyyaml -xarray -dask +xgcm From 1e42aaf551f54b68db56c2f88a522c9d84442d00 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 25 Sep 2019 11:17:13 -0600 Subject: [PATCH 02/18] Add module for modifying pop for xgcm --- pop_tools/modify_pop_for_xgcm.py | 94 ++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 pop_tools/modify_pop_for_xgcm.py diff --git a/pop_tools/modify_pop_for_xgcm.py b/pop_tools/modify_pop_for_xgcm.py new file mode 100644 index 00000000..58e4ebeb --- /dev/null +++ b/pop_tools/modify_pop_for_xgcm.py @@ -0,0 +1,94 @@ +""" +Module for modifying pop model output to be compatible with xgcm + +# Ref: https://gist.github.com/rabernat/933bc785c99828352f343e48d0da6e22 +""" + +import numpy as np +import xarray as xr + + +def _add_pop_dims_to_dataset(ds): + ds_new = ds.copy() + ds_new['nlon_u'] = xr.Variable( + ('nlon_u'), np.arange(len(ds.nlon)) + 1, {'axis': 'X', 'c_grid_axis_shift': 0.5} + ) + ds_new['nlat_u'] = xr.Variable( + ('nlat_u'), np.arange(len(ds.nlat)) + 1, {'axis': 'Y', 'c_grid_axis_shift': 0.5} + ) + ds_new['nlon_t'] = xr.Variable(('nlon_t'), np.arange(len(ds.nlon)) + 0.5, {'axis': 'X'}) + ds_new['nlat_t'] = xr.Variable(('nlat_t'), np.arange(len(ds.nlat)) + 0.5, {'axis': 'Y'}) + + # add metadata to z grid + ds_new['z_t'].attrs.update({'axis': 'Z'}) + ds_new['z_w'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) + ds_new['z_w_top'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) + ds_new['z_w_bot'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': 0.5}) + + return ds_new + + +def _dims_from_grid_loc(grid_loc): + grid_loc = str(grid_loc) + ndim = int(grid_loc[0]) + x_loc_key = int(grid_loc[1]) + y_loc_key = int(grid_loc[2]) + z_loc_key = int(grid_loc[3]) + + x_loc = {1: 'nlon_t', 2: 'nlon_u'}[x_loc_key] + y_loc = {1: 'nlat_t', 2: 'nlat_u'}[y_loc_key] + z_loc = {0: 'surface', 1: 'z_t', 2: 'z_w', 3: 'z_w_bot', 4: 'z_t_150m'}[z_loc_key] + + if ndim == 3: + return z_loc, y_loc, x_loc + elif ndim == 2: + return y_loc, x_loc + + +def _label_coord_grid_locs(ds): + grid_locs = { + 'ANGLE': '2220', + 'ANGLET': '2110', + 'DXT': '2110', + 'DXU': '2220', + 'DYT': '2110', + 'DYU': '2220', + 'HT': '2110', + 'HU': '2220', + 'HTE': '2210', + 'HTN': '2120', + 'HUS': '2210', + 'HUW': '2120', + 'KMT': '2110', + 'KMU': '2220', + 'REGION_MASK': '2110', + 'TAREA': '2110', + 'TLAT': '2110', + 'TLONG': '2110', + 'UAREA': '2220', + 'ULAT': '2220', + 'ULONG': '2220', + } + ds_new = ds.copy() + for vname, grid_loc in grid_locs.items(): + ds_new[vname].attrs['grid_loc'] = grid_loc + return ds_new + + +def relabel_pop_dims(ds): + """Return a new xarray dataset with distinct dimensions for variables at different + grid points. + """ + ds_new = _label_coord_grid_locs(ds) + ds_new = _add_pop_dims_to_dataset(ds_new) + for vname in ds_new.variables: + if 'grid_loc' in ds_new[vname].attrs: + da = ds_new[vname] + dims_orig = da.dims + new_spatial_dims = _dims_from_grid_loc(da.attrs['grid_loc']) + if dims_orig[0] == 'time': + dims = ('time',) + new_spatial_dims + else: + dims = new_spatial_dims + ds_new[vname] = xr.Variable(dims, da.data, da.attrs, da.encoding, fastpath=True) + return ds_new From 5ffa051b4998921d32f34c3dc583981c6951578a Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 25 Sep 2019 11:23:37 -0600 Subject: [PATCH 03/18] Add notebook to depencies --- ci/docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/docs.yml b/ci/docs.yml index 7ed252f7..3bfef867 100644 --- a/ci/docs.yml +++ b/ci/docs.yml @@ -2,6 +2,7 @@ name: pop-tools-dev channels: - conda-forge dependencies: + - notebook - nbsphinx - netcdf4 - numba=0.45.1 From d66987acdc31625857f20bcd8cc7a6b4ed6da291 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 25 Sep 2019 21:21:19 -0600 Subject: [PATCH 04/18] Replace try block with if statement --- pop_tools/modify_pop_for_xgcm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pop_tools/modify_pop_for_xgcm.py b/pop_tools/modify_pop_for_xgcm.py index 58e4ebeb..2d3c3aa4 100644 --- a/pop_tools/modify_pop_for_xgcm.py +++ b/pop_tools/modify_pop_for_xgcm.py @@ -71,7 +71,8 @@ def _label_coord_grid_locs(ds): } ds_new = ds.copy() for vname, grid_loc in grid_locs.items(): - ds_new[vname].attrs['grid_loc'] = grid_loc + if vname in ds.variables: + ds_new[vname].attrs['grid_loc'] = grid_loc return ds_new From b1391bff47b863afefb6c28d09f4f66dec2e622e Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 26 Sep 2019 16:31:39 -0600 Subject: [PATCH 05/18] Add DZU, DZT to grid_locs --- pop_tools/modify_pop_for_xgcm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pop_tools/modify_pop_for_xgcm.py b/pop_tools/modify_pop_for_xgcm.py index 2d3c3aa4..54cbe5d1 100644 --- a/pop_tools/modify_pop_for_xgcm.py +++ b/pop_tools/modify_pop_for_xgcm.py @@ -53,6 +53,8 @@ def _label_coord_grid_locs(ds): 'DXU': '2220', 'DYT': '2110', 'DYU': '2220', + 'DZU': '3221', + 'DZT': '3111', 'HT': '2110', 'HU': '2220', 'HTE': '2210', From d5a5bdd5104f700c50cd5e3bb3c1d02b544272db Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 26 Sep 2019 17:09:19 -0600 Subject: [PATCH 06/18] Update x_loc and y_loc --- pop_tools/modify_pop_for_xgcm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pop_tools/modify_pop_for_xgcm.py b/pop_tools/modify_pop_for_xgcm.py index 54cbe5d1..47536d79 100644 --- a/pop_tools/modify_pop_for_xgcm.py +++ b/pop_tools/modify_pop_for_xgcm.py @@ -35,7 +35,8 @@ def _dims_from_grid_loc(grid_loc): y_loc_key = int(grid_loc[2]) z_loc_key = int(grid_loc[3]) - x_loc = {1: 'nlon_t', 2: 'nlon_u'}[x_loc_key] + x_loc = {1: 'nlon_t', 2: 'nlon_u', 3: 'nlon_u'}[x_loc_key] + y_loc = {1: 'nlat_t', 2: 'nlat_u', 3: 'nlat_t'}[y_loc_key] y_loc = {1: 'nlat_t', 2: 'nlat_u'}[y_loc_key] z_loc = {0: 'surface', 1: 'z_t', 2: 'z_w', 3: 'z_w_bot', 4: 'z_t_150m'}[z_loc_key] From edb64d4a306643e4df17324cc983cd7e21c7159f Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 30 Sep 2019 16:56:05 -0600 Subject: [PATCH 07/18] Use a more appropriate module name --- pop_tools/{modify_pop_for_xgcm.py => xgcm_util.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pop_tools/{modify_pop_for_xgcm.py => xgcm_util.py} (100%) diff --git a/pop_tools/modify_pop_for_xgcm.py b/pop_tools/xgcm_util.py similarity index 100% rename from pop_tools/modify_pop_for_xgcm.py rename to pop_tools/xgcm_util.py From 52562cd3be937be5a4f6b79d7267626b1657ebc9 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 30 Sep 2019 17:37:10 -0600 Subject: [PATCH 08/18] Add top-level get_xgcm_grid function --- docs/source/api.rst | 8 ++++++ pop_tools/__init__.py | 1 + pop_tools/xgcm_util.py | 60 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/docs/source/api.rst b/docs/source/api.rst index 5d87a30c..3029a0f0 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -35,6 +35,12 @@ Utilities lateral_fill +xgcm utilities +~~~~~~~~~~~~~~ + +.. autosummary:: + get_xgcm_grid + .. currentmodule:: pop_tools .. autofunction:: get_grid @@ -48,3 +54,5 @@ Utilities .. autofunction:: list_region_masks .. autofunction:: lateral_fill + +.. autofunction:: get_xgcm_grid diff --git a/pop_tools/__init__.py b/pop_tools/__init__.py index ddeca5ca..b0fe5314 100644 --- a/pop_tools/__init__.py +++ b/pop_tools/__init__.py @@ -8,6 +8,7 @@ from .fill import lateral_fill, lateral_fill_np_array from .grid import get_grid from .region_masks import list_region_masks, region_mask_3d +from .xgcm_util import get_xgcm_grid try: __version__ = get_distribution(__name__).version diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 47536d79..e1ee8bf5 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -96,3 +96,63 @@ def relabel_pop_dims(ds): dims = new_spatial_dims ds_new[vname] = xr.Variable(dims, da.data, da.attrs, da.encoding, fastpath=True) return ds_new + + +def get_xgcm_grid(ds): + """Return an xgcm Grid object + + Parameters + ---------- + ds : xarray.Dataset + An xarray Dataset + + Returns + ------- + grid : xgcm.Grid + An xgcm Grid object + + Examples + -------- + >>> from pop_tools import get_xgcm_grid + >>> import xarray as xr + >>> ds = xr.open_dataset("./tests/data/cesm_pop_monthly.T62_g17.nc") + >>> ds + + Dimensions: (d2: 2, lat_aux_grid: 395, nlat: 384, nlon: 320, time: 1, z_t: 60) + Coordinates: + TLAT (nlat, nlon) float64 ... + TLONG (nlat, nlon) float64 ... + ULAT (nlat, nlon) float64 ... + ULONG (nlat, nlon) float64 ... + * lat_aux_grid (lat_aux_grid) float32 -79.48815 -78.952896 ... 89.47441 90.0 + * time (time) object 0173-01-01 00:00:00 + * z_t (z_t) float32 500.0 1500.0 2500.0 ... 512502.8 537500.0 + Dimensions without coordinates: d2, nlat, nlon + Data variables: + SALT (time, z_t, nlat, nlon) float32 ... + TEMP (time, z_t, nlat, nlon) float32 ... + UVEL (time, z_t, nlat, nlon) float32 ... + VVEL (time, z_t, nlat, nlon) float32 ... + time_bound (time, d2) object ... + Attributes: + title: g.e21.G1850ECOIAF.T62_g17.004 + history: Sun May 26 14:13:02 2019: ncks -4 -L 9 cesm_pop_monthl... + Conventions: CF-1.0; http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-cu... + time_period_freq: month_1 + model_doi_url: https://doi.org/10.5065/D67H1H0V + contents: Diagnostic and Prognostic Variables + source: CCSM POP2, the CCSM Ocean Component + revision: $Id: tavg.F90 90507 2019-01-18 20:54:19Z altuntas@ucar... + calendar: All years have exactly 365 days. + start_time: This dataset was created on 2019-05-26 at 11:20:07.5 + cell_methods: cell_methods = time: mean ==> the variable values are ... + NCO: netCDF Operators version 4.7.4 (http://nco.sf.net) + >>> grid = get_xgcm_grid(ds) + >>> grid + + + """ + import xgcm + + grid = xgcm.Grid(ds) + return grid From 6be0b8c1bdaf72fae034ac34f85d27f814a75593 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 23 Nov 2019 20:57:48 -0700 Subject: [PATCH 09/18] Add test --- pop_tools/xgcm_util.py | 81 +++++++++++++++++++++++------------------ setup.cfg | 2 +- tests/test_xgcm_util.py | 13 +++++++ 3 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 tests/test_xgcm_util.py diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index e1ee8bf5..395da078 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -20,10 +20,14 @@ def _add_pop_dims_to_dataset(ds): ds_new['nlat_t'] = xr.Variable(('nlat_t'), np.arange(len(ds.nlat)) + 0.5, {'axis': 'Y'}) # add metadata to z grid - ds_new['z_t'].attrs.update({'axis': 'Z'}) - ds_new['z_w'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) - ds_new['z_w_top'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) - ds_new['z_w_bot'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': 0.5}) + if 'z_t' in ds_new.variables: + ds_new['z_t'].attrs.update({'axis': 'Z'}) + if 'z_w' in ds_new.variables: + ds_new['z_w'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) + if 'z_w_top' in ds_new.variables: + ds_new['z_w_top'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': -0.5}) + if 'z_w_bot' in ds_new.variables: + ds_new['z_w_bot'].attrs.update({'axis': 'Z', 'c_grid_axis_shift': 0.5}) return ds_new @@ -98,13 +102,15 @@ def relabel_pop_dims(ds): return ds_new -def get_xgcm_grid(ds): +def get_xgcm_grid(ds, **kwargs): """Return an xgcm Grid object Parameters ---------- ds : xarray.Dataset An xarray Dataset + kwargs: + Additional keyword arguments are passed through to `xgcm.Grid` class. Returns ------- @@ -113,46 +119,51 @@ def get_xgcm_grid(ds): Examples -------- - >>> from pop_tools import get_xgcm_grid + >>> from pop_tools import get_xgcm_grid, DATASETS >>> import xarray as xr - >>> ds = xr.open_dataset("./tests/data/cesm_pop_monthly.T62_g17.nc") + >>> fname = DATASETS.fetch("iron_tracer.nc") + >>> ds = xr.open_dataset(fname) >>> ds - Dimensions: (d2: 2, lat_aux_grid: 395, nlat: 384, nlon: 320, time: 1, z_t: 60) + Dimensions: (nlat: 384, nlon: 320, time: 24, z_t: 60, z_w_bot: 60, z_w_top: 60) Coordinates: - TLAT (nlat, nlon) float64 ... - TLONG (nlat, nlon) float64 ... - ULAT (nlat, nlon) float64 ... - ULONG (nlat, nlon) float64 ... - * lat_aux_grid (lat_aux_grid) float32 -79.48815 -78.952896 ... 89.47441 90.0 - * time (time) object 0173-01-01 00:00:00 - * z_t (z_t) float32 500.0 1500.0 2500.0 ... 512502.8 537500.0 - Dimensions without coordinates: d2, nlat, nlon + * time (time) object 0249-02-01 00:00:00 ... 0251-01-01 00:00:00 + * z_t (z_t) float32 500.0 1500.0 2500.0 ... 487508.34 512502.8 537500.0 + TLAT (nlat, nlon) float64 ... + ULONG (nlat, nlon) float64 ... + TLONG (nlat, nlon) float64 ... + ULAT (nlat, nlon) float64 ... + * z_w_top (z_w_top) float32 0.0 1000.0 2000.0 ... 500004.7 525000.94 + * z_w_bot (z_w_bot) float32 1000.0 2000.0 3000.0 ... 525000.94 549999.06 + Dimensions without coordinates: nlat, nlon Data variables: - SALT (time, z_t, nlat, nlon) float32 ... - TEMP (time, z_t, nlat, nlon) float32 ... - UVEL (time, z_t, nlat, nlon) float32 ... - VVEL (time, z_t, nlat, nlon) float32 ... - time_bound (time, d2) object ... - Attributes: - title: g.e21.G1850ECOIAF.T62_g17.004 - history: Sun May 26 14:13:02 2019: ncks -4 -L 9 cesm_pop_monthl... - Conventions: CF-1.0; http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-cu... - time_period_freq: month_1 - model_doi_url: https://doi.org/10.5065/D67H1H0V - contents: Diagnostic and Prognostic Variables - source: CCSM POP2, the CCSM Ocean Component - revision: $Id: tavg.F90 90507 2019-01-18 20:54:19Z altuntas@ucar... - calendar: All years have exactly 365 days. - start_time: This dataset was created on 2019-05-26 at 11:20:07.5 - cell_methods: cell_methods = time: mean ==> the variable values are ... - NCO: netCDF Operators version 4.7.4 (http://nco.sf.net) + UE (time, z_t, nlat, nlon) float32 ... + VN (time, z_t, nlat, nlon) float32 ... + WT (time, z_w_top, nlat, nlon) float32 ... + HDIFE (time, z_t, nlat, nlon) float32 ... + HDIFN (time, z_t, nlat, nlon) float32 ... + HDIFB (time, z_w_bot, nlat, nlon) float32 ... + DIA_IMPVF (time, z_w_bot, nlat, nlon) float32 ... + KPP_SRC (time, z_t, nlat, nlon) float32 ... + STF (time, nlat, nlon) float32 ... + SMS (time, nlat, nlon) float32 ... >>> grid = get_xgcm_grid(ds) >>> grid + Z Axis (periodic): + * center z_t --> left + * right z_w_bot --> center + * left z_w_top --> center + Y Axis (periodic): + * center nlat_t --> right + * right nlat_u --> center + X Axis (periodic): + * center nlon_t --> right + * right nlon_u --> center """ import xgcm - grid = xgcm.Grid(ds) + ds = relabel_pop_dims(ds) + grid = xgcm.Grid(ds, **kwargs) return grid diff --git a/setup.cfg b/setup.cfg index 579dc6ea..f34f0846 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,7 +17,7 @@ collect_ignore = ['setup.py'] [isort] known_first_party=pop_tools -known_third_party=dask,numba,numpy,pkg_resources,pooch,pytest,setuptools,xarray,yaml +known_third_party=dask,numba,numpy,pkg_resources,pooch,pytest,setuptools,xarray,xgcm,yaml multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 diff --git a/tests/test_xgcm_util.py b/tests/test_xgcm_util.py new file mode 100644 index 00000000..8d57aec3 --- /dev/null +++ b/tests/test_xgcm_util.py @@ -0,0 +1,13 @@ +import xarray as xr +import xgcm + +import pop_tools +from pop_tools import DATASETS + + +def test_xgcm_grid(): + fname = DATASETS.fetch('tend_zint_100m_Fe.nc') + ds = xr.open_dataset(fname) + grid = pop_tools.get_xgcm_grid(ds, metrics=None) + assert isinstance(grid, xgcm.Grid) + assert set(['X', 'Y', 'Z']) == set(grid.axes.keys()) From 58cce46eb5291e948919f7349821fcf4773ed27b Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 23 Nov 2019 21:06:55 -0700 Subject: [PATCH 10/18] Use xgcm master --- ci/docs.yml | 4 +++- ci/environment-dev-3.6.yml | 3 ++- ci/environment-dev-3.7.yml | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ci/docs.yml b/ci/docs.yml index 5b56f451..dd3eefa0 100644 --- a/ci/docs.yml +++ b/ci/docs.yml @@ -16,4 +16,6 @@ dependencies: - sphinx-copybutton=0.2.5 - pooch - watermark - - xgcm + - pip + - pip: + - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.6.yml b/ci/environment-dev-3.6.yml index 8d80333b..27246989 100644 --- a/ci/environment-dev-3.6.yml +++ b/ci/environment-dev-3.6.yml @@ -15,10 +15,11 @@ dependencies: - pytest-xdist - python=3.6 - scipy - - xgcm - zarr - docrep - pytest-lazy-fixture - pytest-xdist - pooch - watermark + - pip: + - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.7.yml b/ci/environment-dev-3.7.yml index 53b5dd35..796a891b 100644 --- a/ci/environment-dev-3.7.yml +++ b/ci/environment-dev-3.7.yml @@ -34,4 +34,5 @@ dependencies: - sphinx-copybutton - pooch - watermark - - xgcm + - pip: + - git+https://github.com/xgcm/xgcm.git From ac045276a5c961068cf5b3fe3cb620481895abbe Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 23 Nov 2019 21:34:58 -0700 Subject: [PATCH 11/18] Update environment --- ci/docs.yml | 7 +++---- ci/environment-dev-3.6.yml | 20 +++++++++++++++----- ci/environment-dev-3.7.yml | 13 +++++-------- requirements.txt | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ci/docs.yml b/ci/docs.yml index dd3eefa0..04d3716a 100644 --- a/ci/docs.yml +++ b/ci/docs.yml @@ -2,20 +2,19 @@ name: pop-tools-dev channels: - conda-forge dependencies: - - notebook - nbsphinx - netcdf4 + - notebook - numba=0.45.1 - numpy=1.17.0 - numpydoc=0.8.0 - pip + - pooch - python=3.7 - recommonmark - scipy=1.3.1 - - sphinx_rtd_theme=0.4.2 - sphinx-copybutton=0.2.5 - - pooch + - sphinx_rtd_theme=0.4.2 - watermark - - pip - pip: - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.6.yml b/ci/environment-dev-3.6.yml index 27246989..e62bab3c 100644 --- a/ci/environment-dev-3.6.yml +++ b/ci/environment-dev-3.6.yml @@ -2,24 +2,34 @@ name: pop-tools-dev channels: - conda-forge dependencies: + - autopep8 + - black - bottleneck - codecov + - docrep + - flake8 + - isort - jupyterlab + - make - matplotlib + - nbsphinx - netcdf4 - numba + - numpydoc - pip + - pooch - pytest - pytest-cov - pytest-lazy-fixture - pytest-xdist - python=3.6 + - pyyaml + - recommonmark - scipy - - zarr - - docrep - - pytest-lazy-fixture - - pytest-xdist - - pooch + - sphinx-copybutton + - sphinx=1.8.2 + - sphinx_rtd_theme=0.4.2 - watermark + - zarr - pip: - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.7.yml b/ci/environment-dev-3.7.yml index 796a891b..94b024a2 100644 --- a/ci/environment-dev-3.7.yml +++ b/ci/environment-dev-3.7.yml @@ -6,6 +6,7 @@ dependencies: - black - bottleneck - codecov + - docrep - flake8 - isort - jupyterlab @@ -16,23 +17,19 @@ dependencies: - numba - numpydoc - pip + - pooch - pytest - pytest-cov - pytest-lazy-fixture - pytest-xdist - python=3.7 + - pyyaml - recommonmark - scipy - - sphinx_rtd_theme=0.4.2 - sphinx-copybutton - sphinx=1.8.2 - - xgcm - - zarr - - docrep - - pytest-lazy-fixture - - pytest-xdist - - sphinx-copybutton - - pooch + - sphinx_rtd_theme=0.4.2 - watermark + - zarr - pip: - git+https://github.com/xgcm/xgcm.git diff --git a/requirements.txt b/requirements.txt index 863261a5..22ea4cdb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ numba pyyaml xarray dask -pooch +pooch>=0.7.0 xgcm From 5279f3499d088a50dbead56dafd7c01728663620 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 23 Nov 2019 21:45:05 -0700 Subject: [PATCH 12/18] Add dask and xarray --- ci/docs.yml | 4 +++- ci/environment-dev-3.6.yml | 2 ++ ci/environment-dev-3.7.yml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/docs.yml b/ci/docs.yml index 04d3716a..7d07af69 100644 --- a/ci/docs.yml +++ b/ci/docs.yml @@ -2,6 +2,7 @@ name: pop-tools-dev channels: - conda-forge dependencies: + - dask - nbsphinx - netcdf4 - notebook @@ -13,8 +14,9 @@ dependencies: - python=3.7 - recommonmark - scipy=1.3.1 - - sphinx-copybutton=0.2.5 - sphinx_rtd_theme=0.4.2 + - sphinx-copybutton=0.2.5 - watermark + - xarray - pip: - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.6.yml b/ci/environment-dev-3.6.yml index e62bab3c..72b35c01 100644 --- a/ci/environment-dev-3.6.yml +++ b/ci/environment-dev-3.6.yml @@ -6,6 +6,7 @@ dependencies: - black - bottleneck - codecov + - dask - docrep - flake8 - isort @@ -30,6 +31,7 @@ dependencies: - sphinx=1.8.2 - sphinx_rtd_theme=0.4.2 - watermark + - xarray - zarr - pip: - git+https://github.com/xgcm/xgcm.git diff --git a/ci/environment-dev-3.7.yml b/ci/environment-dev-3.7.yml index 94b024a2..b79795f0 100644 --- a/ci/environment-dev-3.7.yml +++ b/ci/environment-dev-3.7.yml @@ -6,6 +6,7 @@ dependencies: - black - bottleneck - codecov + - dask - docrep - flake8 - isort @@ -30,6 +31,7 @@ dependencies: - sphinx=1.8.2 - sphinx_rtd_theme=0.4.2 - watermark + - xarray - zarr - pip: - git+https://github.com/xgcm/xgcm.git From 356ac54b460dce01c6146b14efbac470bd1feac0 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 11:14:25 -0700 Subject: [PATCH 13/18] Fix bug --- pop_tools/xgcm_util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 395da078..43353a2a 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -41,7 +41,6 @@ def _dims_from_grid_loc(grid_loc): x_loc = {1: 'nlon_t', 2: 'nlon_u', 3: 'nlon_u'}[x_loc_key] y_loc = {1: 'nlat_t', 2: 'nlat_u', 3: 'nlat_t'}[y_loc_key] - y_loc = {1: 'nlat_t', 2: 'nlat_u'}[y_loc_key] z_loc = {0: 'surface', 1: 'z_t', 2: 'z_w', 3: 'z_w_bot', 4: 'z_t_150m'}[z_loc_key] if ndim == 3: From 21cca8090ff5faec320da6e257adaaa6b936a570 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 11:19:12 -0700 Subject: [PATCH 14/18] Add test for UEU, VNU variables --- pop_tools/data_registry.txt | 1 + tests/test_xgcm_util.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pop_tools/data_registry.txt b/pop_tools/data_registry.txt index b048555f..e10fc3a7 100644 --- a/pop_tools/data_registry.txt +++ b/pop_tools/data_registry.txt @@ -6,3 +6,4 @@ cesm_pop_monthly.T62_g17.nc dca4d607f82348cda83a35b2187c522672095aa775334115dda3 lateral_fill_np_array_filled_ref.npz 0e7b16ce8df50d0c904e36aac22868ead3ba8f2a00d5eaeb857dc84ecffb4de8 lateral_fill_np_array_tripole_filled_ref.npz 96e10e924525a6c3b14be4b3f97f41a4c9622938d140585c1f9067fc0f5a2d10 POP_gx3v7.nc 7586ba68ee5b4d8de8ffe5a11974bff81a412c62af9de230088575c8016e4b84 +g.e20.G.TL319_t13.control.001_hfreq.nc 439eb1abf14737341ead088bfd9a3c1b795dc1f79bc9052c09db08fef9ab83e5 diff --git a/tests/test_xgcm_util.py b/tests/test_xgcm_util.py index 8d57aec3..7ae81d34 100644 --- a/tests/test_xgcm_util.py +++ b/tests/test_xgcm_util.py @@ -1,3 +1,4 @@ +import pytest import xarray as xr import xgcm @@ -5,9 +6,10 @@ from pop_tools import DATASETS -def test_xgcm_grid(): - fname = DATASETS.fetch('tend_zint_100m_Fe.nc') - ds = xr.open_dataset(fname) +@pytest.mark.parametrize('file', ['tend_zint_100m_Fe.nc', 'g.e20.G.TL319_t13.control.001_hfreq.nc']) +def test_xgcm_grid(file): + filepath = DATASETS.fetch(file) + ds = xr.open_dataset(filepath) grid = pop_tools.get_xgcm_grid(ds, metrics=None) assert isinstance(grid, xgcm.Grid) assert set(['X', 'Y', 'Z']) == set(grid.axes.keys()) From f5624a1f2b42c9897ce2ee5fadbac1d9fc870dcd Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 11:41:59 -0700 Subject: [PATCH 15/18] Return dataset with renamed dimensions --- docs/source/api.rst | 4 ++-- pop_tools/__init__.py | 2 +- pop_tools/xgcm_util.py | 10 +++++----- tests/test_xgcm_util.py | 7 +++++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 3029a0f0..c2e3cd3f 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -39,7 +39,7 @@ xgcm utilities ~~~~~~~~~~~~~~ .. autosummary:: - get_xgcm_grid + to_xgcm_grid_dataset .. currentmodule:: pop_tools @@ -55,4 +55,4 @@ xgcm utilities .. autofunction:: lateral_fill -.. autofunction:: get_xgcm_grid +.. autofunction:: to_xgcm_grid_dataset diff --git a/pop_tools/__init__.py b/pop_tools/__init__.py index be204396..313dc30c 100644 --- a/pop_tools/__init__.py +++ b/pop_tools/__init__.py @@ -8,7 +8,7 @@ from .fill import lateral_fill, lateral_fill_np_array from .grid import get_grid, grid_defs from .region_masks import list_region_masks, region_mask_3d -from .xgcm_util import get_xgcm_grid +from .xgcm_util import to_xgcm_grid_dataset try: __version__ = get_distribution(__name__).version diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 43353a2a..0f9d0579 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -101,7 +101,7 @@ def relabel_pop_dims(ds): return ds_new -def get_xgcm_grid(ds, **kwargs): +def to_xgcm_grid_dataset(ds, **kwargs): """Return an xgcm Grid object Parameters @@ -146,7 +146,7 @@ def get_xgcm_grid(ds, **kwargs): KPP_SRC (time, z_t, nlat, nlon) float32 ... STF (time, nlat, nlon) float32 ... SMS (time, nlat, nlon) float32 ... - >>> grid = get_xgcm_grid(ds) + >>> grid, ds_new = to_xgcm_grid_dataset(ds) >>> grid Z Axis (periodic): @@ -163,6 +163,6 @@ def get_xgcm_grid(ds, **kwargs): """ import xgcm - ds = relabel_pop_dims(ds) - grid = xgcm.Grid(ds, **kwargs) - return grid + ds_new = relabel_pop_dims(ds) + grid = xgcm.Grid(ds_new, **kwargs) + return grid, ds_new diff --git a/tests/test_xgcm_util.py b/tests/test_xgcm_util.py index 7ae81d34..438b0fda 100644 --- a/tests/test_xgcm_util.py +++ b/tests/test_xgcm_util.py @@ -7,9 +7,12 @@ @pytest.mark.parametrize('file', ['tend_zint_100m_Fe.nc', 'g.e20.G.TL319_t13.control.001_hfreq.nc']) -def test_xgcm_grid(file): +def test_to_xgcm_grid_dataset(file): filepath = DATASETS.fetch(file) ds = xr.open_dataset(filepath) - grid = pop_tools.get_xgcm_grid(ds, metrics=None) + grid, ds_new = pop_tools.to_xgcm_grid_dataset(ds, metrics=None) assert isinstance(grid, xgcm.Grid) assert set(['X', 'Y', 'Z']) == set(grid.axes.keys()) + new_spatial_coords = set(['nlon_u', 'nlat_u', 'nlon_t', 'nlat_t']) + for coord in new_spatial_coords: + assert coord in ds_new.coords From ea3e344d6d0f359e048e27c1dc4f890b7b438966 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 12:00:10 -0700 Subject: [PATCH 16/18] Use coarsen-ed dataset --- pop_tools/data_registry.txt | 1 + pop_tools/xgcm_util.py | 81 +++++++++++++++++++++++++------------ tests/test_xgcm_util.py | 4 +- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/pop_tools/data_registry.txt b/pop_tools/data_registry.txt index e10fc3a7..3a5940d7 100644 --- a/pop_tools/data_registry.txt +++ b/pop_tools/data_registry.txt @@ -7,3 +7,4 @@ lateral_fill_np_array_filled_ref.npz 0e7b16ce8df50d0c904e36aac22868ead3ba8f2a00d lateral_fill_np_array_tripole_filled_ref.npz 96e10e924525a6c3b14be4b3f97f41a4c9622938d140585c1f9067fc0f5a2d10 POP_gx3v7.nc 7586ba68ee5b4d8de8ffe5a11974bff81a412c62af9de230088575c8016e4b84 g.e20.G.TL319_t13.control.001_hfreq.nc 439eb1abf14737341ead088bfd9a3c1b795dc1f79bc9052c09db08fef9ab83e5 +g.e20.G.TL319_t13.control.001_hfreq-coarsen.nc 145659813daf1a607d0857c10699c721693333e39aeb270e116103185b7236ae diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 0f9d0579..7fc4757b 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -120,45 +120,74 @@ def to_xgcm_grid_dataset(ds, **kwargs): -------- >>> from pop_tools import get_xgcm_grid, DATASETS >>> import xarray as xr - >>> fname = DATASETS.fetch("iron_tracer.nc") - >>> ds = xr.open_dataset(fname) + >>> filepath = DATASETS.fetch("g.e20.G.TL319_t13.control.001_hfreq-coarsen.nc") + >>> ds = xr.open_dataset(filepath) >>> ds - Dimensions: (nlat: 384, nlon: 320, time: 24, z_t: 60, z_w_bot: 60, z_w_top: 60) + Dimensions: (d2: 2, nlat: 240, nlon: 360, time: 1, z_t: 62, z_t_150m: 15, z_w: 62, z_w_top: 62) Coordinates: - * time (time) object 0249-02-01 00:00:00 ... 0251-01-01 00:00:00 - * z_t (z_t) float32 500.0 1500.0 2500.0 ... 487508.34 512502.8 537500.0 - TLAT (nlat, nlon) float64 ... - ULONG (nlat, nlon) float64 ... - TLONG (nlat, nlon) float64 ... - ULAT (nlat, nlon) float64 ... - * z_w_top (z_w_top) float32 0.0 1000.0 2000.0 ... 500004.7 525000.94 - * z_w_bot (z_w_bot) float32 1000.0 2000.0 3000.0 ... 525000.94 549999.06 - Dimensions without coordinates: nlat, nlon + * time (time) object 0050-01-01 00:00:00 + * z_t (z_t) float32 500.0 1500.0 2500.0 ... 562499.06 587499.06 + * z_t_150m (z_t_150m) float32 500.0 1500.0 2500.0 ... 13500.0 14500.0 + * z_w (z_w) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 + * z_w_top (z_w_top) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 + TLONG (nlat, nlon) float64 ... + TLAT (nlat, nlon) float64 ... + Dimensions without coordinates: d2, nlat, nlon Data variables: - UE (time, z_t, nlat, nlon) float32 ... - VN (time, z_t, nlat, nlon) float32 ... - WT (time, z_w_top, nlat, nlon) float32 ... - HDIFE (time, z_t, nlat, nlon) float32 ... - HDIFN (time, z_t, nlat, nlon) float32 ... - HDIFB (time, z_w_bot, nlat, nlon) float32 ... - DIA_IMPVF (time, z_w_bot, nlat, nlon) float32 ... - KPP_SRC (time, z_t, nlat, nlon) float32 ... - STF (time, nlat, nlon) float32 ... - SMS (time, nlat, nlon) float32 ... + dz (z_t) float32 ... + dzw (z_w) float32 ... + KMT (nlat, nlon) float64 ... + REGION_MASK (nlat, nlon) float64 ... + TAREA (nlat, nlon) float64 ... + DXU (nlat, nlon) float64 ... + DYU (nlat, nlon) float64 ... + DYT (nlat, nlon) float64 ... + time_bound (time, d2) object ... + UEU (time, z_t, nlat, nlon) float32 ... + VNU (time, z_t, nlat, nlon) float32 ... + S_FLUX_ROFF_VSF (time, z_w_top, nlat, nlon) float32 ... >>> grid, ds_new = to_xgcm_grid_dataset(ds) >>> grid + X Axis (periodic): + * center nlon_t --> right + * right nlon_u --> center Z Axis (periodic): * center z_t --> left - * right z_w_bot --> center * left z_w_top --> center Y Axis (periodic): * center nlat_t --> right * right nlat_u --> center - X Axis (periodic): - * center nlon_t --> right - * right nlon_u --> center + >>> ds_new + + Dimensions: (d2: 2, nlat_t: 240, nlat_u: 240, nlon_t: 360, nlon_u: 360, time: 1, z_t: 62, z_t_150m: 15, z_w: 62, z_w_top: 62) + Coordinates: + * time (time) object 0050-01-01 00:00:00 + * z_t (z_t) float32 500.0 1500.0 2500.0 ... 562499.06 587499.06 + * z_t_150m (z_t_150m) float32 500.0 1500.0 2500.0 ... 13500.0 14500.0 + * z_w (z_w) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 + * z_w_top (z_w_top) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 + TLONG (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + TLAT (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + * nlon_u (nlon_u) int64 1 2 3 4 5 6 7 ... 355 356 357 358 359 360 + * nlat_u (nlat_u) int64 1 2 3 4 5 6 7 ... 235 236 237 238 239 240 + * nlon_t (nlon_t) float64 0.5 1.5 2.5 3.5 ... 357.5 358.5 359.5 + * nlat_t (nlat_t) float64 0.5 1.5 2.5 3.5 ... 237.5 238.5 239.5 + Dimensions without coordinates: d2 + Data variables: + dz (z_t) float32 ... + dzw (z_w) float32 ... + KMT (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + REGION_MASK (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + TAREA (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + DXU (nlat_u, nlon_u) float64 nan nan nan nan ... nan nan nan + DYU (nlat_u, nlon_u) float64 nan nan nan nan ... nan nan nan + DYT (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + time_bound (time, d2) object ... + UEU (time, z_t, nlat_u, nlon_u) float32 inf inf inf ... inf inf + VNU (time, z_t, nlat_t, nlon_u) float32 inf inf inf ... inf inf + S_FLUX_ROFF_VSF (time, z_w, nlat_t, nlon_t) float32 inf inf inf ... inf inf """ import xgcm diff --git a/tests/test_xgcm_util.py b/tests/test_xgcm_util.py index 438b0fda..9b220132 100644 --- a/tests/test_xgcm_util.py +++ b/tests/test_xgcm_util.py @@ -6,7 +6,9 @@ from pop_tools import DATASETS -@pytest.mark.parametrize('file', ['tend_zint_100m_Fe.nc', 'g.e20.G.TL319_t13.control.001_hfreq.nc']) +@pytest.mark.parametrize( + 'file', ['tend_zint_100m_Fe.nc', 'g.e20.G.TL319_t13.control.001_hfreq-coarsen.nc'] +) def test_to_xgcm_grid_dataset(file): filepath = DATASETS.fetch(file) ds = xr.open_dataset(filepath) From 53c396c006a9fca97fe76ec7b7ad7ff30a8498a6 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 12:56:24 -0700 Subject: [PATCH 17/18] Check for non-existance of new coords in the original ds --- pop_tools/xgcm_util.py | 5 ++++- tests/test_xgcm_util.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 7fc4757b..3d022c71 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -102,7 +102,7 @@ def relabel_pop_dims(ds): def to_xgcm_grid_dataset(ds, **kwargs): - """Return an xgcm Grid object + """Modify POP model output to be compatible with xgcm. Parameters ---------- @@ -115,6 +115,9 @@ def to_xgcm_grid_dataset(ds, **kwargs): ------- grid : xgcm.Grid An xgcm Grid object + ds_new : xarray.Dataset + Xarray dataset with distinct dimensions for variables at different + grid points. Examples -------- diff --git a/tests/test_xgcm_util.py b/tests/test_xgcm_util.py index 9b220132..5ff9b52e 100644 --- a/tests/test_xgcm_util.py +++ b/tests/test_xgcm_util.py @@ -18,3 +18,4 @@ def test_to_xgcm_grid_dataset(file): new_spatial_coords = set(['nlon_u', 'nlat_u', 'nlon_t', 'nlat_t']) for coord in new_spatial_coords: assert coord in ds_new.coords + assert coord not in ds.coords From 6bc5445fb3eb560380ac1f8c1b5198452b01bd5f Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 9 Dec 2019 13:01:01 -0700 Subject: [PATCH 18/18] Fix indentation --- pop_tools/xgcm_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pop_tools/xgcm_util.py b/pop_tools/xgcm_util.py index 3d022c71..e3491b0f 100644 --- a/pop_tools/xgcm_util.py +++ b/pop_tools/xgcm_util.py @@ -171,8 +171,8 @@ def to_xgcm_grid_dataset(ds, **kwargs): * z_t_150m (z_t_150m) float32 500.0 1500.0 2500.0 ... 13500.0 14500.0 * z_w (z_w) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 * z_w_top (z_w_top) float32 0.0 1000.0 2000.0 ... 549999.06 574999.06 - TLONG (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan - TLAT (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + TLONG (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan + TLAT (nlat_t, nlon_t) float64 nan nan nan nan ... nan nan nan * nlon_u (nlon_u) int64 1 2 3 4 5 6 7 ... 355 356 357 358 359 360 * nlat_u (nlat_u) int64 1 2 3 4 5 6 7 ... 235 236 237 238 239 240 * nlon_t (nlon_t) float64 0.5 1.5 2.5 3.5 ... 357.5 358.5 359.5