Commit e696752d authored by unknown's avatar unknown
Browse files

v0.0.3 new specifications for plot dividing in plot.CalGR

parent 6cfae4a9
plot.CalGR <- function(x, which = c("both", "hist", "time"), ...) {
plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) {
if (! any(class(x) %in% "CalGR")) {
stop("Non convenient data for x argument. Must be of class \"CalGR\"")
}
if (! any(which %in% c("perf", "hist", "time"))) {
stop("Non convenient data for which argument. Must be of class \"perf\", \"hist\" or \"time\"")
}
nbParamX <- as.numeric(gsub("\\D", "", x$TypeModel))
nbParamC <- ifelse(grepl("CemaNeige", x$TypeModel), 2, 0)
nbParamX <- airGRscholar:::TypeModelGR(x)$NbParam #as.numeric(gsub("\\D", "", x$TypeModel))
nbParamC <- ifelse(airGRscholar:::TypeModelGR(w2)$CemaNeige, 2, 0)
nbParam <- nbParamX + nbParamC
nmParam <- c(sprintf("X%i", 1:nbParamX), sprintf("C%i", seq_len(nbParamC)))
if (any(which[1L] %in% c("both", "hist"))) {
if (any(which[1L] %in% c("perf"))) {
plot_OutputsModel(x$OutputsModel, Qobs = x$Qobs, ...)
}
if (any(which[1L] %in% c("hist"))) {
layout.list <- list(matrix(c(1:2), ncol = 2),
matrix(c(1:3, 3), ncol = 2),
matrix(NA),
......@@ -23,37 +30,15 @@ plot.CalGR <- function(x, which = c("both", "hist", "time"), ...) {
layout.h <- rep(1, nrow(layout.mat))
layout(mat = layout.mat, widths = layout.w, heights = layout.h)
}
if (which[1L] %in% c("both")) {
layout.mat <- rbind(layout.mat, max(layout.mat)+1, max(layout.mat)+2)
layout(mat = layout.mat, widths = layout.w, heights = layout.h)
}
# if (which[1L] %in% c("both")) {
# layout.mat <- rbind(layout.mat, max(layout.mat)+1, max(layout.mat)+2)
# layout(mat = layout.mat, widths = layout.w, heights = layout.h)
# }
if (which[1L] %in% c("time")) {
layout(mat = matrix(1:2), widths = c(1, 2), heights = c(1, 2))
}
# if (nbParam == 1) {
# layout(mat = matrix(c(1:2), ncol = 2), widths = c(1, 1), heights = c(1))
# }
# if (nbParam == 2) {
# layout(mat = matrix(c(1:3, 3), ncol = 2), widths = c(1, 2), heights = c(1, 1))
# }
# if (nbParam == 4) {
# layout(mat = matrix(c(1:5, 5), ncol = 3), widths = c(1, 1, 2), heights = c(1, 1))
# }
# if (nbParam == 5) {
# layout(mat = matrix(c(1:5, 0, 6, 6), ncol = 4), widths = c(1, 1, 1, 2), heights = c(1, 1, 1))
# }
# if (nbParam == 6) {
# layout(mat = matrix(c(1:7, 7), ncol = 4), widths = c(1, 1, 1, 2), heights = c(1, 1, 1))
# }
# if (nbParam == 7) {
# layout(mat = matrix(c(1:5, 0, 6:8, 8), ncol = 5), widths = c(1, 1, 1, 1, 2), heights = c(1, 1, 1, 1))
# }
# if (nbParam == 8) {
# layout(mat = matrix(c(1:9, 9), ncol = 5), widths = c(1, 1, 1, 1, 2), heights = c(1, 1, 1, 1))
# }
}
if (any(which[1L] %in% c("both", "hist"))) {
if (any(which[1L] %in% c("hist"))) {
par(mar = c(2.5, 2.5, 4.5, 1))
for (i in seq_len(ncol(x$OutputsCalib$HistParamR))) {
......@@ -67,7 +52,7 @@ plot.CalGR <- function(x, which = c("both", "hist", "time"), ...) {
xlab = "", ylab = "", main = "Efficiency criteria\nduring the steepest-descent step")
}
if (any(which[1L] %in% c("both", "time"))) {
if (any(which[1L] %in% c("time"))) {
data <- data.frame(DatesR = x$OutputsModel$DatesR,
Precip = x$OutputsModel$Precip,
Qobs = x$Qobs,
......@@ -78,7 +63,7 @@ plot.CalGR <- function(x, which = c("both", "hist", "time"), ...) {
xlab = "", ylab = "Precip.", main = "", ylim = rev(range(data$Precip)))
par(mar = c(5, 4, 0.1, 1), xaxt = "s")
matplot(data$DatesR, data[, c("Qobs", "Qsim")], type = "l", col = c("black", "red"), lty = 1,
matplot(data$DatesR, data[, c("Qobs", "Qsim")], type = "l", col = c("black", "orangered"), lty = 1,
xlab = "Time", ylab = "Flow", main = "", xaxt = "n")
axis.POSIXct(side = 1, x = data$DatesR)
......
......@@ -5,14 +5,14 @@
\usage{
\method{plot}{CalGR}(x, which = c("both", "hist", "time"), ...)
\method{plot}{CalGR}(x, which = c("perf", "hist", "time"), ...)
}
\arguments{
\item{x}{[object of class \emph{CalGR}] see \code{\link{CalGR}} for details}
\item{which}{[character] XXXX \code{"both"}, \code{"hist"}, \code{"time"}},
\item{which}{[character] XXXX \code{"perf"}, \code{"hist"}, \code{"time"}},
\item{...}{Further graphical parameters may also be supplied as arguments. See 'Details'}
}
......@@ -37,11 +37,13 @@ data(L0123001)
BasinObs2 <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
## Preparation of observed data for modelling
w1 <- ObsGR(ObsBV = BasinObs2, TypeModel = "GR6J", CemaNeige = TRUE)
w1 <- ObsGR(ObsBV = BasinObs2, TypeModel = "GR5J", CemaNeige = TRUE)
## Calibration step
w2 <- CalGR(ObsGR = w1, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
WupPer = NULL, CalPer = c("1990-01-01", "1993-12-31"))
plot(w2)
plot(w2, "perf")
plot(w2, "time")
plot(w2, "hist")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment