Skip to content
Snippets Groups Projects
Commit d0909734 authored by Mauricio Zambrano-Bigiarini's avatar Mauricio Zambrano-Bigiarini
Browse files

hydromod.R: sub-daily capable

parent af705124
No related branches found
No related tags found
No related merge requests found
Package: hydroPSO
Type: Package
Title: Model-Independent Particle Swarm Optimisation for Environmental Models
Version: 0.1-58-10
Date: 2012-09-28
Version: 0.1-58-11
Date: 2012-10-15
Authors@R: c(person("Mauricio", "Zambrano-Bigiarini", email="mzb.devel@gmail.com", role=c("aut","cre")), person("Rodrigo", "Rojas", email="Rodrigo.RojasMujica@gmail.com", role=c("ctb")) )
Maintainer: Mauricio Zambrano-Bigiarini <mzb.devel@gmail.com>
Description: This package implements a state-of-the-art version of the Particle Swarm Optimisation (PSO) algorithm (SPSO-2011 and SPSO-2007 capable), with a special focus on the calibration of environmental models. hydroPSO is model-independent, allowing the user to easily interface any model code with the calibration engine (PSO). It includes a series of controlling options and PSO variants to fine-tune the performance of the calibration engine to different calibration problems. An advanced sensitivity analysis function together with user-friendly plotting summaries facilitate the interpretation and assessment of the calibration results. Bugs reports/comments/questions are very welcomed.
......
......@@ -70,7 +70,8 @@ NEWS/ChangeLog for hydroPSO
o 'plot_out' : -) argument 'MinMax' is not required any more
-) argument 'sim' may also be 'integer' (before it had to be 'numeric' != 'integer')
o 'hydromod' : -) if the 'hydroGOF' package is not available, a simple correlation plot is produced between observations and
o 'hydromod' : -) now it is able to handle sub-daily models
-) if the 'hydroGOF' package is not available, a simple correlation plot is produced between observations and
the best simulation
-) improved documentation
......
......@@ -22,6 +22,7 @@
# Updates: 20-Dec-2010 #
# 19-Jan-2011 ; 22-Jan-2011 ; 02-Feb-2011 ; 11-May-2011 #
# 13-Jan-2012 ; 16-Jan-2012 ; 23-Jan-2012 ; 02-May-2012 ; 12-Oct-2012 #
# 15-Oct-2012 #
################################################################################
hydromod <- function(
param.values, # Numeric vector with the paramter values that will be used in the input files of the hydrological model
......@@ -150,25 +151,38 @@ hydromod <- function(
# In case different dates are given for 'sim', 'obs', 'gof.Ini', gof.Fin',
# 'sim' and 'obs' are subset to the time period selected for the GoF function
if ( !missing(gof.Ini) | !missing(gof.Fin) )
ifelse ( grepl("%H", date.fmt, fixed=TRUE) | grepl("%M", date.fmt, fixed=TRUE) |
grepl("%S", date.fmt, fixed=TRUE) | grepl("%I", date.fmt, fixed=TRUE) |
grepl("%p", date.fmt, fixed=TRUE) | grepl("%X", date.fmt, fixed=TRUE),
subdaily <- TRUE, subdaily <- FALSE )
if (!missing(gof.Ini) ) {
ifelse(subdaily, gof.Ini <- as.POSIXct(gof.Ini, format=date.fmt),
gof.Ini <- as.Date(gof.Ini, format=date.fmt) )
if (!zoo::is.zoo(obs)) {
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Ini' !" )
} else obs <- window(obs, start=as.Date(gof.Ini, format=date.fmt) )
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Ini' !")
} else obs <- zoo:window.zoo(obs, start=gof.Ini)
if (!zoo::is.zoo(sim)) {
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Ini' !" )
} else sim <- window(sim, start=as.Date(gof.Ini, format=date.fmt) )
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Ini' !")
} else sim <- window(sim, start=gof.Ini)
} # IF end
if (!missing(gof.Fin) ) {
ifelse(subdaily, gof.Fin <- as.POSIXct(gof.Fin, format=date.fmt),
gof.Fin <- as.Date(gof.Fin, format=date.fmt) )
if (gof.Fin < gof.Ini) {
stop( "Invalid argument: 'gof.Fin < gof.Ini' (", gof.Fin, " < ", gof.Ini, ")" )
} else {
if (!zoo::is.zoo(obs)) {
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Fin' !" )
} else obs <- window(obs, end=as.Date(gof.Fin, format=date.fmt) )
if (!zoo::is.zoo(sim)) {
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Fin' !" )
} else sim <- window(sim, end=as.Date(gof.Fin, format=date.fmt) )
if (!zoo::is.zoo(obs)) {
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Fin' !" )
} else obs <- window(obs, end=gof.Fin)
if (!zoo::is.zoo(sim)) {
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Fin' !" )
} else sim <- window(sim, end=gof.Fin)
} # IF end
} # IF end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment