seagrid.download.obpg#

File naming rules of NASA OB.DAAC Level-3 mapped products.

The Ocean Biology Distributed Active Archive Center names its L3 mapped files as:

<MISSION_SENSOR>.<period>.L3m.<code>.<suite>.<product>.<resolution>[.NRT].nc
AQUA_MODIS.20100101_20100131.L3m.MO.CHL.chlor_a.4km.nc

This module turns (dtm, data_var, timetype, sensor, resolution) into file names, download URLs and NASA CMR collection short names. It has no network code.

ivar SENSOR_PREFIX:

File-name prefix of each sensor.

vartype SENSOR_PREFIX:

dict

ivar CMR_PREFIX:

Prefix of the CMR collection short names of each sensor.

vartype CMR_PREFIX:

dict

ivar PRODUCTS:

data_var -> (suite, product).

vartype PRODUCTS:

dict

ivar TIMETYPE_CODE:

Canonical time type -> OB.DAAC period code.

vartype TIMETYPE_CODE:

dict

ivar GETFILE_URL:

Base URL for downloading a file by name.

vartype GETFILE_URL:

str

Functions

cmr_short_name(data_var[, sensor])

Return the NASA CMR collection short name of an L3 mapped product.

filename(dtm[, data_var, timetype, sensor, ...])

Return the OB.DAAC file name of an L3 mapped product.

period_string(dtm[, timetype, clim_years])

Return the period part of a file name.

product(data_var)

Return the (suite, product) names of a variable.

url(name)

Return the download URL of an OB.DAAC file.

seagrid.download.obpg.cmr_short_name(data_var, sensor='MODIS')[source]#

Return the NASA CMR collection short name of an L3 mapped product.

Parameters:
  • data_var (str) – Variable, a key of PRODUCTS.

  • sensor (str, optional) – A key of CMR_PREFIX. Default "MODIS".

Returns:

str – E.g. "MODISA_L3m_CHL".

Raises:

ValueError – If the sensor or variable has no known CMR collection.

Return type:

str

Examples

>>> cmr_short_name("par")
'MODISA_L3m_PAR'
seagrid.download.obpg.filename(dtm, data_var='chlor_a', timetype='daily', sensor='MODIS', resolution='4km', *, clim_years=None, nrt=False)[source]#

Return the OB.DAAC file name of an L3 mapped product.

Parameters:
  • dtm (str, pandas.Timestamp, numpy.datetime64 or datetime) – Any date in the period.

  • data_var (str, optional) – Variable, a key of PRODUCTS. Default "chlor_a".

  • timetype (str, optional) – "daily", "8day", "monthly" or "climatology" (or an alias such as "DAY" or "mo"). Default "daily".

  • sensor (str, optional) – A key of SENSOR_PREFIX. Default "MODIS" (Aqua).

  • resolution (str, optional) – "4km", "9km", … Default "4km".

  • clim_years ((int, int), optional) – First and last year of a climatology.

  • nrt (bool, optional) – Near-real-time file (.NRT.nc). Default False.

Returns:

str

Return type:

str

Examples

>>> filename("2010-01-15", "par", "mo")
'AQUA_MODIS.20100101_20100131.L3m.MO.PAR.par.4km.nc'
>>> filename("2023-03-15", "kd_490", "DAY", sensor="VIIRS", resolution="9km")
'SNPP_VIIRS.20230315.L3m.DAY.KD.Kd_490.9km.nc'
seagrid.download.obpg.period_string(dtm, timetype='daily', clim_years=None)[source]#

Return the period part of a file name.

Parameters:
  • dtm (str, pandas.Timestamp, numpy.datetime64 or datetime) – Any date in the period.

  • timetype (str, optional) – "daily", "8day", "monthly" or "climatology" (or an alias). Default "daily".

  • clim_years ((int, int), optional) – First and last year of a climatology. Required for "climatology".

Returns:

str – YYYYMMDD for daily files, YYYYMMDD_YYYYMMDD otherwise.

Raises:

ValueError – For "hourly"/"static", or a climatology without clim_years.

Return type:

str

Examples

>>> period_string("2010-02-11", "8day")
'20100210_20100217'
>>> period_string("2010-07-15", "climatology", clim_years=(2002, 2021))
'20020701_20210731'
seagrid.download.obpg.product(data_var)[source]#

Return the (suite, product) names of a variable.

Parameters:

data_var (str) – seagrid variable name, e.g. "chlor_a" or "kd_490".

Returns:

suite, product (str) – E.g. ("KD", "Kd_490").

Raises:

ValueError – If data_var is not in PRODUCTS.

Return type:

tuple[str, str]

seagrid.download.obpg.url(name)[source]#

Return the download URL of an OB.DAAC file.

Parameters:

name (str) – File name, as from filename().

Returns:

str

Return type:

str

Examples

>>> url("AQUA_MODIS.20100101.L3m.DAY.PAR.par.4km.nc")
'https://oceandata.sci.gsfc.nasa.gov/getfile/AQUA_MODIS.20100101.L3m.DAY.PAR.par.4km.nc'