pycif.plugins.datastreams.backgrounds.carboscope_bg — API reference

pycif.plugins.datastreams.backgrounds.carboscope_bg — API reference#

Configuration reference: carboscope_bg plugin

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

Locate CARBOSCOPE background files and link them to the working directory.

The requested date interval is expanded to cover full calendar years (CARBOSCOPE station files are not split by period), all files matching ref_dir/ref_file are symlinked into target_dir, and hourly sub-periods spanning the expanded interval are generated.

Parameters:
  • ref_dir – directory holding the CARBOSCOPE background files.

  • ref_file – glob pattern (relative to ref_dir) matching the per-station files to fetch.

  • date_interval – 2-element sequence (datei, datef) giving the requested date range.

  • target_dir – directory where matching files are symlinked.

  • tracer – the background datastream Plugin (unused here beyond being accepted for interface consistency).

Returns:

(list_files, list_dates), each a dict with a single key (the start of the expanded interval). list_files maps it to the list of linked file paths; list_dates maps it to the list of hourly [start, start + 1h] date pairs spanning the interval.

Return type:

tuple

Raises:

CifError – if no file matches ref_dir/ref_file.

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

Read CARBOSCOPE background concentrations into a pyCIF datastore.

For each file in files, parses the whitespace-delimited station data (date components in columns 1-6, concentration in column 12), keeps only rows within the requested date range, derives the station code from the file name (translated via self.dict_station_name if station_name_dict was configured), and packs the result into an empty pyCIF datastore. All per-file datastores are concatenated.

Parameters:
  • self – the background datastream Plugin.

  • name – name of the observed parameter/component.

  • varnames – unused (kept for interface consistency with other datastream read functions).

  • dates – list of [start, end] date pairs to extract, one per entry of files.

  • files – list of CARBOSCOPE station files to read from, aligned with dates.

  • interpol_flx (bool) – unused here (kept for interface consistency).

  • tracer – the background tracer, used for its numscale scaling factor.

  • model – unused here (kept for interface consistency).

Returns:

concatenated pyCIF datastore (as built by init_empty) with date, station, network, parameter and duration metadata columns, and obserror/ spec main-data columns.

Return type:

pandas.DataFrame

pycif.plugins.datastreams.backgrounds.carboscope_bg.write.write(self, prescr_file, prescr, typefile, mode='a', **kwargs)[source]#

Write prescribed species background fields for LMDZ.

Parameters:
  • self (Fluxes) – the Fluxes plugin.

  • prescr_file (str) – the file where to write the prescribed field.

  • prescr (xarray.Dataset) – prescribed species data to write. For typefile == "bin", must expose "fwd" and "tl" data variables.

  • typefile (str) – output format, either "bin" for a raw binary file (fwd/tl arrays transposed and dumped with tofile) or "nc" for a NETCDF3_CLASSIC file.

  • mode (str) – unused; kept for interface consistency. NetCDF output is always merged into any existing file, since xarray’s append mode is not supported here.