This is the fourth of a series of tutorials on the FUSE implementation within the RHydro package. The script for this tutorial is available here. If you are interested in following the discussion related to this post and see how it evolves, join the R4Hydrology community on Google+!
If you want to know what FUSE is, how to prepare your data and run a simple simulation go to the first post of the series, for a basic calibration example (using 1 model structure) go to the second post, while for an example of multi-model calibration got to the third post.
HydroMAD is an excellent framework for hydrological modelling, optimization, sensitivity analysis and assessment of results. It contains a large set of soil moisture accounting modules and routing functions.
Thanks to Joseph Guillaume (hydromad’s maintainer), FUSE-RHydro is now compatible with HydroMAD, therefore using and calibrating FUSE becomes even easier! Joseph provided many of the examples below, many thanks for that too!
In this tutorial I will show how to:
- set up FUSE and its parameter ranges using the hydromad approach
- run a simulation
- calibrate FUSE using one of the hydromad’s algorithms
Recap from previous posts
Load the package and prepare your default list of models
library(hydromad) library(RHydro) data(modlist)
Read sample data in
temp <- read.csv("dummyData.csv")
Convert to date the first column and then convert to zoo object
temp[,1] <- as.Date(temp[,1],format="%Y-%m-%d") DATA <- read.zoo(temp)
Step 1: set up FUSE and its parameter ranges using the hydromad approach
HydroMAD allows to specify a rainfall-runoff model of choice. This is achieved by using the hydromad() function and specifying the soil moisture accounting model and routing function to use.
Set the parameter ranges using hydromad.options
hydromad.options(fusesma = fusesma.ranges(), fuserouting = fuserouting.ranges())
modspec <- hydromad(DATA, sma = "fusesma", routing = "fuserouting", mid = 1:1248, modlist = modlist)
myNewParameterSet <- parameterSets( coef(modspec, warn=FALSE), 1, method="random" )
Step 2: run a single simulation
modx <- update(modspec, newpars = myNewParameterSet)
U <- modx$U
Qrout <- modx$fitted.values
Step 3: calibrate FUSE using one of hydromad’s algorithms
Hydromad provide the “fitBy” method to calibrate using a specified algorithm. As an example, the Shuffled Complex Evolution method can be used as shown below. Please note that the procedure is likely to take a LONG time.
modfit <- fitBySCE(modspec)
Get a summary of the result
If you want to use the latest version of fuse, the above steps can be adapted as follows:
library(hydromad) library(fuse) data(modlist) # Load data temp <- read.csv("dummyData.csv") temp[,1] <- as.Date(temp[,1],format="%Y-%m-%d") DATA <- read.zoo(temp) # Set the parameter ranges using hydromad.options hydromad.options(fusesma = fusesma.ranges(), fuserouting = fuserouting.ranges()) # Set up the model modspec <- hydromad(DATA, sma = "fusesma", routing = "fuserouting", mid = 1:1248, deltim = 1/24) # Calibrate FUSE using one of hydromad’s algorithms modfit <- fitBySCE(modspec) # Get a summary of the result summary(modfit)
This tutorials was just a brief introduction to a topic that can be explored in many different directions. From a technical point of view, it could be worth to invest some effort into code optimization and/or parallelisation. This would also have an impact on the scientific side facilitating experiments on sensitivity analysis, regionalisation of catchment characteristics and model structure variability.
Some of those ideas are already on their way, some others are just random thoughts. Therefore…watch this space!