lair.noaa.GMLData#

class lair.noaa.GMLData(specie, site, platform='surface', sample_type='flask', lab_id=1, measurement_group='ccgg', frequency='event', driver='pandas', gml_dir=None)[source]#

NOAA GML Data

One file of NOAA GML’s measurements of one gas at one site: every sample (frequency='event') or monthly means ('month').

Each parameter is also an attribute of the same name.

Parameters:
  • specie (str) – The greenhouse gas specie, in lower case as in NOAA’s file names ('ch4').

  • site (str) – The site where the flask samples were collected, its code in lower case ('uta').

  • platform (str, optional) – The platform where the flask samples were collected, by default ‘surface’.

  • sample_type (str, optional) – The sample type, by default ‘flask’. Use ‘pfp’ for Portable Flask Package data.

  • lab_id (int, optional) – The lab ID, by default 1.

  • measurement_group (str, optional) – The measurement group, by default ‘ccgg’.

  • frequency (str, optional) – The frequency of the measurements, by default ‘event’.

  • driver (str, optional) – The driver to use to read the data, by default ‘pandas’: a DataFrame from the .txt file, or 'xarray': a Dataset from the .nc file.

  • gml_dir (str, optional) – The NOAA GML data root, by default $LAIR_GML_DIR.

Variables:
  • directory (str) – The directory for the data.

  • filename (str) – The filename for the data.

  • filepath (str) – The filepath for the data.

  • file_template (str) – The template for the filename.

  • driver_ext (dict) – The driver extensions.

Notes

The file is read from, and download() saves it to, one folder per species and sample type in the data root. specie and site are names in the file name, so spell them as NOAA does, in lower case ('ch4', 'uta'):

$LAIR_GML_DIR/
  ch4/
    flask/
      ch4_uta_surface-flask_1_ccgg_event.txt
      ch4_uta_surface-flask_1_ccgg_month.txt
    pfp/
      ch4_mbo_surface-pfp_1_ccgg_event.txt

Each name is {specie}_{site}_{platform}-{sample_type}_{lab_id}_{measurement_group}_{frequency} and .txt for driver='pandas' or .nc for driver='xarray'. download() copies the file of that name from NOAA GML’s FTP server (/data/trace_gases/{specie}/{sample_type}/{platform}/{ext}/).

See also

GMLData.apply_qaqc

Keeps the samples with good flags.

CarbonTracker

NOAA’s model, for a background.

Examples

Making one reads nothing; it names the file:

>>> from lair.noaa import GMLData
>>> uta = GMLData("ch4", "uta", gml_dir="gml")
>>> uta.filepath.as_posix()
'gml/ch4/flask/ch4_uta_surface-flask_1_ccgg_event.txt'

Then uta.download() fetches it and uta.data reads it.

Attributes

data

The file's data, read once.

Methods

apply_qaqc(data[, flags, driver])

Apply QA/QC filtering.

download()

Download the file from NOAA GML's FTP server and return its path.