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

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

Configuration reference: lmdz_outfields_nc plugin

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

Link monthly LMDz trajq files and build 3-hourly sub-intervals.

Iterates over dates spaced by tracer.file_freq across date_interval, links each existing monthly file into target_dir, and builds 3-hourly sub-intervals covering the whole month (8 per day).

Parameters:
  • ref_dir – Directory where the original files are found.

  • ref_file – Date-format pattern for the original file names.

  • date_interval – List of two dates, the beginning and end of the period to fetch.

  • target_dir – Directory where links to the original files are created.

  • tracer – Tracer/component configuration; tracer.file_freq gives the frequency at which monthly files are available.

  • component – Unused.

Returns:

A tuple (list_files, list_dates) of dictionaries keyed by monthly file date. list_dates maps each key to one 3-hourly [start, end] interval per 3-hour period of the month; list_files maps each key to the (repeated) path of that month’s file.

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

Build the pyCIF domain from an LMDz trajq reference file.

Opens the first fetched trajq input file, builds a cyclic regular lon-lat grid (with corner cells extended/wrapped at the poles and at +/-180 degrees) from its lon/lat variables, and reads hybrid vertical coefficients ap/bp from tracer.dir_vcoord/tracer.file_vcoord.

Parameters:
  • ref_dir – Unused directly (kept for interface consistency).

  • ref_file – Used only in the error message if no reference file is available.

  • input_interval – Unused directly (kept for interface consistency).

  • target_dir – Unused directly (kept for interface consistency).

  • tracer – Tracer/component configuration; tracer.input_files, tracer.dir_vcoord and tracer.file_vcoord are used.

Returns:

The domain built from the reference file’s horizontal grid and vertical coefficients, with lon_cyclic=True.

Return type:

pycif.utils.classes.domains.Domain

Raises:

CifError – If no reference trajq file is available.

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

Read a variable from LMDz trajq files into a pyCIF DataArray.

Opens each distinct file in files once, matches each requested date against the file’s time coordinate (since the file may cover a different month/year range than strictly requested), and stacks the selected (lev, lat, lon) slices into a single array.

Parameters:
  • self – The field/tracer Plugin.

  • name – Name of the component; used as fallback variable name.

  • varnames – Name of the variable to read; if empty, name is used instead.

  • dates – List of date entries to extract, matching files.

  • files – List of files matching dates; each distinct file is opened only once.

  • interpol_flx – Unused.

  • tracer – Unused.

  • model – Unused.

  • **kwargs – Unused.

Returns:

A 4-dimensional (time, lev, lat, lon) array.

Return type:

xarray.DataArray