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 credentialscommand andseagrid.download.credentials(status(),report()): which provider accounts are set up, without contacting any server.seagrid initprints 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, andLicense-Expression: MITin the package metadata).
2.5.0 (2026-11-30)#
Longhurst provinces on every grid, in two versions#
longhursthas two versions."2007"(the default): the 57 provinces of Longhurst (2007) from the 1/6° gridLonghurst_Regions_2007.nc, with the 2.x numbering (now inlonghurst.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 withpyshp); 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()andlonghurst_basins()(version=,fill=,cache=) on its own grid, cached likelandmask(). Ocean cells outside every province take the nearest one (fill=Falseto turn off).New
geospatial.rasterize(polygons on any grid, shapely),geospatial.sample_nearest(a regular field on any grid) andgeospatial.fill_nearest.shapelyandpyshpare 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.psmand the local sources now work after a plainimport seagrid.
Geographic fields on every source#
Every source has
lats(),lons(),dx(),dy(),area()(numpy),landmask()anddistance_from_land()(DataArrays, km), e.g.ostia.landmask(). Results are kept on the source object (_cache),cache=Falsecomputes without keeping anything, andclear_cache()forgets them. Land masks and distances are also stored as Zarr in<datadir>/geo/(settinggeodir), checked against a hash of the grid.Land comes from the source where it has its own (the GHRSST L4
maskof OSTIA, AVHRR OI and MUR; the missing cells of the gridded models;kmtof 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)anddistance_from_land(k)are cached the same way;distance_to_landstays as the tracmass name.New
geospatial.landmask_from_flagsandlandmask_from_elevation.Grid.lats/Grid.lonsof 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.ymlon pushes tomaster); project URLs inpyproject.toml.gebco: the file on CEDA isGEBCO_2024_CF.nc(lat, lon,elevationint16 m);GEBCO_2024.ncdoes not exist there.The source reference lists the logins of the Earthdata sources (
avhrr,mur25) and ofglorys(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 knownecco2andlonghurstoutages.
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) andscrippsgog(Scripps Gulf of Guinea MITgcm, HTTPS), ported fromtracmass.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 (setdatadir).sources.model.ocean_model.ModelSource:open_dataset(dtm)opens the velocities together (tracers=Trueadds temperature and salinity),fetch_daydownloads the missing variables of a day in parallel,download_rangeretries failed days and returns those that still failed, plusgrid_definition,landmask(k),distance_to_land(k)andmask_fill.seagrid.gcm.glorys(2.x) is now the same source asseagrid.glorys;seagridno longer imports it at start-up. The 2.xretrieveandbasedirare kept.geospatial.distance_to_mask(only coastal cells in the KD-tree, x periodic) andgeospatial.landmask_from_kmt. Distances next to the east/west seam of a global grid are now correct (tracmass’sdistance_to_landmissed land just across it).DataSourcehooks_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,earthaccessandpyhdfare still installed by default, but can be left out with uv’sexclude-dependencies(see Installation). seagrid then imports and every other source works; the sources that need a missing package raise anImportErrornaming it. They are imported only when a source uses them, andseagrid.download.optional.status()shows which are installed.keyringandkeyrings-cryptfileare 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’sBucketResampler(same result as the 2.xcoarsegrid, about six times faster) withstat="mean" | "sum" | "count" | "min" | "max";resample.BinResamplerreuses the bin indices over many fields.coarsegrid,kdqueryandCBIOMES_Global_HalfDegare 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 threecbiomes()copies.Matchworks 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). NewMatch.samplewithnei,days_behind/days_aheadandmax_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_missingand the history. A period that is not complete yet (it reaches past the source’s last date) raisesFileNotFoundErrorinstead of being cached half-built.New source members
regrid,matchandclimatology, soostia.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_gridconverts pyresample geometries, xarray objects, grid names and sources.seagrid.geospatial:landmask(islands removed withscipy.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.ll2ijmatched every observation one cell west of the right one;gebco.distance_balltreehalved longitudes and swapped latitude and longitude;Match.multidayreused the previous day’s data after anOSError;utils.vprintreferred to undefined settings;spherical_distignored its radius argument.Removed:
Match.get_balltreeandMatch.nearest_valid(example and unfinished code),geospatial.test, the emptyutils/landmask.py, and thescikit-learnandhaversinedependencies.utilsandgridtoolsnow wrapseagrid.grids.metrics.seagrid.sourcesexportsEarthdataSourceandLocalSource.
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.dtmdefaults to the first available date; for monthly, 8-day and climatology data any date in the period names the period.New families
EarthdataSourceandLocalSource; HTTP sources can unpack ZIP archives; Copernicus settings can differ per time type, filters may contain wildcards (SMOC run dates), andmethod = "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/raidpath); 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_settingsfollows changes ofSEAGRID_*environment variables and settings files (Dynaconf cached the first result).download.http.remote_existsraisesDownloadErrorfor server errors (5xx) instead of reporting the file missing; Copernicus errors are never empty and authentication failures raiseAuthenticationError.Removed:
seagrid.nasa,seagrid.gebco_climatologyandseagrid.download.obdaac(unused or broken).avhrr.cbiomes,ghrsst.cbiomesandgebco.all_cbiomesare gone until the generic climatology builder (phase 6);gebco.cbiomes,point_elevation,cell_area,areamaskanddistance_balltreeremain.No module writes to the working directory at import any more.
Settings are read from
/etc/seagrid,~/.config/seagrid,./seagrid.toml,./sg_*.tomland$SEAGRID_SETTINGS_FILE_FOR_DYNACONF, with a.secrets.tomlat each level. The package’ssettings.tomlis nowsettings_template.tomland holds no credentials.New
seagridcommand line:init,sources,config files|check|show.Tests are split into
quick,installandfulllevels (pytest --level).Importing seagrid no longer creates
./data_arraysor the SMOC data directory.Requires Python 3.11 or newer.
New
seagrid.gridspackage: theGridtype (coordinates, exact cell metrics, pyresamplegeometryandarea_defviews, subsetting, xarray wrapping) and the factoriesregular_latlon,nasa_l3,cbiomes_halfdeg,from_dataset,from_area_defandfrom_settings. The oldsetup_nasa_grid,setup_latlon_grid,setup_grid_from_latlon_vecsandCBIOMES_Global_HalfDeg.gridnow use it and return the same grids.New
seagrid.timetypes: canonical time-type names with aliases, plusperiod,period_startanddate_range.New
seagrid.typingwithDatetimeLikeandPathLike.One download layer in
seagrid.download:http.fetch(retries,.partialwrites, checksum and length checks, login-page detection), plusearthdata(session,fetch,search,exists),copernicus(get_files,subset,exists),opendap(open_remote,cache_dataset,retrieve, deferred parallel writes),obpg(OB.DAAC file naming) andcache. Failures raiseDownloadErrororAuthenticationError. The legacyhttp_server.retrieve,pydap.retrieve,obpg_filedata.generate_filenameand the earthdata functions now use it.OB.DAAC file names are fixed for 8-day products and for
kd_490,sst,poc,flh,zeuand the IOP products, which used the retired naming scheme.New
seagrid.sources: theDataSourcebase class and a registry (seagrid.get_source,seagrid.list_sources,seagrid.open_dataset). Every source hasfilename,local_path,remote_url,download,download_range,check_remote,downloaded,open_dataset,open_dataarray,open_mfdataset,grid,time_range,dtm_vecanddescribe. 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 withget_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.ostiaandseagrid.acspoexpose every member of their source (ostia.open_dataset,ostia.download_range,ostia.grid, …) and are reachable asseagrid.ostiaafterimport seagrid;ostia.source(variant="nrt")returns another variant.dtmis 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
DataSourcesignatures, so arguments afterdata_varare keyword-only (modis.filename(dtm, "par", timetype="monthly")),modis.open_datasetdefaults tochlor_ainstead ofpar,oc_cci.filenameincludes the.zarrsuffix of the cache file,dtm_vecis a method, andsetup_gridreturns aseagrid.grids.Grid(usable wherever the pyresample grid was).New CLI commands:
seagrid describe,download,check,downloaded.Settings:
timescalesis renamedtimetypes;[ostia-nrt]and[acspo-nrt]become[ostia.variants.nrt]and[acspo.variants.nrt]; new keysgrid,latency,time_ranges,progressandtimeout; 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 exclusivecopernicusmarinearguments.OSTIA longitudes are now the exact cell centres (2.0 spread 7200 points over -180…180). ACSPO
sstis returned in °C.New
seagrid.inventory(from tracmass_jax): SQLite record of downloaded files and a collapsed summary of which dates are cached.