seagrid.sources#

seagrid’s data sources: one interface for every product.

Every source is a DataSource with the same methods, whatever the provider: filename, local_path, remote_url, download, download_range, check_remote, downloaded, open_dataset, open_dataarray, open_mfdataset, grid, time_range, dtm_vec and describe.

Examples

>>> import seagrid
>>> seagrid.list_sources()
['acspo', 'modis_a', 'oc_cci', 'ostia']
>>> sst = seagrid.get_source("ostia")
>>> ds = sst.open_dataset("2010-06-01")
>>> monthly = sst.open_dataset("2010-06-01", timetype="monthly")
seagrid.sources.get_source(name, variant=None, **overrides)[source]#

Return a data source object.

Parameters:
  • name (str) – Source name or alias, e.g. "ostia" or "modis".

  • variant (str, optional) – Product variant, e.g. "nrt" (see the source’s variants).

  • **overrides – Settings that replace the configured ones for this object only, e.g. datadir="/scratch/ostia".

Returns:

DataSource

Return type:

DataSource

Examples

>>> import seagrid
>>> ostia = seagrid.get_source("ostia")
>>> ostia.name, ostia.timetypes
('ostia', ('daily', '8day', 'monthly'))
seagrid.sources.list_sources()[source]#

Return the names of all available data sources (without aliases).

Returns:

list of str – Sorted source names.

Return type:

list[str]

seagrid.sources.register(cls)[source]#

Add a source class to the registry under its name and aliases.

Called automatically for every DataSource subclass that sets name (pass register=False in the class statement to opt out).

Parameters:

cls (type) – The source class.

Returns:

type – cls, so this can be used as a decorator.

Raises:

ValueError – If another class is already registered under one of the names.

Return type:

type[DataSource]

seagrid.sources.source_class(name)[source]#

Return the class of a source.

Parameters:

name (str) – Source name or alias, e.g. "ostia" or "modis".

Returns:

type

Raises:

KeyError – If no source has that name.

Return type:

type[DataSource]

Modules

base

The DataSource base class: one interface for every data source.

families

Intermediate source classes for each kind of data provider.

local

Sources that read files from a local or mounted disk.

model

Ocean-model and reanalysis data sources.

module

Module-level access to a data source: from seagrid import ostia.

ocean_colour

Ocean-colour data sources.

pp

Primary-production data sources.

registry

The registry of seagrid data sources.

sst

Sea-surface-temperature data sources.

static

Static (time-invariant) data sources: bathymetry, regions.