Changelog#

2.5.2 (2026-12-01)#

  • New credentials guide (docs/getting_started/credentials.md), with a section per provider (Copernicus Marine, NASA Earthdata, Mercator Ocean) and the sources that need no account (OC-CCI and all others).

  • New seagrid credentials command and seagrid.download.credentials (status(), report()): which provider accounts are set up, without contacting any server. seagrid init prints the same check and warns when an account is missing.

  • README rewritten after the readme-best-practices template.

2.5.1 (2026-11-30)#

  • seagrid is released under the MIT license (LICENSE, and License-Expression: MIT in the package metadata).

2.5.0 (2026-11-30)#

Longhurst provinces on every grid, in two versions#

  • longhurst has two versions. "2007" (the default): the 57 provinces of Longhurst (2007) from the 1/6° grid Longhurst_Regions_2007.nc, with the 2.x numbering (now in longhurst.PROVINCES_2007; the file’s codes 1-22, 30-37, 50-72 and 80-83). Its server is gone and no other is known, so the file must be copied into the data directory; the full tests list it as unavailable. Variant "1995": the 54 initial static boundaries as polygons, downloaded as GeoJSON from the Marine Regions WFS (VLIZ) or the same shapefile from SAERI (read with pyshp); using it warns, because its provinces and numbers differ. On OSTIA’s grid the two versions give the same basin on 99.2% of the ocean.

  • The file’s codes are mapped to province numbers by an explicit table (longhurst.RAW_CODES_2007) instead of by rank, as in 2.x; the numbers are the same.

  • Every source has longhurst_provinces(), longhurst_biomes() and longhurst_basins() (version=, fill=, cache=) on its own grid, cached like landmask(). Ocean cells outside every province take the nearest one (fill=False to turn off).

  • New geospatial.rasterize (polygons on any grid, shapely), geospatial.sample_nearest (a regular field on any grid) and geospatial.fill_nearest. shapely and pyshp are dependencies (shapely was already installed through pyresample).

  • seagrid.gebco, seagrid.longhurst, seagrid.mimoc, seagrid.tiho_psd, seagrid.bicep_cp, seagrid.bicep_poc, seagrid.cafe, seagrid.psm and the local sources now work after a plain import seagrid.

Geographic fields on every source#

  • Every source has lats(), lons(), dx(), dy(), area() (numpy), landmask() and distance_from_land() (DataArrays, km), e.g. ostia.landmask(). Results are kept on the source object (_cache), cache=False computes without keeping anything, and clear_cache() forgets them. Land masks and distances are also stored as Zarr in <datadir>/geo/ (setting geodir), checked against a hash of the grid.

  • Land comes from the source where it has its own (the GHRSST L4 mask of OSTIA, AVHRR OI and MUR; the missing cells of the gridded models; kmt of the tracmass models), and from GEBCO otherwise (geospatial.landmask_from_elevation: land fraction > 0.5, one dask pass over GEBCO). On OSTIA’s grid the two agree on 99.3% of cells.

  • The model sources’ landmask(k) and distance_from_land(k) are cached the same way; distance_to_land stays as the tracmass name.

  • New geospatial.landmask_from_flags and landmask_from_elevation. Grid.lats/Grid.lons of rectilinear grids are broadcast views (no memory).

Phase 8: docs and the full-level run#

  • Published at https://brorfred.github.io/seagrid/ (GitHub Pages, from .github/workflows/docs.yml on pushes to master); project URLs in pyproject.toml.

  • gebco: the file on CEDA is GEBCO_2024_CF.nc (lat, lon, elevation int16 m); GEBCO_2024.nc does not exist there.

  • The source reference lists the logins of the Earthdata sources (avhrr, mur25) and of glorys (Mercator Ocean, ~/.netrc); the settings reference has the model-source keys; README and installation page updated.

  • Full-level run on 2026-11-22 (no large downloads): 681 passed. Not passing, outside seagrid: cmems_globgc (the Copernicus password the user’s settings give this source is refused, the other Copernicus sources log in), tiho_psd (Pangaea answers HTTP 503 with Retry-After), and the known ecco2 and longhurst outages.

