pycif.plugins.datastreams.fluxes.edgar_v5 — API reference#
Configuration reference: edgar_v5 plugin
- pycif.plugins.datastreams.fluxes.edgar_v5.fetch.fetch(ref_dir, ref_file, date_interval, target_dir, tracer=None, **kwargs)[source]#
Fetch EDGAR v5 yearly files, falling back to the closest available year.
Expands
date_intervalto include full years, then scans all files matchingref_dir/ref_filebetween 1900 and 2100 to determine, for each requested year, the closest available year at or before it (theclosest_yearbehavior is effectively always applied by this lookup). The resolved file is linked intotarget_dir; if it has atimevariable, it is read to build the per-record[start, end]date pairs actually covered, otherwise the whole file is treated as covering the full requested year.- Parameters:
ref_dir (str) – directory where the original files are found.
ref_file (str) – (template) name of the original files.
date_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; unused directly but kept for interface compatibility.
**kwargs – unused, kept for interface compatibility.
- Returns:
list_files(tmp_files) andlist_dates(tmp_dates).- list_files: for each requested year, a list containing the name of
the resolved file repeated once per covered date interval.
- list_dates: for each requested year, a list of
[start, end] date intervals covered by the resolved file.
- Return type:
(dict, dict)
- pycif.plugins.datastreams.fluxes.edgar_v5.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#
Build the horizontal domain from an EDGAR v5 reference file.
Locates a reference NetCDF file (either an exact name match for
ref_fileinref_dir, or the first file whose name parses againstref_fileas a date format). Iftracer.truncatedis set, builds a regional domain from the file’s nativelon/latcoordinates; otherwise builds a fixed, longitude-cyclic global 0.1°x0.1° domain. In both cases a single (surface) vertical level is used.- Parameters:
ref_dir (str) – directory where the original files are found.
ref_file (str) – (template) name of the original files.
input_interval (list) – unused, kept for interface compatibility.
target_dir (str) – unused, kept for interface compatibility.
tracer – the tracer Plugin, giving access to
truncated.
- Returns:
a single-level domain, regional (
truncated) or fixed global 0.1°x0.1°.- Return type:
- Raises:
CifError – if no reference file could be found in
ref_dir.
- pycif.plugins.datastreams.fluxes.edgar_v5.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, model=None, **kwargs)[source]#
Read EDGAR v5 fluxes for the requested dates into a pyCIF array.
For each requested date/file pair, if the file has a
timevariable, the exact matching time index is located and that slice is read; otherwise the full 2D field is read directly (single-record file). The longitude axis is then split at column 1800 and re-concatenated (data[:, :1800]followed bydata[:, 1800:], i.e. in the same order) before being appended to the output.- Parameters:
self – the fluxes Plugin.
name – the name of the component; unused directly, kept for interface compatibility.
varnames (str) – variable name to read from the file.
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 – unused, kept for interface compatibility.
model – unused, kept for interface compatibility.
**kwargs – unused, kept for interface compatibility.
- Returns:
the flux data with dimensions
(time, lev, lat, lon).- Return type:
xr.DataArray