seagrid.sources.model.scrippsgog#

Scripps Gulf of Guinea (GoG) regional MITgcm daily output (HTTPS files).

The run (GG_i001) is served as netCDF files, one per day and variable group, e.g. daily/GG_i001_2024-01-02_1day_UVEL_VVEL_top200m.nc, and cached unchanged in <datadir>/daily/<year>/.

Layout: an MITgcm C-grid on a regular 1/64° mesh (1376 × 385 T-cells, 11°W–10.5°E, 1–7°N). The velocity files cover the 320 T-cell rows 2–7°N and keep MITgcm’s staggered dimensions (uvel on (z, YC, XG), the west face of each T-cell; vvel on (z, YG, XC), the south face plus the northernmost north face) and their face metrics (dyG, dxG, drF) and open fractions (hFacW, hFacS). open_dataset(dtm) returns the whole velocity file.

There is no hFacC in the files. ScrippsGoG.grid_definition() rebuilds it from the binary Depth grid file and the layer thicknesses with MITgcm’s partial-cell rule (calc_hfac()), and checks it against the files’ hFacW/hFacS.

Examples

>>> from seagrid import scrippsgog
>>> ds = scrippsgog.open_dataset("2024-06-01")
>>> grid = scrippsgog.grid_definition()

Module Attributes

GRID_FILES

Binary MITgcm grid files (big-endian float32) under <product>/grid/.

Functions

calc_hfac(depth, drf[, hfac_min, hfac_min_dr])

Rebuild MITgcm's T-cell open fraction hFacC from the bathymetry.

calc_kmt_dzt(hfac, drf)

Return the number of open layers and the cell thickness from hFacC.

check_hfac(hfac_ext, ref[, atol])

Raise if a rebuilt hFacC disagrees with a file's hFacW/hFacS.

read_meta_shape(path)

Return the array shape (..., ny, nx) declared in an MITgcm .meta file.

Classes

ScrippsGoG([variant])

Scripps Gulf of Guinea regional MITgcm daily output (HTTPS).

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

Bases: ModelSource

Scripps Gulf of Guinea regional MITgcm daily output (HTTPS).

Settings ([scrippsgog]): host, product (PRELIM), run (i001), variables ({key: [file group, name in file]}), hfac_min (MITgcm’s partial-cell minimum fraction of the run) and delr_file (the layer-thickness file in grid/).

Parameters:
  • variant (str | None)

  • overrides (Any)

available_dates(data_var='uvel')[source]#

Return the dates the server has files for (from its directory listing).

Parameters:

data_var (str, optional) – Variable. Default "uvel".

Returns:

pandas.DatetimeIndex

Return type:

DatetimeIndex

open_dataset(dtm=None, data_var=None, *, tracers=False, **kwargs)[source]#

Open one day, downloading the file first if it is not cached.

Without data_var (and tracers), the whole velocity file: uvel, vvel and the face metrics. Other parameters as for ModelSource.open_dataset().

Parameters:
Return type:

Dataset

property griddir: Path#

Local directory of the binary MITgcm grid files.

retrieve_grid(force=False)[source]#

Download the binary MITgcm grid files (XC, YC, Depth, …).

Parameters:

force (bool, optional) – Download again even if cached. Default False.

Returns:

pathlib.Path – griddir.

Return type:

Path

read_grid_field(name)[source]#

Read one binary MITgcm grid field (XC, YC, Depth, RC).

Parameters:

name (str) – Field name; <name>.data and <name>.meta must be in griddir (see retrieve_grid()).

Returns:

numpy.ndarray – float32, (385, 1376) for 2-D fields.

Return type:

ndarray

seagrid.sources.model.scrippsgog.calc_hfac(depth, drf, hfac_min=0.2, hfac_min_dr=0.0)[source]#

Rebuild MITgcm’s T-cell open fraction hFacC from the bathymetry.

Parameters:
  • depth (numpy.ndarray) – Ocean depth (positive, m), (ny, nx); 0 on land.

  • drf (numpy.ndarray) – Layer thicknesses (m), (nz,), surface first.

  • hfac_min (float, optional) – MITgcm hFacMin and hFacMinDr.

  • hfac_min_dr (float, optional) – MITgcm hFacMin and hFacMinDr.

Returns:

numpy.ndarray – hFacC, float32 (nz, ny, nx), in [0, 1].

Return type:

ndarray

Notes

As MITgcm ini_masks_etc: the fraction of each layer above the sea floor is rounded to 0 below half the minimum size, and up to the minimum size below it.

Examples

>>> calc_hfac(np.array([[25.0]]), np.array([10.0, 10.0, 10.0]))[:, 0, 0]
array([1. , 1. , 0.5], dtype=float32)
seagrid.sources.model.scrippsgog.calc_kmt_dzt(hfac, drf)[source]#

Return the number of open layers and the cell thickness from hFacC.

Parameters:
Returns:

  • kmt (numpy.ndarray) – Number of open layers, int32 (ny, nx); 0 on land.

  • dzt (numpy.ndarray) – drf * hfac (partial bottom cells), float32 (nz, ny, nx).

Return type:

tuple[ndarray, ndarray]

seagrid.sources.model.scrippsgog.check_hfac(hfac_ext, ref, atol=1e-4)[source]#

Raise if a rebuilt hFacC disagrees with a file’s hFacW/hFacS.

MITgcm sets a face’s open fraction to the smaller of its two T-cells’.

Parameters:
  • hfac_ext (numpy.ndarray) – hFacC on the velocity rows plus one row on each side.

  • ref (xarray.Dataset) – A velocity file with hFacW and hFacS.

  • atol (float, optional) – Tolerance.

Raises:

ValueError – If they disagree by more than atol.

Return type:

None

seagrid.sources.model.scrippsgog.read_meta_shape(path)[source]#

Return the array shape (..., ny, nx) declared in an MITgcm .meta file.

Parameters:

path (str | Path)

Return type:

tuple[int, …]