pycif.plugins.datastreams.fluxes.EDGARv8_EYECLIMA_nc — API reference#
Configuration reference: EDGARv8_EYECLIMA_nc plugin
- pycif.plugins.datastreams.fluxes.EDGARv8_EYECLIMA_nc.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
Fetch EDGARv8 forecast-style files covering the simulation interval.
Iterates daily over
input_interval; for each day, brackets the nearest valid file within the current (and, at month boundaries, adjacent) directory usingfind_valid_file(), links the found file intotarget_dir, and builds hourly date sub-intervals for that day (the last day of the interval is truncated toinput_interval[1].hour).- 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; unused directly but kept for interface compatibility.
**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)
- pycif.plugins.datastreams.fluxes.EDGARv8_EYECLIMA_nc.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#
Build the horizontal domain from an EDGARv8 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.EDGARv8_EYECLIMA_nc.read.read(self, name, varnames, dates, files, interpol_flx=False, comp_type=None, tracer=None, **kwargs)[source]#
Get EDGARv8 fluxes with country-specific temporal profiles applied.
Loads the weekday/weekend-type tables, weekly and hourly temporal profile CSVs from
tracer.dir_profils, and the EDGAR global country mask NetCDF (tracer.global_mask). For each requested date, for each country that has a mask footprint and an available temporal profile: computes the local time from the country’s timezone, looks up the matching weekday/hourly coefficient (falling back to an equivalent activity profile via the hardcodedprofils_eqmapping if the exact one is missing), and accumulatesemis * 24 * 7 * daily_coef * hourly_coef * country_maskinto the output grid. Grid cells not covered by any country’s profile (or by no profile at all) fall back to flat monthly emissions.- 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 (values assumed in kg/m2/s).
dates (list) – list of the date intervals to extract.
files (list) – list of files matching
dates.interpol_flx (bool) – unused, kept for interface compatibility.
comp_type – unused, kept for interface compatibility.
tracer – the tracer Plugin, giving access to
dir_profils,global_mask,truncatedandprofil_select.**kwargs – unused, kept for interface compatibility.
- Returns:
the flux data with dimensions
(time, lev, lat, lon).- Return type:
xr.DataArray
- Raises:
CifImportError – if
pycountryand/orzoneinfoare not available in the environment.
- pycif.plugins.datastreams.fluxes.EDGARv8_EYECLIMA_nc.utils.find_valid_file(ref_dir, file_format, dd, ref_dir_next, ref_dir_previous=False)[source]#
Find the pair of files bracketing a reference date.
Lists the files in
ref_dir(and, whenddfalls near a month boundary, inref_dir_next/ref_dir_previous) that matchfile_format, parses their date from the file name, sorts them, and returns the nearest available file/date beforeddand the nearest one afterdd(used to bracket forecast-style files).- Parameters:
ref_dir (str) – directory to search for candidate files.
file_format (str) – strptime/strftime-compatible file name pattern used both to parse each candidate file’s date and to derive
dd’s canonical file name.dd (datetime.datetime) – reference date to bracket.
ref_dir_next (str) – adjacent directory to also search when
ddis close to the end of its month.ref_dir_previous (str or bool) – adjacent directory to also search when
ddis close to the start of its month;Falseto skip this lookup.
- Returns:
a 2-element list of file paths
[file_before, file_after]and the corresponding 2-element list of dates[date_before, date_after]bracketingdd.- Return type:
(list[str], list[datetime.datetime])
- Raises:
CifError – if no file matching
file_formatis found inref_dir(and adjacent directories, if searched).