hbv_pso: HBV Modelling with Particle Swarm Optimization

Description Usage Arguments Value Examples

View source: R/hbv-pso.R

Description

Performs particle swarm optimization of the HBV hydrological model by wrapping hydroPSO and TUWmodel.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
hbv_pso(
  prec = NULL,
  airt = NULL,
  ep = NULL,
  area = 1,
  param = hbvPSO::tuwmodel_params_default,
  disable_tr = FALSE,
  par_fixed = NULL,
  obs = NULL,
  from = NULL,
  to = NULL,
  warmup = 0,
  incon = NULL,
  outpath = NULL,
  hydroPSO_args = NULL,
  FUN_gof = hydroGOF::NSE,
  FUN_gof_args = NULL,
  plotting = FALSE
)

Arguments

prec

Precipitation input (mm/day) as zoo, matrix or numerical. If multivariate, each variable is the input for one zone.

airt

Air Temperature input (degC/day) as zoo, matrix or numerical. If multivariate, each variable is the input for one zone.

ep

Potential Evapotranspiration (mm/day) as zoo, matrix or numerical. If multivariate, each variable is the input for one zone.

area

If input data is distributed into zones (multivariate zoo/matrix), a vector of the decimal proportion of area for each zone.

obs

Observed Discharge (mm/day) as zoo or numerical

from

Start of the modelling period (including warmup) as Date or string in standard date format. Requires input datasets to be zoo objects.

to

End of the modelling period as Date or string in standard date format. Requires input datasets to be zoo objects.

warmup

Warmup phase which is removed before calculating goodness of fit. Can be given as numeric (days removed from the model start date) or date (as Date object or string in default format which can be cast to Date by as.Date). If given as date, it marks the start of the simulation period after warmup.

incon

vector/matrix of initial conditions for the model (ncol = number of zones): SSM0 soil moisture (mm); SWE0 snow water equivalent (mm); SUZ0 initial value for fast (upper zone) response storage (mm); SLZ0 initial value for slow (lower zone) response storage (mm)

outpath

Path to the directory storing the output files as string. If not NULL, the following is set in in hydroPSO's control list: drty.out=outpath and write2disk=TRUE

hydroPSO_args

Arguments passed on to hydroPSO

FUN_gof

The function used to calculate goodness of fit. Must take sim and obs as first arguments.

FUN_gof_args

Further arguments passed on to FUN_gof

plotting

Toggles plotting of the results (with plot_results if optimization is performed, otherwise with plot_out). As alternative to TRUE, a list of arguments for the respective plotting functions can be provided.

Value

A list of the following items:

  1. sim simulated runoff (mm/day) of the best model run

  2. obs observed runoff (mm/day)

  3. gof goodness of fit of the best model run

  4. pso_out hydroPSO output

  5. hbv_out TUWmodel output from the best model run

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
# loading the example data from TUWmodel
data(example_TUWmodel, package="TUWmodel")
# extracting the input data for the lumped case (see TUWmodel examples):
# 1.) apply weighted means
prec <- apply(P_Vils, 1, weighted.mean, w=areas_Vils)
airt <- apply(T_Vils, 1, weighted.mean, w=areas_Vils)
ep <- apply(PET_Vils, 1, weighted.mean, w=areas_Vils)
# 2.) casting from named numeric vector to zoo
prec <- zoo(prec, order.by=as.Date(names(prec)))
airt <- zoo(airt, order.by=as.Date(names(airt)))
ep <- zoo(ep, order.by=as.Date(names(ep)))
obs <- zoo(Q_Vils, order.by=as.Date(names(Q_Vils)))
# setting up date range and warmup, limit max iterations to 500
control <- list(maxit=500)
from <- "1976-01-01"
to <- "1996-12-31"
warmup <- "1977-01-01"
# running hbv_PSO with default options, without plotting or parallel processing
res <- hbv_pso(prec=prec, airt=airt, ep=ep, obs=obs,hydroPSO_args = list(control=control))

## End(Not run)

jthurner/hbvPSO documentation built on Oct. 15, 2020, midnight