Phase 7: ocean-model readers from tracmass_jax#

  • New sources glorys (GLORYS12v1 on the Mercator THREDDS server, OPeNDAP, login in ~/.netrc), ecco2 (ECCO2 cube92 on APDRC, OPeNDAP) and scrippsgog (Scripps Gulf of Guinea MITgcm, HTTPS), ported from tracmass.seagrid. They return the same data, chunks and coordinates as the tracmass readers, and use the same cache layout, file names and inventory, so existing caches work unchanged (set datadir).

  • sources.model.ocean_model.ModelSource: open_dataset(dtm) opens the velocities together (tracers=True adds temperature and salinity), fetch_day downloads the missing variables of a day in parallel, download_range retries failed days and returns those that still failed, plus grid_definition, landmask(k), distance_to_land(k) and mask_fill.

  • seagrid.gcm.glorys (2.x) is now the same source as seagrid.glorys; seagrid no longer imports it at start-up. The 2.x retrieve and basedir are kept.

  • geospatial.distance_to_mask (only coastal cells in the KD-tree, x periodic) and geospatial.landmask_from_kmt. Distances next to the east/west seam of a global grid are now correct (tracmass’s distance_to_land missed land just across it).

  • DataSource hooks _relpath (subdirectories, e.g. per year), _cache_var (the variable’s name in the cached file) and _vars_in_file (every variable a downloaded file holds is recorded in the inventory); opendap.open_remote(timeout=...).

  • Clean install: copernicusmarine, earthaccess and pyhdf are still installed by default, but can be left out with uv’s exclude-dependencies (see Installation). seagrid then imports and every other source works; the sources that need a missing package raise an ImportError naming it. They are imported only when a source uses them, and seagrid.download.optional.status() shows which are installed.

  • keyring and keyrings-cryptfile are no longer dependencies; nothing used them.

Phase 6: resampling, matching and climatologies on Grid#

  • seagrid.regrid(obj, grid, method="bin" | "nearest") resamples any xarray object onto any grid, keeping leading dimensions. Binning uses pyresample’s BucketResampler (same result as the 2.x coarsegrid, about six times faster) with stat="mean" | "sum" | "count" | "min" | "max"; resample.BinResampler reuses the bin indices over many fields. coarsegrid, kdquery and CBIOMES_Global_HalfDeg are kept for 2.x code.

  • seagrid.climatology.build(source, data_var, grid=..., stat=...) builds a cached monthly climatology of any source on any grid (default CBIOMES 0.5°). It replaces the three cbiomes() copies.

  • Match works with sources, source names and source modules as well as 2.x modules and callables. Observations are grouped by the source’s time step (one open per month for monthly data). New Match.sample with nei, days_behind/days_ahead and max_distance. Distances are great-circle distances (no more lon/lat KD-tree), and missing time steps are logged instead of printed.

  • Means derived from finer files (8-day, monthly) skip missing files with a warning instead of failing, and record the number used and the dates skipped in seagrid_n_files, seagrid_missing and the history. A period that is not complete yet (it reaches past the source’s last date) raises FileNotFoundError instead of being cached half-built.

  • New source members regrid, match and climatology, so ostia.match(df.lon, df.lat, df.index) works.

  • Grid.nearest(lon, lat, k): the cell containing each point (regular grids) or the nearest cell centres on the sphere; grids.as_grid converts pyresample geometries, xarray objects, grid names and sources.

  • seagrid.geospatial: landmask (islands removed with scipy.ndimage), distance_from_land (on the sphere, correct across the antimeridian), cell_area, area_weighted_mask, global_land_mask. The GEBCO helpers (distance_balltree, cell_area, areamask, cbiomes) wrap them.

  • Fixed: pp.read_pp.ll2ij matched every observation one cell west of the right one; gebco.distance_balltree halved longitudes and swapped latitude and longitude; Match.multiday reused the previous day’s data after an OSError; utils.vprint referred to undefined settings; spherical_dist ignored its radius argument.

  • Removed: Match.get_balltree and Match.nearest_valid (example and unfinished code), geospatial.test, the empty utils/landmask.py, and the scikit-learn and haversine dependencies. utils and gridtools now wrap seagrid.grids.metrics.

  • seagrid.sources exports EarthdataSource and LocalSource.

