pycif.plugins.datastreams.meteos.dummy_csv — API reference

Contents

pycif.plugins.datastreams.meteos.dummy_csv — API reference#

Configuration reference: dummy_csv plugin

pycif.plugins.datastreams.meteos.dummy_csv.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#

Locate dummy meteo CSV files, generating them if missing, and link them.

Iterates over period-start dates covering input_interval at tracer.file_freq, and for each period computes the hourly (or tracer.resolution) sub-periods it should cover. If the corresponding source file (ref_dir/ref_file formatted for that period) exists, it is symlinked into target_dir; otherwise it is generated on the fly via make.make().

Parameters:
  • ref_dir – directory holding (or expected to hold) the dummy meteo CSV files.

  • ref_file – strftime-style file name pattern (relative to ref_dir), formatted once per period.

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

  • target_dir – directory where files are symlinked or generated.

  • tracer – the meteo datastream Plugin, used for tracer.file_freq and tracer.resolution, and passed through to make when a file needs to be generated.

Returns:

(list_files, list_dates), dicts keyed by each period’s start date. list_files maps each key to the (repeated) target file path, one entry per sub-period; list_dates maps each key to the corresponding list of [start, start + resolution] date pairs.

Return type:

tuple

pycif.plugins.datastreams.meteos.dummy_csv.make.make(meteo, meteo_file, file_hours, **kwargs)[source]#

Creates random meteo time series for toy Gaussian model

Generates a uniform random wind speed (0-5), wind direction (0-360) and a random Pasquill stability class (A-F) for each requested time step, then writes the result as a CSV file. If meteo.seed is set, the NumPy random seed is derived deterministically from meteo.seed_id and the elapsed time between file_hours and meteo.datei, so runs are reproducible.

Parameters:
  • meteo (pycif.utils.classes.Meteo) – object defining the meteo

  • meteo_file (str) – path where to dump

  • file_hours (pd.DatetimeIndex) – list of dates to include

Returns:

None. The generated time series is written to meteo_file as a CSV (indexed by date, with windspeed, winddir and stabclass columns).

pycif.plugins.datastreams.meteos.dummy_csv.read.read(meteo, name, varnames, dates, files, **kwargs)[source]#

Read a variable from the dummy meteo CSV files.

For each requested date, reloads the CSV file when it differs from the previously read one, then selects the row matching that date.

Parameters:
  • meteo – the meteo datastream Plugin (unused here beyond interface consistency).

  • name (str) – name of the CSV column to extract (windspeed, winddir or stabclass).

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

  • dates – list of [start, end] date pairs, aligned with files; only start is used to select rows.

  • files – list of dummy meteo CSV files to read from, aligned with dates. Consecutive duplicate entries are only reloaded once.

Returns:

the requested column’s values for each date in dates, with dims (time, lev, lat, lon) (single-point lev/lat/lon).

Return type:

xarray.DataArray