seagrid.sources.module#
Module-level access to a data source: from seagrid import ostia.
Each built-in source has a module (seagrid.ostia, seagrid.modis,
…) whose attributes are those of the source object, so
>>> from seagrid import ostia
>>> ostia.filename("2010-06-01")
'20100601120000-UKMO-L4_GHRSST-SSTfnd-OSTIA-GLOB_REP-v02.0-fv02.0.nc'
is the same as seagrid.get_source("ostia").filename("2010-06-01").
The module attributes always reflect the current settings, so a changed
configuration environment (seagrid.config.change_env()) takes effect
at the next call. ostia.source(variant="nrt", datadir=...) returns a
separate source object for a variant or with overridden settings.
A source module is two lines:
from seagrid.sources.module import bind
__getattr__, __dir__, source = bind("ostia")
Functions
|
Return |
- seagrid.sources.module.bind(name, extra=())[source]#
Return
__getattr__,__dir__andsourcefor a source module.- Parameters:
- Returns:
getattr (
callable) – Module__getattr__delegating to the default source object.dir (
callable) – Module__dir__listing the source’s public members.source (
callable) –source(variant=None, **overrides), returning a new source object.
- Return type:
tuple[Callable[[str], Any], Callable[[], list[str]], Callable[…, DataSource]]
Notes
The default object is created on first use and kept while the source’s settings stay the same, so its cached grids are reused between calls.