pycif.plugins.datastreams.fluxes.chimere — API reference#
Configuration reference: chimere plugin
- pycif.plugins.datastreams.fluxes.chimere.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
Fetch CHIMERE AEMISSIONS/BEMISSIONS files covering the interval.
Builds a date range at
tracer.file_freq, links each existing per-period file intotarget_dirwith hourly sub-dates. If the linked file declares abottom_topdimension different from the domain’s current number of levels,tracer.domainis rebuilt with the file’s vertical level count (horizontal geometry copied as-is, sigma coefficients truncated to the new number of levels).- Parameters:
ref_dir (str) – directory where the original files are found.
ref_file (str) – (template) name of the original files.
input_interval (list) – simulation interval, as a list of the two bounding dates.
target_dir (str) – directory where links to the original files are created.
tracer – the tracer Plugin, giving access to
file_freq,nameanddomain.**kwargs – unused, kept for interface compatibility.
- Returns:
list_filesandlist_dates.- list_files: for each date that begins a period, a list containing
the names of the files that are available for the dates within this period.
- list_dates: for each date that begins a period, a list containing
the date intervals matching the files listed in
list_files.
- Return type:
(dict, dict)
- Raises:
CifError – if
tracer.file_freqis not set, or if no file matchingref_dir/ref_fileis found over the requested interval.
- pycif.plugins.datastreams.fluxes.chimere.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, ddi=None, **kwargs)[source]#
Get fluxes from pre-computed CHIMERE AEMISSIONS/BEMISSIONS files.
For each requested date/file pair, determines the hour index to extract either from
ddi(if given) or by parsing the file’sTimesvariable, then reads that hourly slice of the requested variable. Iftracer.diurnal_factoris set, the diurnal cycle of the flux is rescaled toward its daily mean while conserving the daily total (EXPERIMENTAL).- Parameters:
self – the fluxes Plugin.
name (str) – name of the component.
varnames (list[str] or str) – variable name(s) to read;
nameis used ifvarnamesis empty.dates (list) – list of the date intervals to extract.
files (list) – list of files matching
dates.interpol_flx (bool) – unused, kept for interface compatibility.
tracer – the tracer Plugin, giving access to
diurnal_factor.model – unused, kept for interface compatibility.
ddi (datetime.datetime, optional) – reference start date of the file, used to compute the hour index directly; if
None, the hour is instead derived from the file’sTimesvariable.**kwargs – unused, kept for interface compatibility.
- Returns:
the flux data with dimensions
(time, lev, lat, lon).- Return type:
xr.DataArray
- Raises:
CifError – if
ddiis not given and the file has noTimesvariable to derive the hour index from.
- pycif.plugins.datastreams.fluxes.chimere.write.write(self, name, flx_file, flx, mode='a', metadata=None, **kwargs)[source]#
Write flux to AEMISSION CHIMERE compatible files.
- Parameters:
self (Fluxes) – the Fluxes plugin
flx_file (str) – the file where to write fluxes
flx (xarray.DataArray) – fluxes data to write
mode (str) – ‘w’ to overwrite, ‘a’ to append