pycif.plugins.datastreams.fields.bc_plugin_template — API reference

pycif.plugins.datastreams.fields.bc_plugin_template — API reference#

Configuration reference: bc_plugin_template plugin

pycif.plugins.datastreams.fields.bc_plugin_template.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None)[source]#

Retrieves the required files according to the simulation and the data files available

Args#

  • ref_dir: directory where the original files are found

  • ref_file: (template) name of the original files

  • input_interval: list of two dates: the beginning and end of the simulation

  • target_dir: directory where the links to the orginal files are created

Returns#

  • list_dates: a dictionary in which each key leads to a list of intervals [date_beginning, date_end] so that each interval is covered by one value taken fom the matching file stored in list_files.

  • list_files: dictionary in which each key leads to a list of files so that the list of intervals are covered by the values provided in these files.

Chosing the keys for both dictionary: the most efficient ways are to use either i) the dates at which the data files begin or ii) dates matching the typical use of this data. Example: if the data is typically used for generating BCs per day, use the dates of the days to simulate as keys. The idea is to avoid to list the same file in several keys because the read routine is called for each key.

Examples for a simulation from 01-01-2001 00H00 to 01-02-2001 00H00 for which input BC files cover 24 hours at an hourly resolution: - data = annual data for 2001:

  • list_dates = { ‘01-01-2001’: [[01-01-2001 00H00, 31-12-2001 23H59]] }

  • list_files = { ‘01-01-2001’: [[yearly_data_file]] }

  • data = hourly data in daily files:
    • list_dates = { ‘01-01-2001 00H00’: [ [01-01-2001 00H00, 01-01-01-2001 01H00 ], [01-01-2001 01H00, 01-01-01-2001 02H00 ], [01-01-2001 02H00, 01-01-01-2001 03H00 ], … [01-01-2001 23H00, 01-02-01-2001 00H00 ]] }

    • list_files = { ‘01-01-2001 00H00’: [ daily_data_file_for_01/01/2001, daily_data_file_for_01/01/2001, daily_data_file_for_01/01/2001, … ] }

Notes#

  • the information file_freq, provided in the yaml file and accessible through tracer.file_freq, is used here and only here.

  • the intervals listed in list_dates are used to perform the time interpolation. They must therefore be the smallest intervals during which the values are constant XXXmal dit?XX. Example: if time profiles are applied (see XX for option apply_profile and how to provide the profile data) to yearly data, the intervals must be the intervals obtained after applying the profiles (e.g. monthly, hourly) and not the whole year.

  • the decumulation of fields is taken care of in read

Retrieves the characteristics of the spatial domain on which the data is provided.

Args:#

  • ref_dir: directory where the original data files are found

  • ref_file: (template) name of the original files

  • input_interval: XX???XXX

  • target_dir: directory where the links to the orginal files are created

Returns:#

  • the setup of the domain, done in section “Initializes domain”

pycif.plugins.datastreams.fields.bc_plugin_template.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#

Reads the data in the orignal files. Is called for each key in dictionary list_dates/list_files provided by fetch.

Args:#

  • name: name of the component

  • dates: list of the dates matching the files

  • files: list of the files matching the dates

-> dates and files as provided by fetch.py

  • varnames: original names of variables to read

  • comp_type: type of boundary conditions to generate. Useful to distinguish lateral from top from initial conditions.

Returns:#

  • a DataArray with the actual data: 4 dimensional (time, vertical levels, latitude, longitude) with coordinates in increasing order (see also get_domain).

pycif.plugins.datastreams.fields.bc_plugin_template.read.read(self, name, varnames, dates, files, interpol_flx=False, comp_type=None, **kwargs)[source]#

Get BCs from raw files and load them into a pyCIF variables