seagrid.sources.registry#

The registry of seagrid data sources.

Every DataSource subclass with a name is registered when its module is imported. The modules of the built-in sources are listed in BUILTIN_MODULES and imported on first use, so get_source("ostia") works without importing anything first.

Module Attributes

BUILTIN_MODULES

Module of each built-in source, imported when the source is first requested.

Functions

get_source(name[, variant])

Return a data source object.

list_sources()

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

register(cls)

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

source_class(name)

Return the class of a source.

seagrid.sources.registry.BUILTIN_MODULES: dict[str, str] = {'acspo': 'seagrid.sources.sst.acspo', 'avhrr': 'seagrid.sources.sst.ghrsst', 'bicep_cp': 'seagrid.sources.ocean_colour.carbon', 'bicep_poc': 'seagrid.sources.ocean_colour.carbon', 'cafe': 'seagrid.sources.pp.cafe', 'cmems_globgc': 'seagrid.sources.model.cmems_globgc', 'ecco2': 'seagrid.sources.model.ecco2', 'gebco': 'seagrid.sources.static.gebco', 'glorys': 'seagrid.sources.model.glorys', 'glorys_carb': 'seagrid.sources.model.glorys_carb', 'ifado': 'seagrid.sources.local', 'kd_cci': 'seagrid.sources.local', 'longhurst': 'seagrid.sources.static.longhurst', 'mercator12': 'seagrid.sources.local', 'mimoc': 'seagrid.sources.model.mimoc', 'modis_a': 'seagrid.sources.ocean_colour.modis', 'mur25': 'seagrid.sources.sst.ghrsst', 'oc_cci': 'seagrid.sources.ocean_colour.oc_cci', 'oc_cci_local': 'seagrid.sources.local', 'olci': 'seagrid.sources.ocean_colour.olci', 'ostia': 'seagrid.sources.sst.ostia', 'psm': 'seagrid.sources.local', 'scrippsgog': 'seagrid.sources.model.scrippsgog', 'seawifs': 'seagrid.sources.ocean_colour.seawifs', 'smoc': 'seagrid.sources.model.smoc', 'tiho_psd': 'seagrid.sources.ocean_colour.carbon', 'viirs': 'seagrid.sources.ocean_colour.viirs'}#

Module of each built-in source, imported when the source is first requested.

seagrid.sources.registry.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.registry.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.registry.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.registry.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]