Run Particle Swarm Optimizations of the HBV Model using hydroPSO and TUWmodel by importing configurations from R files. Supports specifiying multiple configuration files to run optimizations in batches.

hbv_pso_run(configpath, recursive = FALSE, suffix = NULL, gof.name = NULL,
  from_validation = NULL, to_validation = NULL, ...)

Arguments

configpath

character vector of full path and/or file names. Any file given is sourced and an hbv_pso optimization run is started with the imported arguments. Any directory given is searched for R files starting with "run", and an optimization run is started for each found in the same way as for file paths.

recursive

logical, should config files be searched in subdirectories? If true, hbv_pso_run will recurse once into any directory given in configpath before searching for configuration files

suffix

String, will be appended to the optimization run identifier

gof.name

String, Used as part of the optimization run identifier. Shorthand for setting plotting$gof.name. If gof.name is not set directly, the value from plotting$gof.name is used.

from_validation

Date or date string in default format, start of validation run with best parameter set found during optimization

to_validation

Date or date string in default format, end of validation period

...

Parameters passed to hbv_pso, will overwrite those set in in the configuration files.

Value

A list of the following items:

  1. summary data frame with id, gof, gof_valid, from, to, from_valid and to_valid for each optimization run

  2. results list with hydro_pso output from all optimization runs, named by id

In addition, the output files from each optimization run are written inside a directory which is located in the same directory as the configuration file, and named by the identifier of the respective optimization run.

Details

Runs Particle Swarm Optimizations of HBV for given parameter sets defined in simple R scripts. Timeseries input data (prec, airt, ep, obs, area, elevation_zones) can be automatically imported from csv or HBV-light format.

Each optimization run is given an identification string concatenated from the name of the input data directory (i.e. the location of the configuration file), the name of the gof variable and an optional suffix. This identifier is used as directory name for the output files, in plot titles and file names, and in the result list returned by hbv_pso_run.

Parameter definition

Parameters for the different optimization runs are defined by simple variable assignment, where the variable name corresponds to the parameter as used in hbv_pso(). They are defined in simple R files passed to hbv_pso_run (see configpath). In order for the configuration files to be picked up when passing directory paths to hbv_pso_run, the configuration file names must start with "run".

Parameters can also be set by passing them as additional arguments to hbv_pso_run, which will overwrite corresponding values defined in configuration file(s). Be aware that when using this option, any lists passed are not merged but completely replace the values set in the configfile.

In addition to parameters described in hbv_pso(), the following optional parameters unique to hbv_pso_run can also be set in configuration files: suffix, gof.name,from_validation, to_validation (see above).

Input data definition

For each optimization run, the following variables have to be defined and contain valid values as defined in hbv_pso(): prec, airt, ep, obs, area, elev_zones. The input data can be assinged in the following ways (in descending order of precedence):

  1. assignment inside the configfile: Add code which assigns the input

  2. text files inside input data directories: The files must be named as the input time series (with either .csv, .txt or no suffix, e.g. prec.csv) and be located in the same directory as the configfile. They must produce a valid zoo object with index when read by read.zoo with default arguments

  3. HBV-light input files: Analogue to the text files above, input data can also be imported from files as used by HBV-light ("ptq.text" and "ep.txt")

If a given input data set is not defined in the configuration file, hbv_pso_run will try to load it from a corresponding file in the input data directory - first from a csv file, and then from the corrseponding HBV-light file (e.g. PTQ.txt for prec, airt or obs).