pycif.plugins.datastreams.backgrounds.tm5_background — API reference#
Configuration reference: tm5_background plugin
- pycif.plugins.datastreams.backgrounds.tm5_background.fetch.fetch(ref_dir, ref_file, date_interval, target_dir, tracer=None, **kwargs)[source]#
Locate TM5-4DVAR annual background files and link them to the working directory.
The requested date interval is expanded to cover full calendar years, and one yearly-formatted file name (
ref_fileformatted with the year’s start date) is checked per year. Each existing file is symlinked intotarget_dirand opened to read its time stamps (tracer.time_varname), from which hourly[t, t + 1h]date pairs are built.- Parameters:
ref_dir – directory holding the TM5-4DVAR background files.
ref_file – strftime-style file name pattern (relative to
ref_dir), formatted once per calendar year.date_interval – 2-element sequence
(datei, datef)giving the requested date range.target_dir – directory where matching files are symlinked.
tracer – the background datastream Plugin, used for
tracer.time_varname.
- Returns:
(list_files, list_dates), dicts keyed by each year’s start date.list_filesmaps each key to a list of the (single, repeated) linked file path, one entry per time stamp found in the file;list_datesmaps each key to the corresponding list of[t, t + 1h]date pairs. Years without an existing file are simply absent from both dicts.- Return type:
tuple
- pycif.plugins.datastreams.backgrounds.tm5_background.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, **kwargs)[source]#
Read TM5-4DVAR background concentrations into a pyCIF datastore.
Iterates over the unique files referenced in
files; for each new file, decodes the station-ID variable (tracer.id_varname) into station/network/agl (above-ground-level) components, reads the time stamps (tracer.time_varname) and the simulated-concentration array (self.varname), meshes stations against time stamps, and packs the result into an empty pyCIF datastore.Note
Only the datastore built from the last (in iteration order) distinct file in
filesis returned:dsis reassigned on each new file rather than accumulated/concatenated across files.- Parameters:
self – the background datastream Plugin.
name – name of the observed parameter/component.
varnames – unused (kept for interface consistency with other datastream
readfunctions).dates – list of
[start, end]date pairs, aligned withfiles.files – list of TM5-4DVAR annual background files, aligned with
dates. Consecutive duplicate entries are only read once.interpol_flx (bool) – unused here (kept for interface consistency).
tracer – the background tracer, used for
id_varname,time_varnameand thenumscalescaling factor.model – unused here (kept for interface consistency).
- Returns:
pyCIF datastore (as built by
init_empty) for the last file processed, withdate,station,network,parameteranddurationmetadata columns, andobserror/specmain-data columns.- Return type:
pandas.DataFrame
- pycif.plugins.datastreams.backgrounds.tm5_background.write.write(self, prescr_file, prescr, typefile, mode='a', **kwargs)[source]#
Write prescribed species background fields for LMDZ.
- Parameters:
self (Fluxes) – the Fluxes plugin.
prescr_file (str) – the file where to write the prescribed field.
prescr (xarray.Dataset) – prescribed species data to write. For
typefile == "bin", must expose"fwd"and"tl"data variables.typefile (str) – output format, either
"bin"for a raw binary file (fwd/tlarrays transposed and dumped withtofile) or"nc"for a NETCDF3_CLASSIC file.mode (str) – unused; kept for interface consistency. NetCDF output is always merged into any existing file, since xarray’s append mode is not supported here.