seagrid.gcm.smoc#

Copernicus SMOC hourly surface currents, as a module.

Every member of seagrid.sources.model.smoc.SMOC is available as a module attribute, plus the grid metrics and C-grid helpers used by tracmass:

from seagrid import smoc

ds = smoc.open_dataset("2023-01-01 06:00")             # one hour
day = smoc.open_dataset("2023-01-01", timetype="daily")
cgrid = smoc.open_dataset("2023-01-01 06:00", c_grid=True)
metrics = smoc.grid_definition()                       # dxv, dyu, dxdy

See seagrid.sources.module.

Module Attributes

LON1D

exact multiples of 1/12°, -180 .

LAT1D

exact multiples of 1/12°, -80 .

Functions

grid_definition([dask, force])

Return the SMOC cell metrics, computed once and cached as Zarr.

open_dataset([dtm, data_var, c_grid])

Open one hour (or day) of SMOC, downloading the file if needed.

source([variant])

Return a source object, optionally for a variant or with overrides.

seagrid.gcm.smoc.LAT1D = array([-80.        , -79.91666667, -79.83333333, ...,  89.83333333,         89.91666667,  90.        ], shape=(2041,))#

exact multiples of 1/12°, -80 … 90.

Type:

Cell-centre latitudes

seagrid.gcm.smoc.LON1D = array([-180.        , -179.91666667, -179.83333333, ...,  179.75      ,         179.83333333,  179.91666667], shape=(4320,))#

exact multiples of 1/12°, -180 … 180 - 1/12.

Type:

Cell-centre longitudes

seagrid.gcm.smoc.a_to_c_grid(ds)[source]#

Interpolate uvel/vvel from an Arakawa A grid to a C grid.

On the A grid all velocity components share the T-cell centres. On the C grid (the NEMO convention used by GLORYS) U(i, j) sits on the east face of T-cell (i, j) and V(i, j) on its north face. Both are a two-point average with the eastern or northern neighbour. Longitude is periodic, so uvel wraps exactly at the dateline; for vvel the northernmost row wraps to the southernmost, which is unphysical, so mask or discard the last latitude row if needed.

Parameters:

ds (xarray.Dataset) – Dataset with uvel and vvel on lat/lon.

Returns:

xarray.Dataset – Copy of ds with uvel and vvel on the C grid. The dimensions are unchanged; the half-cell stagger is implicit in the index convention.

Return type:

Dataset

seagrid.gcm.smoc.grid_definition(dask=True, force=False)[source]#

Return the SMOC cell metrics, computed once and cached as Zarr.

Parameters:
  • dask (bool, optional) – Open the cached store with dask. Default True.

  • force (bool, optional) – Recompute and overwrite the cache. Default False.

Returns:

xarray.Dataset – dxv (zonal cell width, m), dyu (meridional cell height, m) and dxdy (cell area, m²) on y/x, with 2-D lon and lat coordinates. The cache is trm_smoc_grid_def.zarr in the SMOC data directory.

Return type:

Dataset

seagrid.gcm.smoc.open_dataset(dtm=None, data_var=None, *, c_grid=False, **kwargs)[source]#

Open one hour (or day) of SMOC, downloading the file if needed.

As seagrid.sources.DataSource.open_dataset(), plus c_grid.

Parameters:
  • dtm (str, pandas.Timestamp, numpy.datetime64 or datetime, optional) – Date and hour. Default: the first available date.

  • data_var (str, optional) – Return only this variable.

  • c_grid (bool, optional) – Interpolate uvel/vvel to an Arakawa C grid (a_to_c_grid()). Default False.

  • **kwargs – timetype ("hourly", the default, or "daily") and the other keywords of open_dataset().

Returns:

xarray.Dataset

Return type:

Dataset

seagrid.gcm.smoc.source(variant=None, **overrides)#

Return a source object, optionally for a variant or with overrides.

Parameters:
  • variant (str, optional) – Product variant, e.g. "nrt".

  • **overrides – Settings that replace the configured ones for this object.

Returns:

DataSource

Return type:

DataSource