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

+importFrom(zoo, is.zoo)

parent 280e50e8
No related branches found
No related tags found
No related merge requests found
...@@ -3,13 +3,12 @@ Type: Package ...@@ -3,13 +3,12 @@ Type: Package
Title: Model-Independent Particle Swarm Optimisation for Environmental Models Title: Model-Independent Particle Swarm Optimisation for Environmental Models
Version: 0.1-58-10 Version: 0.1-58-10
Date: 2012-09-28 Date: 2012-09-28
Author: Mauricio Zambrano-Bigiarini [aut, cre] and Rodrigo Rojas [ctb]
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")) ) 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> 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. 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.
License: GPL (>=2) License: GPL (>=2)
Depends: R (>= 2.10.0) Depends: R (>= 2.10.0)
Imports: Hmisc, sp, lattice, grid Imports: Hmisc, sp, lattice, zoo, grid
Suggests: hydroGOF(>= 0.3-3), hydroTSM(>= 0.3-0), zoo(>= 1.7-2), xts(>= 0.8-2), lhs, scatterplot3d, vioplot, multicore Suggests: hydroGOF(>= 0.3-3), hydroTSM(>= 0.3-0), zoo(>= 1.7-2), xts(>= 0.8-2), lhs, scatterplot3d, vioplot, multicore
URL: http://www.rforge.net/hydroPSO, http://cran.r-project.org/web/packages/hydroPSO URL: http://www.rforge.net/hydroPSO, http://cran.r-project.org/web/packages/hydroPSO
Classification: optimisation, optimization, calibration, environment, environmental sciences, hydrology, PSO Classification: optimisation, optimization, calibration, environment, environmental sciences, hydrology, PSO
......
importFrom("Hmisc", wtd.quantile, wtd.Ecdf) importFrom("Hmisc", wtd.quantile, wtd.Ecdf)
importFrom("sp", coordinates, spplot) importFrom("sp", coordinates, spplot)
importFrom("lattice", xyplot, axis.default) importFrom("lattice", xyplot, axis.default)
importFrom("zoo", is.zoo)
import(grid) import(grid)
#importFrom("hydroTSM", hydroplot, hydropairs, dip, mip, yip, vector2zoo) #importFrom("hydroTSM", hydroplot, hydropairs, dip, mip, yip, vector2zoo)
#importFrom("hydroGOF", ggof) #importFrom("hydroGOF", ggof)
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
# Author : Mauricio Zambrano-Bigiarini # # Author : Mauricio Zambrano-Bigiarini #
# Started: 14-Dec-2010 at JRC Ispra # # Started: 14-Dec-2010 at JRC Ispra #
# Updates: 20-Dec-2010 # # Updates: 20-Dec-2010 #
# 19-Jan-2011 ; 22-Jan-2011 ; 02-Feb-2011 ; 11-May-2011 # # 19-Jan-2011 ; 22-Jan-2011 ; 02-Feb-2011 ; 11-May-2011 #
# 13-Jan-2012 ; 16-Jan-2012 ; 23-Jan-2012 ; 02-May-2012 # # 13-Jan-2012 ; 16-Jan-2012 ; 23-Jan-2012 ; 02-May-2012 ; 12-Oct-2012 #
################################################################################ ################################################################################
hydromod <- function( hydromod <- function(
param.values, # Numeric vector with the paramter values that will be used in the input files of the hydrological model param.values, # Numeric vector with the paramter values that will be used in the input files of the hydrological model
...@@ -137,7 +137,7 @@ hydromod <- function( ...@@ -137,7 +137,7 @@ hydromod <- function(
out.FUN.argsDefaults <- formals(out.FUN) out.FUN.argsDefaults <- formals(out.FUN)
out.FUN.args <- modifyList(out.FUN.argsDefaults, out.FUN.args) out.FUN.args <- modifyList(out.FUN.argsDefaults, out.FUN.args)
sim <- do.call(out.FUN, as.list(out.FUN.args)) sim <- do.call(out.FUN, as.list(out.FUN.args))
############################################################################## ##############################################################################
# 4) Goodness of fit # # 4) Goodness of fit #
...@@ -151,10 +151,10 @@ hydromod <- function( ...@@ -151,10 +151,10 @@ hydromod <- function(
# 'sim' and 'obs' are subset to the time period selected for the GoF function # 'sim' and 'obs' are subset to the time period selected for the GoF function
if (!missing(gof.Ini) ) { if (!missing(gof.Ini) ) {
if (!is.zoo(obs)) { if (!zoo::is.zoo(obs)) {
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Ini' !" ) 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) ) } else obs <- window(obs, start=as.Date(gof.Ini, format=date.fmt) )
if (!is.zoo(sim)) { if (!zoo::is.zoo(sim)) {
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Ini' !" ) 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) ) } else sim <- window(sim, start=as.Date(gof.Ini, format=date.fmt) )
} # IF end } # IF end
...@@ -163,14 +163,14 @@ hydromod <- function( ...@@ -163,14 +163,14 @@ hydromod <- function(
if (gof.Fin < gof.Ini) { if (gof.Fin < gof.Ini) {
stop( "Invalid argument: 'gof.Fin < gof.Ini' (", gof.Fin, " < ", gof.Ini, ")" ) stop( "Invalid argument: 'gof.Fin < gof.Ini' (", gof.Fin, " < ", gof.Ini, ")" )
} else { } else {
if (!is.zoo(obs)) { if (!zoo::is.zoo(obs)) {
stop( "Invalid argument: 'obs' must be a zoo or xts object to use 'gof.Fin' !" ) 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) ) } else obs <- window(obs, end=as.Date(gof.Fin, format=date.fmt) )
if (!is.zoo(sim)) { if (!zoo::is.zoo(sim)) {
stop( "Invalid argument: 'sim' must be a zoo or xts object to use 'gof.Fin' !" ) 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) ) } else sim <- window(sim, end=as.Date(gof.Fin, format=date.fmt) )
} # IF end } # IF end
} # IF end } # IF end
nobs <- length(obs) nobs <- length(obs)
nsim <- length(sim) nsim <- length(sim)
...@@ -211,13 +211,14 @@ hydromod <- function( ...@@ -211,13 +211,14 @@ hydromod <- function(
png(filename=png.fname, width= width, height= height, res=res) png(filename=png.fname, width= width, height= height, res=res)
if ( !is.na( match("hydroGOF", installed.packages()[,"Package"] ) ) ) { if ( !is.na( match("hydroGOF", installed.packages()[,"Package"] ) ) ) {
library(hydroGOF)
ggof(sim, obs, main=main, cex.main=1.5, leg.cex=leg.cex, tick.tstep=tick.tstep, lab.tstep=lab.tstep, lab.fmt=lab.fmt) ggof(sim, obs, main=main, cex.main=1.5, leg.cex=leg.cex, tick.tstep=tick.tstep, lab.tstep=lab.tstep, lab.fmt=lab.fmt)
} else } else plot_out(sim=sim, obs=obs, ptype="corr")
dev.off() dev.off()
if (verbose) message("===========================================") if (verbose) message("===========================================")
if (verbose) message("[ See the file 'Obs_vs_Sim.png' ]") if (verbose) message("[ See the file '", basename(png.fname), "' ")
if (verbose) message("===========================================") if (verbose) message("===========================================")
} # 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