seagrid.sources.model.glorys#

GLORYS12 daily reanalysis from the Mercator Ocean THREDDS server (OPeNDAP).

Each day and variable is read over OPeNDAP and cached as one Zarr store, <datadir>/<year>/GLORYS12V1_<date>_grid<X>.zarr. The server needs a Mercator Ocean account, read from ~/.netrc (see Glorys.check_auth()).

Layout (NEMO ORCA12 C-grid, 1/12°): one variable opens with its own dimensions (deptht or depthw, y, x) and coordinates lat_<g>/lon_<g>, where <g> is the first letter of the variable (lat_u for uvel). Opened together (open_dataset(dtm)), the depth dimensions become z. The velocity stores have x = 4322: two halo columns in the west and one in the east relative to the T-cells of the mesh files (x = 4320).

Examples

>>> from seagrid import glorys
>>> ds = glorys.open_dataset("2010-06-01")
>>> temp = glorys.open_dataarray("2010-06-01", "temp")
>>> grid = glorys.grid_definition()

Functions

calc_e3t(zgr)

Return the T-cell thickness of a NEMO grid with partial bottom cells.

Classes

Glorys([variant])

GLORYS12 daily reanalysis (Mercator Ocean THREDDS, OPeNDAP, login).

Exceptions

AuthError

Login to the Mercator THREDDS server failed (see Glorys.check_auth()).

exception seagrid.sources.model.glorys.AuthError[source]#

Bases: PermissionError

Login to the Mercator THREDDS server failed (see Glorys.check_auth()).

class seagrid.sources.model.glorys.Glorys(variant=None, **overrides)[source]#

Bases: OpendapModelSource

GLORYS12 daily reanalysis (Mercator Ocean THREDDS, OPeNDAP, login).

Settings ([glorys]): host (dap2://tds.mercator-ocean.fr), product (glorys12v1), variables, mesh_hgr and mesh_zgr (NEMO mesh files in datadir(), needed by grid_definition()), chunks (dask chunks of the remote read and the cached stores), opendap_timeout ([connect, read] seconds per request), account_email, userguide_url.

Parameters:
  • variant (str | None)

  • overrides (Any)

has_fill_values: ClassVar[bool] = True#

True if land cells hold fill values that mask_fill() replaces.

property product: str#

Product name on the server, e.g. "glorys12v1".

property machine: str#

Host name of the THREDDS server (the ~/.netrc machine).

check_auth(raise_error=True, timeout=20)[source]#

Check that the THREDDS server accepts the login in ~/.netrc.

Requests the description (.dds) of the uvel dataset without following redirects: the server answers 200 when the login works and redirects to its login page when it is missing or wrong. Nothing is downloaded.

Parameters:
  • raise_error (bool, optional) – Raise AuthError if the login fails. Default True; False logs the explanation and returns False.

  • timeout (float, optional) – Seconds to wait for the server. Default 20.

Returns:

bool – True if the login works.

Raises:
  • AuthError – The login is missing or rejected. The message says what is wrong with the netrc file, how to fix it and how to request an account.

  • seagrid.download.DownloadError – If the server cannot be reached (not a login problem).

Return type:

bool

grid_definition(dask=True, force=False)[source]#

Return the ORCA12 cell metrics from the NEMO mesh files, cached as Zarr.

As ModelSource.grid_definition(). Fill values in land cells of older caches become 0 (land is kmt == 0 and dzt == 0).

Parameters:
Return type:

Dataset

rechunk_wvel(start, end=None, depth_chunk=10, path=None)[source]#

Rewrite cached wvel stores with depth_chunk levels per chunk.

wvel stores downloaded by tracmass before 2026-10-08 hold each 1000 × 1000 tile as one 50-level chunk, so reading a few levels decompresses all 50. Each store is written next to the original, checked to hold identical values, and only then swapped in. Stores that already have depth_chunk levels per chunk are skipped.

Do not run it on days a tracking run reads at the same time: a run that opened a store before the swap fails to read it.

Parameters:
  • start (str or datetime-like) – First day.

  • end (str or datetime-like, optional) – Last day (inclusive). Default: start only.

  • depth_chunk (int, optional) – Levels per chunk. Default 10, as uvel/vvel.

  • path (str or os.PathLike, optional) – Rechunk this one store instead (for testing on a copy).

Returns:

list of pathlib.Path – The stores that were rewritten.

Raises:

RuntimeError – If a rewritten store differs from its original (which is then left untouched).

Return type:

list[Path]

seagrid.sources.model.glorys.calc_e3t(zgr)[source]#

Return the T-cell thickness of a NEMO grid with partial bottom cells.

Parameters:

zgr (xarray.Dataset) – A NEMO mesh_zgr file with e3t_0 (thickness of full cells), e3t_ps (thickness of the bottom cell) and mbathy (1-based level of the bottom cell, 0 on land).

Returns:

xarray.DataArray – (z, y, x) thickness in metres, 0 below the sea floor.

Return type:

DataArray