pycif.plugins.datastreams.fluxes.iconart — API reference#
Configuration reference: iconart plugin
- pycif.plugins.datastreams.fluxes.iconart.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
Fetch ICON-ART flux files and build the hourly date intervals they cover.
Splits the simulation interval into sub-periods using
tracer.model.periods(default'10D'), links the file matching the start of each sub-period (if it exists) into target_dir, and expands each sub-period into hourly[start, end]intervals attracer.model.input_resolution.- Parameters:
ref_dir (str) – Directory containing the reference input files.
ref_file (str) – Filename pattern of the input files (a
strftimeformat string).input_interval (list[datetime.datetime]) –
[date_i, date_f]simulation interval to cover.target_dir (str) – Directory where the resolved files are linked.
tracer – The flux tracer plugin, providing access to
model(forperiodsandinput_resolution).
- Returns:
(list_files, list_dates), each keyed by the start date of a sub-period, mapping to the list of file paths and the list of hourly[start, end]date-interval pairs within that sub-period.- Return type:
tuple[dict, dict]
- pycif.plugins.datastreams.fluxes.iconart.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, ddi=None, **kwargs)[source]#
Get ICON-ART fluxes and load them into a pyCIF variable, applying temporal scaling if configured.
Opens the base emission field from the first file only. Then, depending on which
tfactors_*input arguments are set on self:if
tfactors_hoy_fileis set, computes an hour-of-year scaling factor per country and per requested date;else if
tfactors_hod_file,tfactors_dow_fileandtfactors_moy_fileare all set, computes the combined month-of-year x day-of-week x hour-of-day scaling factor per country and per requested date;otherwise, reads all requested hourly time steps directly from the base field with no scaling.
When scaling is applied, per-country factors are broadcast to grid cells via the file’s
country_idsmask (or directly, if the number of countries already matches the number of cells).- Parameters:
self – the fluxes Plugin, providing the
tfactors_*/vfactors_*input arguments.name – the name of the component
varnames (list[str]) – original names of variables to read; use name if varnames is empty
dates – list of
[start, end]date intervals to extract; only the start of each interval is used.files – list of files matching dates; only the first file is actually opened.
interpol_flx (bool) – Unused, kept for interface consistency with other flux plugins.
tracer – Unused directly, kept for interface consistency.
model – Unused directly, kept for interface consistency.
ddi – Unused directly, kept for interface consistency.
- Returns:
- the flux data with dimensions
(time, lev, lat, lon).
- Return type:
xr.DataArray
- Raises:
CifKeyError – If no temporal-scaling arguments are set and either the base field has no
timedimension, or some requested hours are missing from it.
- pycif.plugins.datastreams.fluxes.iconart.write.write(self, name, flx_file, flx, mode='a', **kwargs)[source]#
No-op stub; writing ICON-ART fluxes is not implemented.
- Parameters:
self (Fluxes) – the Fluxes plugin
name (str) – name of the flux variable
flx_file (str) – the file where fluxes would be written
flx (xarray.DataArray) – fluxes data that would be written
mode (str) – ‘w’ to overwrite, ‘a’ to append