Phase 5: every source on the common interface#

  • All sources are DataSources with a module each: VIIRS (and NOAA-20), SeaWiFS, OLCI (S3A and S3B), SMOC, CMEMS BGC, GLORYS carbon, AVHRR OI (v2.1, and v2.0 back to 1981), MUR25 (seagrid.ghrsst), MIMOC, GEBCO, Longhurst, TiHo PSD, BICEP POC and carbon, CAFE, and the local-disk sources iFADO/S05, PSM, OC-CCI local, Kd-CCI and Mercator 1/12°. seagrid.list_sources() lists 29.

  • dtm defaults to the first available date; for monthly, 8-day and climatology data any date in the period names the period.

  • New families EarthdataSource and LocalSource; HTTP sources can unpack ZIP archives; Copernicus settings can differ per time type, filters may contain wildcards (SMOC run dates), and method = "subset" writes Zarr.

  • Fixed configuration, checked against the archives: MODIS-Aqua runs 2002-07-04 – 2026-05-30 (was 2023 only); VIIRS from 2012 ([viirs] used the MODIS section); SeaWiFS 1997-09-04 – 2010-12-11, 9 km only; CMEMS BGC dataset IDs (..._0.25deg_...) and range to 2026; SMOC from 2022-05 with run-dated file names; GLORYS carbon reads the original files (no fixed /data/raid path); AVHRR and MUR25 come from PO.DAAC (the NCEI and PO.DAAC OPeNDAP paths are retired or throttled); GEBCO 2024 from CEDA.

  • Settings sections renamed to the source names: [cmems_globgc] (was [cmems-globgc] and [cmems-globgc-monthly]), [tiho_psd], [oc_cci_local]. Credentials in the old section names are still read.

  • config.source_settings follows changes of SEAGRID_* environment variables and settings files (Dynaconf cached the first result).

  • download.http.remote_exists raises DownloadError for server errors (5xx) instead of reporting the file missing; Copernicus errors are never empty and authentication failures raise AuthenticationError.

  • Removed: seagrid.nasa, seagrid.gebco_climatology and seagrid.download.obdaac (unused or broken). avhrr.cbiomes, ghrsst.cbiomes and gebco.all_cbiomes are gone until the generic climatology builder (phase 6); gebco.cbiomes, point_elevation, cell_area, areamask and distance_balltree remain.

  • No module writes to the working directory at import any more.

  • Settings are read from /etc/seagrid, ~/.config/seagrid, ./seagrid.toml, ./sg_*.toml and $SEAGRID_SETTINGS_FILE_FOR_DYNACONF, with a .secrets.toml at each level. The package’s settings.toml is now settings_template.toml and holds no credentials.

  • New seagrid command line: init, sources, config files|check|show.

  • Tests are split into quick, install and full levels (pytest --level).

  • Importing seagrid no longer creates ./data_arrays or the SMOC data directory.

  • Requires Python 3.11 or newer.

  • New seagrid.grids package: the Grid type (coordinates, exact cell metrics, pyresample geometry and area_def views, subsetting, xarray wrapping) and the factories regular_latlon, nasa_l3, cbiomes_halfdeg, from_dataset, from_area_def and from_settings. The old setup_nasa_grid, setup_latlon_grid, setup_grid_from_latlon_vecs and CBIOMES_Global_HalfDeg.grid now use it and return the same grids.

  • New seagrid.timetypes: canonical time-type names with aliases, plus period, period_start and date_range.

  • New seagrid.typing with DatetimeLike and PathLike.

  • One download layer in seagrid.download: http.fetch (retries, .partial writes, checksum and length checks, login-page detection), plus earthdata (session, fetch, search, exists), copernicus (get_files, subset, exists), opendap (open_remote, cache_dataset, retrieve, deferred parallel writes), obpg (OB.DAAC file naming) and cache. Failures raise DownloadError or AuthenticationError. The legacy http_server.retrieve, pydap.retrieve, obpg_filedata.generate_filename and the earthdata functions now use it.

  • OB.DAAC file names are fixed for 8-day products and for kd_490, sst, poc, flh, zeu and the IOP products, which used the retired naming scheme.

  • New seagrid.sources: the DataSource base class and a registry (seagrid.get_source, seagrid.list_sources, seagrid.open_dataset). Every source has filename, local_path, remote_url, download, download_range, check_remote, downloaded, open_dataset, open_dataarray, open_mfdataset, grid, time_range, dtm_vec and describe. Coarser time types are computed as NaN-aware means (monthly and 8-day from daily files) and cached. Bounding boxes from the settings apply to every source. Product variants are chosen with get_source(name, variant="nrt").

  • MODIS-Aqua, OC-CCI, OSTIA and ACSPO are the first sources on the new interface. The modules seagrid.modis, seagrid.oc_cci, seagrid.ostia and seagrid.acspo expose every member of their source (ostia.open_dataset, ostia.download_range, ostia.grid, …) and are reachable as seagrid.ostia after import seagrid; ostia.source(variant="nrt") returns another variant.

  • dtm is optional: ostia.open_dataset() opens the first available date (the first rather than the latest, so it is downloaded once and stays cached).

  • Changed: module functions now take the DataSource signatures, so arguments after data_var are keyword-only (modis.filename(dtm, "par", timetype="monthly")), modis.open_dataset defaults to chlor_a instead of par, oc_cci.filename includes the .zarr suffix of the cache file, dtm_vec is a method, and setup_grid returns a seagrid.grids.Grid (usable wherever the pyresample grid was).

  • New CLI commands: seagrid describe, download, check, downloaded.

  • Settings: timescales is renamed timetypes; [ostia-nrt] and [acspo-nrt] become [ostia.variants.nrt] and [acspo.variants.nrt]; new keys grid, latency, time_ranges, progress and timeout; dates may be "today" or relative ("-720D").

  • Fixed configuration found by the new full tests: OSTIA NRT uses dataset METOFFICE-GLO-SST-L4-NRT-OBS-SST-V2 (a rolling two-year archive), the ACSPO NRT archive covers the last year, the ACSPO reanalysis lags about two months, and OC-CCI has no global 1 km product at the configured URLs.

  • Fixed copernicus.get_files, which passed mutually exclusive copernicusmarine arguments.

  • OSTIA longitudes are now the exact cell centres (2.0 spread 7200 points over -180…180). ACSPO sst is returned in °C.

  • New seagrid.inventory (from tracmass_jax): SQLite record of downloaded files and a collapsed summary of which dates are cached.