pycif.plugins.datastreams.fluxes.chimere — API reference

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 into target_dir with hourly sub-dates. If the linked file declares a bottom_top dimension different from the domain’s current number of levels, tracer.domain is 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, name and domain.

  • **kwargs – unused, kept for interface compatibility.

Returns:

list_files and list_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_freq is not set, or if no file matching ref_dir/ref_file is 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’s Times variable, then reads that hourly slice of the requested variable. If tracer.diurnal_factor is 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; name is used if varnames is 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’s Times variable.

  • **kwargs – unused, kept for interface compatibility.

Returns:

the flux data with dimensions (time, lev, lat, lon).

Return type:

xr.DataArray

Raises:

CifError – if ddi is not given and the file has no Times variable 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

pycif.plugins.datastreams.fluxes.chimere.write.write_AEMISSIONS(name, flx_file, flx, mode='a', lon=None, lat=None, nlev=1, ncformat='NETCDF4')[source]#

Auxiliary function that can be used outside pycif