seagrid.sources.families#
Intermediate source classes for each kind of data provider.
Class |
Used for |
|---|---|
NASA OB.DAAC L3 mapped ocean colour (MODIS, VIIRS, SeaWiFS, OLCI), downloaded with Earthdata login |
|
Copernicus Marine original files (OSTIA, SMOC, …) |
|
THREDDS/Hyrax OPeNDAP datasets cached locally |
|
Plain HTTP(S) servers with URL templates |
|
NASA Earthdata archives (PO.DAAC) with URL templates |
|
Files on a local or mounted disk (no download) |
Functions
|
Return the fields available to URL and file-name templates. |
|
Return the fields of URL, directory and file-name templates. |
Classes
|
Copernicus Marine products, as original files or as subsets. |
|
Files in a NASA Earthdata archive (PO.DAAC, ...), located by templates. |
|
Files on a plain HTTP(S) server, located by URL templates. |
|
Files on a local or mounted disk, located by templates; no download. |
|
NASA OB.DAAC Level-3 mapped products, one variable per file. |
|
Datasets read over OPeNDAP and cached locally as netCDF or Zarr. |
- class seagrid.sources.families.CopernicusSource(variant=None, **overrides)[source]#
Bases:
DataSourceCopernicus Marine products, as original files or as subsets.
Settings:
dataset_id,dataset_version(optional)The dataset.
filestampLocal file-name template with
{dtm}.filestamp_formatstrftime()format for{dtm}, default%Y%m%d.file_filterstrftime format of the server-side file filter, default
filestamp_format. It may contain wildcards, e.g."SMOC_%Y%m%d_R*"for files whose names include a run date; the matching server file is then stored under thefilestampname.method"files"(the default: download original files) or"subset"(write one Zarr store per time step withseagrid.download.copernicus.subset(), usingdata_varsanddepth_bounds).username,passwordOptional, in
.secrets.toml; default thecopernicusmarine logincredentials.
Any of
dataset_id,dataset_version,filestamp_formatandfile_filtermay be a table keyed by time type, for products with a separate dataset per time type:dataset_id = { daily = "..._P1D-m", monthly = "..._P1M-m" }
- Parameters:
variant (str | None)
overrides (Any)
- class seagrid.sources.families.EarthdataSource(variant=None, **overrides)[source]#
Bases:
HTTPSourceFiles in a NASA Earthdata archive (PO.DAAC, …), located by templates.
As
HTTPSource, but downloads with an Earthdata login (~/.netrcorEARTHDATA_USERNAME/EARTHDATA_PASSWORD) and checks availability in CMR. Extra setting:short_name, the CMR collection (e.g."MUR25-JPL-L4-GLOB-v04.2").- Parameters:
variant (str | None)
overrides (Any)
- class seagrid.sources.families.HTTPSource(variant=None, **overrides)[source]#
Bases:
DataSourceFiles on a plain HTTP(S) server, located by URL templates.
Settings:
host,remotedirandfilename, formatted withtemplate_fields()(e.g."/sst/{year}/{day_of_year:03}").If
archiveis set, the server has a ZIP archive of that name (also a template) inremotedir; it is downloaded, extracted into the data directory and removed, andfilenamenames the extracted member to open (e.g. one month of a climatology).- Parameters:
variant (str | None)
overrides (Any)
- class seagrid.sources.families.OBPGSource(variant=None, **overrides)[source]#
Bases:
DataSourceNASA OB.DAAC Level-3 mapped products, one variable per file.
Files are named by
seagrid.download.obpg.filename()and downloaded from the OB.DAACgetfileservice with an Earthdata login. Each resolution is kept in its own sub-directory ofdatadir.Settings:
sensor,resolutions,timetypes,data_vars,clim_years(for climatologies),nrt.- Parameters:
variant (str | None)
overrides (Any)
- class seagrid.sources.families.LocalSource(variant=None, **overrides)[source]#
Bases:
DataSourceFiles on a local or mounted disk, located by templates; no download.
Settings:
datadirandfilename, formatted withtemplate_fields()({year},{month:02},{timetype},{data_var}, …).filenamemay contain*and?wildcards; exactly one file must match.check_remote()reports whether the file exists, and a missing file raisesFileNotFoundErrornaming the path.- Parameters:
variant (str | None)
overrides (Any)
- local_path(dtm=None, data_var=None, *, timetype=None, resolution=None)[source]#
Return the path of the file of one time step (templated
datadir).
- datadir(timetype=None, resolution=None)[source]#
Return the fixed part of
datadir(before the first template field).
- download(dtm=None, data_var=None, *, timetype=None, resolution=None, force=False)[source]#
Return the local file; local sources have nothing to download.
- Raises:
FileNotFoundError – If the file is not there.
- Parameters:
- Return type:
- class seagrid.sources.families.OpendapSource(variant=None, **overrides)[source]#
Bases:
DataSourceDatasets read over OPeNDAP and cached locally as netCDF or Zarr.
Subclasses implement
_remote_url(). Settings:opendap_engine("netcdf4", the default, or"pydap").- Parameters:
variant (str | None)
overrides (Any)
- seagrid.sources.families.date_fields(dtm)[source]#
Return the fields available to URL and file-name templates.
- Parameters:
dtm (
pandas.Timestamp) – The time step.- Returns:
dict–dtm(the timestamp, usable as{dtm:%Y%m%d}),year,month,day,hour,day_of_year(ints) andyyyymmdd.- Return type:
Examples
>>> "{year}/{day_of_year:03}".format(**date_fields(pd.Timestamp("2020-02-01"))) '2020/032'
- seagrid.sources.families.template_fields(dtm, *, data_var=None, timetype=None)[source]#
Return the fields of URL, directory and file-name templates.
- Parameters:
dtm (
pandas.Timestamp)data_var (
str, optional)timetype (
str, optional)
- Returns:
dict– Thedate_fields()plusdata_varandtimetype(empty strings when not given).- Return type:
Examples
>>> f = template_fields(pd.Timestamp("2020-02-01"), timetype="monthly") >>> "{timetype}/{year}{month:02}".format(**f) 'monthly/202002'