pycif.plugins.datastreams.fluxes.GFEDv4 — API reference

pycif.plugins.datastreams.fluxes.GFEDv4 — API reference#

Configuration reference: GFEDv4 plugin

pycif.plugins.datastreams.fluxes.GFEDv4.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None, **kwargs)[source]#

Fetch files and dates for GFED4.

Builds candidate yearly file dates at tracer.file_freq; for each existing file, generates the sub-annual date pairs at the resolution matching tracer.temporal_fraction (monthly, daily, or 3-hourly for "diurnal") and links the file into target_dir.

Parameters:
  • ref_dir (str) – the path to the input files

  • ref_file (str) – format of the input files

  • input_interval (list) – simulation interval (start and end dates)

  • target_dir (str) – where to copy

  • tracer – the tracer Plugin, corresponding to the paragraph datavect/components/fluxes/parameters/my_species in the configuration yaml; can be needed to fetch extra information given by the user

  • component – the component Plugin, same as tracer; corresponds to the paragraph datavect/components/fluxes in the configuration yaml

Returns:

for each date that begins a period, an array containing

the names of the files that are available for the dates within this period

list_dates: for each date that begins a period, an array containing

the names of the dates matching the files listed in list_files

Return type:

list_files

Raises:

CifError – if tracer.temporal_fraction is not one of "monthly", "daily" or "diurnal".

pycif.plugins.datastreams.fluxes.GFEDv4.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#

Read information from the reference file to define the data horizontal and, if relevant, vertical domain.

Parameters:
  • ref_dir (str) – the path to the input files

  • ref_file (str) – format of the input files

  • input_interval (list) – simulation interval (start and end dates)

  • target_dir (str) – where to copy

  • tracer – the tracer Plugin, corresponding to the paragraph datavect/components/fluxes/parameters/my_species in the configuration yaml; can be needed to fetch extra information given by the user

Returns:

a domain class object, with the definition of the center grid

cells coordinates, as well as corners

Return type:

domain (Domain)

pycif.plugins.datastreams.fluxes.GFEDv4.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, ddi=None, **kwargs)[source]#

Get GFED4 fluxes, converted to trace-gas emissions, into a pyCIF array.

Loads the per-ecosystem emission-factor table from tracer.file_emisfactors for the requested species (defaulting to 1000 g/kgDM per ecosystem if not specified). For each requested date/file: reads the monthly dry-matter emissions (/emissions/MM/DM), converts them to a per-hour rate, computes a per-ecosystem contribution-weighted conversion factor from tracer.ecosystems and the per-source partitioning variables in the file, then applies daily and/or diurnal fractional scaling (depending on tracer.temporal_fraction) read from the HDF file. Latitude is flipped to match the domain built by get_domain.

Parameters:
  • self – the fluxes Plugin.

  • name (str) – name of the component.

  • varnames (str) – original name of the variable to read; name is used if varnames is empty.

  • dates (list) – list of the date intervals to extract.

  • files (list) – list of the files matching dates.

  • interpol_flx (bool) – unused, kept for interface compatibility.

  • tracer – the tracer Plugin, giving access to file_emisfactors, ecosystems and temporal_fraction.

  • model – unused, kept for interface compatibility.

  • ddi – unused, kept for interface compatibility.

  • **kwargs – unused, kept for interface compatibility.

Returns:

the flux data with dimensions (time, lev, lat, lon), in g-species/hour.

Return type:

xr.DataArray

Raises:
  • CifError – if the requested species is not found in the emission factor file, or if a required ecosystem in tracer.ecosystems has no matching emission factor.

  • CifKeyError – if a daily or diurnal fraction variable required by tracer.temporal_fraction is missing from the input file.

pycif.plugins.datastreams.fluxes.GFEDv4.write.write(self, name, flx_file, flx, mode='a', **kwargs)[source]#

Not implemented: writing GFED4 fluxes is not supported.

Raises:

CifError – always.