Support non-global datasets
With non-global datasets everything works as it is, but in some cases the user might not want to trim the x
- and y
-dimensions as done with lib.trim_and_squeeze()
. E.g. when working with nest data. For the x
-dimension this could be easily implemented with something like
def trim_and_squeeze(ds):
"""Remove redundant grid points and drop singleton dimensions."""
if "y" in ds.dims:
ds = ds.isel(y=slice(1, -1))
if "x" in ds.dims:
if (ds.nav_lon.isel(x=1)
- ds.nav_lon.isel(x=-1)).sum().values == 0:
ds = ds.isel(x=slice(1, -1))
ds = ds.squeeze()
return ds
with
if (ds.nav_lon.isel(x=1)
- ds.nav_lon.isel(x=-1)).sum().values == 0:
checking whether there are repeated longitude values on the x
-axis (at least for ORCA025 this works fine).
For the y
-dimension this is a lot more tricky and I can't think of a nice way to implement this so far.