pycif.plugins.datastreams.meteos.tm5_meteo — API reference

pycif.plugins.datastreams.meteos.tm5_meteo — API reference#

Configuration reference: tm5_meteo plugin

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

Link individual TM5 meteo files to the working directory (original implementation).

Superseded by fetch() below, which copies the whole meteo directory tree instead. For each month spanned by input_interval and each of a fixed set of file categories/prefixes (albedo/sr/veg under an0tr1; blh/ci/cp under h06h18tr1; cld/convec/mfw under h06h18tr3), links the individual source file (named via component.dir_<filedir>) into target_dir. A missing source file is silently skipped (only debug-logged).

Parameters:
  • ref_dir – directory holding the TM5 meteo subdirectories.

  • ref_file – unused (kept for interface consistency).

  • input_interval – mapping of period-start dates to the list of dates within each period; only its dates are used, expanded to the first of each covered month.

  • target_dir – directory where matching files are symlinked.

  • tracer – unused (kept for interface consistency).

  • component – object exposing dir_an0tr1/dir_h06h18tr1/ dir_h06h18tr3 attributes giving the sub-path (under ref_dir) of each file category.

Returns:

(list_files, list_dates), both dicts keyed by the keys of input_interval and mapping to empty lists — this implementation does not report the dates/files it actually linked.

Return type:

tuple

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

Link the whole TM5 meteo directory tree to the working directory.

Clears target_dir, then bulk-copies the ref_dir tree into it with cp -Rsn (directory names are recreated, files become symlinks; -n avoids errors on already-existing targets).

Note

Version history: 2.0 (17-05-2021, J.C.A. van Peet) replaced the original per-file linking implementation (fetch_AB above, 1.0, 28-04-2021, A. Berchet) with this bulk directory copy.

Parameters:
  • ref_dir – directory holding the TM5 meteo directory tree to copy.

  • ref_file – unused (kept for interface consistency).

  • input_interval – 2-element sequence (ddi, ddf) giving the requested date range.

  • target_dir – directory where the meteo tree is copied as symlinks; cleared before copying.

  • tracer – unused (kept for interface consistency).

  • component – unused (kept for interface consistency).

Returns:

(list_files, list_dates). list_files is a dict with a single key (ddi) mapping to an empty list. list_dates maps that same key to an array of consecutive monthly [start, end] date pairs spanning (ddi, ddf).

Return type:

tuple

Raises:

CifRuntimeError – if the cp -Rsn subprocess exits with a non-zero return code.

pycif.plugins.datastreams.meteos.tm5_meteo.read.read_AB(self, name, tracdir, tracfile, varnames, dates, interpol_flx=False, tracer=None, model=None, filetypes=['defstoke', 'fluxstoke', 'fluxstokev', 'phystoke'], **kwargs)[source]#

Cache the LMDZ-style physics time step from a defstoke file (original implementation).

Superseded by read() below, which is a non-functional placeholder. For each date and file type, builds the expected <filetype>.an<year>.m<month>.nc path in tracdir (falling back to <filetype>.nc if the dated file is missing) and, for filetype == "defstoke", reads dtvr/istdyn from it the first time to compute and cache self.offtstep. This appears to be LMDZ mass-flux bookkeeping logic carried over and not actually applicable to reading TM5 meteo.

Parameters:
  • self – the meteo datastream Plugin (receives the cached offtstep attribute).

  • name – unused (kept for interface consistency).

  • tracdir – directory holding the meteo files.

  • tracfile – unused (kept for interface consistency).

  • varnames – unused (kept for interface consistency).

  • dates – list of dates to build file paths for.

  • interpol_flx (bool) – unused (kept for interface consistency).

  • tracer – unused (kept for interface consistency).

  • model – unused (kept for interface consistency).

  • filetypes ([str]) – file-type radicals to iterate over; only "defstoke" triggers any actual processing.

Returns:

None. self.offtstep is set as a side effect, once.

pycif.plugins.datastreams.meteos.tm5_meteo.read.read(self, name, tracdir, tracfile, varnames, dates, interpol_flx=False, tracer=None, model=None, filetypes=['defstoke', 'fluxstoke', 'fluxstokev', 'phystoke'], **kwargs)[source]#

Placeholder: reading TM5 meteo is not implemented.

Always logs a critical error and terminates the process via sys.exit(); it never returns a value to the caller. Kept only to satisfy the meteo datastream plugin interface.

Note

Version history: 2.0 (17-05-2021, J.C.A. van Peet) replaced the original read_AB implementation (above, 1.0, 28-04-2021, A. Berchet) with this placeholder.

Parameters:
  • self – the meteo datastream Plugin.

  • name – unused.

  • tracdir – unused.

  • tracfile – unused.

  • varnames – unused.

  • dates – unused.

  • interpol_flx (bool) – unused.

  • tracer – unused.

  • model – unused.

  • filetypes ([str]) – unused.

Raises:

SystemExit – always; a CifRuntimeError is raised internally, caught, logged critically, and followed by sys.exit().