# Ocean models on their own grids GLORYS12 (`seagrid.glorys`), ECCO2 cube92 (`seagrid.ecco2`) and the Scripps Gulf of Guinea MITgcm run (`seagrid.scrippsgog`) give daily velocities, temperature and salinity on the model grid, with the cell metrics needed to turn velocities into volume fluxes. tracmass reads its velocities through them. ```python from seagrid import glorys glorys.check_auth() # login in ~/.netrc ds = glorys.open_dataset("2010-06-01") # uvel, vvel, wvel ds = glorys.open_dataset("2010-06-01", tracers=True) # + temp, salt temp = glorys.open_dataarray("2010-06-01", "temp") grid = glorys.grid_definition() # dxv, dyu, dxdy, dzt, kmt land = glorys.landmask() # True on land (kmt == 0) dist = glorys.distance_from_land() # km, great circle lats, area = glorys.lats(), glorys.area() # T-cell centres, m² ``` `landmask(k)` and `distance_from_land(k)` take a 1-based model level (deeper, the sea floor counts as land) and are stored in `/geo/`. `distance_to_land` is the same as `distance_from_land` (the tracmass name). ## Downloading `open_dataset` downloads what is missing. Without `data_var` it opens the velocities together and fetches the missing files of the day in parallel (`fetch_day`). For a long period, use `download_range`, which skips days already cached, tries a failed day again (`retries`, `retry_wait`) and returns the days that still failed, so it can simply be started again: ```python failed = glorys.download_range("2010-01-01", "2010-12-31") failed = glorys.download_range("2010-01-01", "2010-12-31", data_vars=["temp", "salt"]) glorys.downloaded("2010-01-01", "2010-12-31") # summary of the cache ``` Each day and variable is one Zarr store (GLORYS, ECCO2) or the original netCDF file (GoG) in `//`. Downloads are written under a `.partial` name and moved into place when complete, so an interrupted download never looks cached. GLORYS needs a Mercator Ocean account. Add it to `~/.netrc`: ```text machine tds.mercator-ocean.fr login password ``` and make the file private (`chmod 600 ~/.netrc`). `glorys.check_auth()` says what is wrong if the login fails. ## Layout Model data keep the model's own layout, unlike seagrid's gridded products: | Source | Grid | One variable | Velocities together | |---|---|---|---| | `glorys` | NEMO ORCA12 C-grid, 1/12° | `(deptht or depthw, y, x)`, coordinates `lat_u`/`lon_u` (`_v`, `_w`, `_t`, `_s`) | `(z, y, x)` | | `ecco2` | regular 0.25°, -180–180 | `(z, y, x)`, 1-D `z`, `y` (latitude), `x` (longitude) | `(z, y, x)` | | `scrippsgog` | MITgcm C-grid, 1/64°, 11°W–10.5°E, 2–7°N | as in the file | the whole velocity file: `uvel` on `(z, YC, XG)`, `vvel` on `(z, YG, XC)`, `drF`, `dyG`, `dxG`, `hFacW`, `hFacS` | `grid_definition()` is on the T-cells and has `dxv` (width of the north face), `dyu` (height of the east face), `dxdy` (area), `dzt` (thickness, 0 below the sea floor) and `kmt` (number of ocean levels, 0 on land). It is built once and cached in the data directory: GLORYS from the NEMO mesh files (`mesh_hgr`, `mesh_zgr` settings), ECCO2 from the coordinates and the land pattern of one `uvel` field, GoG from the binary MITgcm grid files and the partial-cell rule, checked against the files' `hFacW`/`hFacS`. GLORYS velocities hold the netCDF fill value in land cells. `open_dataset` replaces it (velocities 0, tracers NaN) unless `mask=False`; then call `glorys.mask_fill(da)` on the part you keep, which is several times faster for a small region. ## Settings The data directories default to `/mercator/glorys12v1`, `/ecco2/cube92_daily` and `/scrippsgog/PRELIM`. To use an existing cache, set `datadir` in your own `seagrid.toml`: ```toml [glorys] datadir = "/data/raid/mercator/glorys12v1" [ecco2] datadir = "/data/raid/ecco2/cube92_daily" [scrippsgog] datadir = "/data/raid/scrippsgog/PRELIM" ```