lair.noaa.CarbonTracker#

class lair.noaa.CarbonTracker(version, carbon_tracker_directory=None, cache=True)[source]#

Bases: object

NOAA CarbonTracker

Parameters:
  • version (str)

  • carbon_tracker_directory (str | Path | None)

  • cache (bool)

specie#

The greenhouse gas specie.

Type:

Literal[‘ch4’, ‘co2’]

version#

The CarbonTracker version.

Type:

str

directory#

The directory for the version.

Type:

str

cache#

Whether to cache the data.

Type:

bool

get_specie_from_version(version)[source]#

Get the specie from the version.

Parameters:

version (str)

Return type:

Literal[‘ch4’, ‘co2’]

from_version(version, carbon_tracker_directory=None)[source]#

Create a CarbonTracker object from the version.

Parameters:
  • version (str)

  • carbon_tracker_directory (str | None)

download(sub_dirs=['fluxes', 'molefractions'], pattern=None)[source]#

Download CarbonTracker data from the NOAA GML FTP server.

Parameters:
units: Literal['ppb', 'ppm']#

Units of the molefraction field (‘ppb’ for CH4, ‘ppm’ for CO2)

static get_specie_from_version(version)[source]#

Get the specie from the version.

Parameters:

version (str) – The version of CarbonTracker data.

Returns:

Literal[‘ch4’, ‘co2’] – The specie.

Return type:

Literal[‘ch4’, ‘co2’]

static from_version(version, carbon_tracker_directory=None)[source]#

Create a CarbonTracker object from the version.

Parameters:
Returns:

CarbonTracker – The CarbonTracker object.

download(sub_dirs=('fluxes', 'molefractions'), pattern=None)[source]#

Download CarbonTracker data from the NOAA GML FTP server.

Parameters:
  • sub_dirs (list of str, optional) – The subdirectories to download data from, by default [‘fluxes’, ‘molefractions’]. If None, download the entire version data.

  • pattern (str, optional) – Only download matching files: a glob against the remote path if it has wildcards (e.g. '*2015-06*'), else a substring. By default None.

property molefractions_dir: Path#

Directory of the molefraction (concentration-field) files.

sample(points)[source]#

Sample the molefraction field at points.

points is a DataFrame with columns time (UTC sample time), lati, long, zagl; any other columns (e.g. indx, run_time) are carried through for downstream grouping. Returns one row per input point with ct_<specie>_<units> and the CT cell/level used. Points whose UTC date has no molefraction file are dropped.

Parameters:

points (DataFrame)

Return type:

DataFrame

background(points, by=None)[source]#

Background mole fraction [ppm]: mean of the sampled field over points.

Samples the field at every point (e.g. trajectory endpoints) and averages over them. With by (e.g. 'run_time') the mean and 1-sigma spread are returned per group; otherwise a single-row summary. Output is ppm (CT-CH4 mole fractions are stored in ppb, CO2 in ppm).

Parameters:
Return type:

DataFrame