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

pycif.plugins.datastreams.fluxes.flexpart — API reference#

Configuration reference: flexpart plugin

pycif.plugins.datastreams.fluxes.flexpart.fetch.fetch(ref_dir, ref_file, date_interval, target_dir, tracer=None, **kwargs)[source]#

Fetch yearly FLEXPART flux files and prepare a single-level domain.

Builds a yearly file list covering date_interval; for each existing file, expands it into monthly date sub-intervals, links the file (and, if tracer.file_glob is set, the accompanying “global” background file for that year) into target_dir. Finally, tracer.domain is rebuilt with a single forced vertical level (nlev=1), copying all other horizontal/nesting attributes from the existing domain unchanged.

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, giving access to domain and, optionally, file_glob.

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

Returns:

list_files and list_dates.

list_files: for each date that begins a period (a year), a list

containing the name of the file repeated once per covered monthly sub-interval.

list_dates: for each date that begins a period, a list of

[start, end] monthly date intervals covered by the file.

Return type:

(dict, dict)

pycif.plugins.datastreams.fluxes.flexpart.read.read(self, name, varnames, dates, files, interpol_flx=False, tracer=None, **kwargs)[source]#

Get FLEXPART fluxes, optionally cropped to a nested regional domain.

For each requested date/file pair, reads the requested variable via readnc(); if tracer.crop_region is set, crops the field to the nest region using a nearest-index lookup against tracer.domain.lon_in/lat_in. If the domain is nested and tracer.file_glob is set, also reads the corresponding “global” background file for the matching time index and appends it (flattened) to the regional data; otherwise the outside-nest part is padded with NaN. If tracer.convert_to_flux is set, values are converted to ng/m2/s using tracer.numscale (default 1e12) divided by 3600.

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) – accepted but not used to alter behavior; kept for interface compatibility.

  • tracer – the tracer Plugin, giving access to domain, latname_flx, lonname_flx, timename_flx, crop_region, convert_to_flux, numscale and, optionally, file_glob.

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

Returns:

the flux data with dimensions (time, lev, lat, lon), where lon is the flattened (region + background) horizontal index.

Return type:

xr.DataArray

pycif.plugins.datastreams.fluxes.flexpart.read_glob.read_glob(self, name, tracdir, tracfic, dates, interpol_flx=False, **kwargs)[source]#

Get global fluxes from pre-computed fluxes and load them into a pycif variables

Parameters:
  • self – the model Plugin

  • name – the name of the component

  • tracdir – flux directory and file format

  • tracfic – flux directory and file format

  • dates – list of dates to extract

  • interpol_flx (bool) – if True, interpolates fluxes at time t from

  • files (values of surrounding available)

Note

This was originally copied from ../flexpart/read.py. May eventually be moved to a different plugin

pycif.plugins.datastreams.fluxes.flexpart.write.write()[source]#

Not implemented: writing FLEXPART fluxes is not supported.

Raises:

CifError – always.