Delft-FEWS I/O

PI-XML

class rtctools.optimization.pi_mixin.PIMixin(**kwargs)[source]

Bases: IOMixin

Adds Delft-FEWS Published Interface I/O to your optimization problem.

During preprocessing, files named rtcDataConfig.xml, timeseries_import.xml, rtcParameterConfig.xml, and rtcParameterConfig_Numerical.xml are read from the input subfolder. rtcDataConfig.xml maps tuples of FEWS identifiers, including location and parameter ID, to RTC-Tools time series identifiers.

During postprocessing, a file named timeseries_export.xml is written to the output subfolder.

Variables:
  • pi_binary_timeseries – Whether to use PI binary timeseries format. Default is False.

  • pi_parameter_config_basenames – List of parameter config file basenames to read. Default is [rtcParameterConfig].

  • pi_parameter_config_numerical_basename – Numerical config file basename to read. Default is rtcParameterConfig_Numerical.

  • pi_check_for_duplicate_parameters – Check if duplicate parameters are read. Default is True.

  • pi_validate_timeseries – Check consistency of timeseries. Default is True.

max_timeseries_id(variable: str) str

Returns the name of the upper bound timeseries for the specified variable.

Parameters:

variable – Variable name.

min_timeseries_id(variable: str) str

Returns the name of the lower bound timeseries for the specified variable.

Parameters:

variable – Variable name.

property timeseries_export

pi.Timeseries object for holding the output data.

property timeseries_import

pi.Timeseries object containing the input data.

property timeseries_import_times

List of time stamps for which input data is specified.

The time stamps are in seconds since t0, and may be negative.

NetCDF

class rtctools.optimization.netcdf_mixin.NetCDFMixin(**kwargs)[source]

Bases: IOMixin

Adds NetCDF I/O to your optimization problem.

During preprocessing, a file named timeseries_import.nc is read from the input subfolder. During postprocessing a file named timeseries_export.nc is written to the output subfolder.

Both the input and output nc files are expected to follow the FEWS format for scalar data in a NetCDF file, i.e.:

  • They must contain a variable with the station ids (location ids) which can be recognized by the attribute cf_role set to timeseries_id.

  • They must contain a time variable with attributes standard_name = time and axis = T

From the input file, all 2-D (or 3-D in case of ensembles) variables with dimensions equal to the station ids and time variable (and realization) are read.

To map the NetCDF parameter identifier to and from an RTC-Tools variable name, the overridable methods netcdf_id_to_variable() and netcdf_id_from_variable() are used.

Variables:

netcdf_validate_timeseries – Check consistency of timeseries. Default is True

netcdf_id_from_variable(variable_name: str) tuple[str, str][source]

Maps the variable name in RTC-Tools to a station_id and parameter name for writing to a NetCDF file.

Returns:

A pair of station_id and parameter

netcdf_id_to_variable(station_id: str, parameter: str) str[source]

Maps the station_id and the parameter name to the variable name to be used in RTC-Tools.

Returns:

The variable name used in RTC-Tools

netcdf_validate_timeseries = True

Check consistency of timeseries.