FUSE model in RHydro package (part 4: HydroMAD compatibility)

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.

RHydro-HydroMAD compatibility

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:

  1. set up FUSE and its parameter ranges using the hydromad approach
  2. run a simulation
  3. 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())
Set up the model
modspec <- hydromad(DATA,
                    sma = "fusesma"                    routing = "fuserouting", 
                    mid = 1:1248, 
                    modlist = modlist)
# Randomly generate 1 parameter set
myNewParameterSet <- parameterSetscoef(modspecwarn=FALSE), 
                                    1                                    method="random" )

Step 2: run a single simulation

Run a simulation using the parameter set generated above
modx <- update(modspec,
               newpars = myNewParameterSet)
Generate a summary of the result
summary(modx)
The instantaneous runoff is
U <- modx$U
The routed discharge is
Qrout <- modx$fitted.values
Plot the Observed vs Simulated value
hydromad:::xyplot.hydromad(modx)
Add the precipitation to the above plot
hydromad:::xyplot.hydromad(modx, with.P=TRUE)

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

summary(modfit)

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)

What’s next?

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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s