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

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

Configuration reference: GCP_1x1 plugin

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

Fetch files and dates for GCP.

Builds candidate file dates at tracer.file_freq; for each existing file, reads its embedded time values and, if tracer.is_climato is set, shifts them from the file’s own year onto the target simulation year. An end-of-period date is appended, the resulting date intervals are filtered to the requested interval, and the file is linked 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

pycif.plugins.datastreams.fluxes.GCP_1x1.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.GCP_1x1.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, ddi=None, **kwargs)[source]#

Get fluxes from raw files and load them into a pyCIF variables.

For each requested date interval/file, opens the dataset and, if tracer.is_climato is set, shifts the file’s embedded time values from their own year onto the requested date’s year before selecting the matching time slice.

Parameters:
  • name (str) – name of the component

  • varnames (list[str]) – original names of variables to read; use name if varnames is empty

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

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

Returns:

the actual data with dimension:

time, levels, latitudes, longitudes

Return type:

xr.DataArray

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

Write flux to GCP template files.

Parameters:
  • self (Fluxes) – the Fluxes plugin

  • flx_file (str) – the file where to write fluxes

  • flx (xarray.Dataset) – fluxes data to write