pycif.plugins.datastreams.fields.lmdz_ic — API reference

pycif.plugins.datastreams.fields.lmdz_ic — API reference#

Configuration reference: lmdz_ic plugin

pycif.plugins.datastreams.fields.lmdz_ic.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None)[source]#

Link the single LMDz restart file for the simulation start date.

Parameters:
  • ref_dir (str) – Path to the data.

  • ref_file (str) – File name format of the data.

  • input_interval (list[datetime.datetime]) – Date range; only the start date is used.

  • target_dir (str) – Where to link the data.

  • tracer – Unused.

  • component – Unused.

Returns:

tuple of single-entry dictionaries keyed by the simulation start date, describing the linked file and the (single-point) date interval it covers. Empty dicts if the original file is not found.

Return type:

(list_files, list_dates)

pycif.plugins.datastreams.fields.lmdz_ic.read.read(self, name, varnames, dates, files, tracer=None, **kwargs)[source]#

Read a species from an LMDz restart file into a pyCIF DataArray.

Resolves the variable name to read in the file, in order of precedence: varnames if given (for a non-perturbed species; raises if tracer.restart_id is also set), otherwise tracer.restart_id if set, otherwise the restart_id of the matching species in the chemical scheme (self.chemistry.acspecies). A numeric restart_id is turned into the conventional qNN variable name.

Parameters:
  • self – The field/tracer Plugin; self.chemistry.acspecies is used when no explicit restart_id/varnames is given.

  • name – Name of the component/species.

  • varnames – Explicit variable name to read; incompatible with tracer.restart_id unless name is a perturbed sample (contains "__sample#").

  • dates – List of date entries; only the first date is used as the output time coordinate.

  • files – List with a single restart file path.

  • tracer – Tracer/component configuration; may define restart_id.

  • **kwargs – Unused.

Returns:

A 4-dimensional (time, lev, lat, lon) array with a single time step.

Return type:

xarray.DataArray

Raises:
  • IllegalArgumentError – If both varnames and tracer.restart_id are given for a non-perturbed species.

  • CifTypeError – If varnames is given but is not a string.

  • CifValueError – If more than one file is given, or if the species is not found in the chemical scheme.

pycif.plugins.datastreams.fields.lmdz_ic.write.write(self, name, path, data, lmdz_version='std', metadata=None, **kwargs)[source]#

Write a restart/initial-condition variable to an AEMISSION-style CHIMERE-compatible NetCDF file.

Builds lat/lon coordinates (with bounds) from metadata['domain'] if given, adds a single-valued temps time coordinate (for compatibility with LMDZ std/OpenMPI), renames dimensions to LMDZ’s temps/sigs/rlatu/rlonv convention, and creates or appends to the target NetCDF file.

Parameters:
  • self (object) – this plugin.

  • name (str) – variable name to write.

  • path (str) – path to the target file to write.

  • data (xarray.DataArray) – data to write.

  • lmdz_version (str) – LMDZ plugin version, 'std' or 'acc' (currently unused in the body).

  • metadata – Optional dict with a "domain" entry, used to build the lat/lon coordinates; if absent, no horizontal coordinates are written.

  • **kwargs – Unused.

Raises:

CifTypeError – If data is not an xarray.DataArray.