SimVsObs | R Documentation |
Simple comparison between time series of observed and simulated variables. This function is specially designed to check the correct operation of the wrapper functions prepared by the user. The premise is as follows: if the user can generate a 'nice' graph (graphically evidencing the simulated and observed values, and obtaining finite numerical values for the objectives) then they can proceed with greater confidence to the hydroMOPSO optimisation step.
SimVsObs(Sim,
Obs,
Objs.values,
Objs.names,
var.names,
var.units,
legend.sim = "Simulated",
legend.obs = "Observed",
cal.period,
warmup.period,
full.period,
main = "study case #1",
analysis.period,
digits.round = 8)
Sim |
( |
Obs |
( |
Objs.values |
( |
Objs.names |
( |
var.names |
( |
var.units |
( |
legend.sim |
( |
legend.obs |
( |
warmup.period |
( |
cal.period |
( |
full.period |
( |
main |
( |
analysis.period |
( |
digits.round |
( |
No return value
Rodrigo Marinao Rivas ra.marinao.rivas@gmail.com, Mauricio Zambrano-Bigiarini, mzb.devel@gmail.com
hydroMOPSO
###############################################################################################
# This example is derived from example 5 of the hydroMOPSO function
library(hydroMOPSO)
library(airGR)
library(hydroTSM)
library(hydroGOF)
# RTL basin ------------------------------------------------
basin.area <- 1415025887 # basin area in square meters
# Load time series -----------------------------------------
data(Trancura9414001plus) # Load RTL data set
# Dates ----------------------------------------------------
dates.raw <- Trancura9414001plus[,"Date"]
dates <- as.Date(dates.raw) # dates
# INPUTS time series ---------------------------------------
# Precipitation (input variable)
ts.pcp.raw <- Trancura9414001plus[,"P_mm"]
ts.pcp <- zoo(ts.pcp.raw, dates)
# Potential EvapoTranspiration (input variable)
ts.pet.raw <- Trancura9414001plus[,"PET_mm"]
ts.pet <- zoo(ts.pet.raw, dates)
# OUTPUTS time series --------------------------------------
# Observed streamflow (calibration output variable)
ts.qobs.raw <- Trancura9414001plus[,"Qobs_m3s"]
ts.qobs <- zoo(ts.qobs.raw, dates)
# Parameter ranges and noCal parameters --------------------
lower <- c("X1" = 0.01, "X2" = -100, "X3" = 0.01, "X4" = 0.5) # parameter range lower threshold
upper <- c("X1" = 1200, "X3" = 100, "X3" = 5000, "X4" = 5 ) # parameter range upper threshold
noCal.param <- (lower + upper)/2 # uncalibrated parameters
# Names and units of observed output variables -------------
char.obs.names <- "Streamflow"
char.obs.units <- "m3/s"
# Objectives names -----------------------------------------
char.objs.names <- c("KGE2012_Q", "KGEGarcia_Q")
# Calibration dates and subsetting -------------------------
WarmUpCal.dates <- dip("1979-01-01", "1979-12-31") # WarmUp for Calibration
Cal.dates <- dip("1980-01-01", "1999-12-31") # Calibration
FullCal.dates <- dip("1979-01-01", "1999-12-31") # WarmUp + Calibration
start.FullCal <- FullCal.dates[1]
end.FullCal <- FullCal.dates[length(FullCal.dates)]
# INPUTS time series ---------------------------------------
# Precipitation (input variable)
ts.pcp.FullCal <- window(ts.pcp, start = start.FullCal, end = end.FullCal) # subsetting pcp
# Potential EvapoTranspiration (input variable)
ts.pet.FullCal <- window(ts.pet, start = start.FullCal, end = end.FullCal) # subsetting pet
# OUTPUTS time series --------------------------------------
# Observed streamflow (calibration output variable)
ts.qobs.FullCal <- window(ts.qobs, start = start.FullCal, end = end.FullCal) # subsetting qobs
list.obs.Cal <- list(Q = ts.qobs.FullCal)
# Structuring Inputs and Options of GR4J model -------------
InputsModel.Cal <- CreateInputsModel(FUN_MOD= RunModel_GR4J,
DatesR= as.POSIXlt(FullCal.dates),
Precip= coredata(ts.pcp.FullCal),
PotEvap= coredata(ts.pet.FullCal))
RunOptions.Cal <- CreateRunOptions(FUN_MOD= RunModel_GR4J, InputsModel= InputsModel.Cal,
IndPeriod_Run = 1:length(FullCal.dates), warnings = FALSE)
# Checking Wrapper function in calibration -----------------
noCal.results.Cal <- GR4JExampleCal(param.values = noCal.param,
Obs = list.obs.Cal,
Objs.names = char.objs.names,
var.names = char.obs.names,
var.units = char.obs.units,
warmup.period = WarmUpCal.dates,
cal.period = Cal.dates,
full.period = FullCal.dates,
InputsModel = InputsModel.Cal,
RunOptions = RunOptions.Cal,
area = basin.area)
noCal.sim.Cal <- noCal.results.Cal[["sim"]]
noCal.objs.Cal <- noCal.results.Cal[["Objs"]]
dev.new()
SimVsObs(Sim = noCal.sim.Cal, Obs = list.obs.Cal,
Objs.values = noCal.objs.Cal, Objs.names = char.objs.names,
var.names = char.obs.names, var.units = char.obs.units,
legend.sim = "Simulated", legend.obs = "Observed",
warmup.period = WarmUpCal.dates, cal.period = Cal.dates, full.period = FullCal.dates,
main = "...just checking GR4JExampleCal function", analysis.period = "calibration",
digits.round = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.