Performs particle swarm optimization of the HBV hydrological model by wrapping hydroPSO and TUWmodel.
hbv_pso(prec = NULL, airt = NULL, ep = NULL, area = 1, param = hbvPSO::tuwmodel_params_default, obs = NULL, from = NULL, to = NULL, warmup = 0, telev = NULL, pelev = NULL, elev_zones = NULL, incon = NULL, outpath = NULL, hydroPSO_args = NULL, FUN_gof = hydroGOF::NSE, FUN_gof_args = NULL, plotting = FALSE)
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. |
param | Parameters as two-column (min,max) matrix or dataframe if optimization should be performed, and as vector otherwise.
The last two parameters are optional and used to transform the temperature/precipitation input (instead of being passed on to TUWmodel). To disable pcalt/tcalt, set them to zero or ommit from param. See tuwmodel_params_default for an example with the default ranges as specified in TUWmodel. |
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. |
telev | Reference Elevation for the air temperature input, used to adjust temperature by tcalt. |
pelev | Reference Elevation for the precipitation input, used to adjust precipitation by pcalt. |
elev_zones | Vector of mean elevation for each zone. Only required if tcalt/pcalt is used. |
incon | vector/matrix of initial conditions for the model ( |
outpath | Path to the directory storing the output files as string. If not NULL, the following is set in in hydroPSO's control list: |
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 |
plotting | Toggles plotting of the results (with plot_results if optimization is performed, otherwise with plot_out). As alternative to |
A list of the following items:
sim
simulated runoff (mm/day) of the best model run
obs
observed runoff (mm/day)
gof
goodness of fit of the best model run
pso_out
hydroPSO output
hbv_out
TUWmodel output from the best model run
# 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)) # }