Commit eb693cee authored by unknown's avatar unknown
Browse files

v0.1.5.11 dyplot updated to be compatible with dygraphs >= 1.1.1.4

parent f8350886
Package: airGRteaching
Type: Package
Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (Including a Shiny Interface)
Version: 0.1.5.10
Date: 2017-09-06
Version: 0.1.5.11
Date: 2017-09-07
Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut")), person("Guillaume", "Thirel", role = c("ctb")))
Depends: airGR (>= 1.0.8.0)
Imports: xts, dygraphs, shiny, plotrix, markdown
Imports: xts, dygraphs (>= 1.1.1.4), shiny, plotrix, markdown
Description: Add-on package to the airGR package that simplifies its use and is aimed at being used for teaching hydrology. The package provides 1) three functions that allow to complete very simply a hydrological modelling exercise 2) plotting functions to help students to explore observed data and to interpret the results of calibration and simulation of the GR models 3) a shiny graphical interface that allows for displaying in the impact of model parameters on hydrographs and models internal variables.
License: GPL-2
NeedsCompilation: no
......
......@@ -22,10 +22,12 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
}
}
if (any(class(x) %in% "ObsGR")) {
if (any(class(x) %in% "ObsGR")) {
data <- data.frame(DatesR = x$InputsModel$DatesR,
Precip = x$InputsModel$Precip,
Qobs = x$Qobs)
Qobs = x$Qobs,
Qsim = NA)
} else {
data <- data.frame(DatesR = x$OutputsModel$DatesR,
Precip = x$OutputsModel$Precip,
......@@ -35,19 +37,41 @@ dyplot.default <- function(x, col.Precip = "royalblue", col.Q = c("black", "oran
col.Q <- rep(col.Q, 2)
}
}
Plim <- c(-1e-3, max(data$Precip, na.rm = TRUE))
# if (any(names(x$InputsModel) == "LayerPrecip")) {
# data$Psol <- rowMeans(as.data.frame(x$InputsModel$LayerPrecip) * as.data.frame(x$InputsModel$LayerFracSolidPrecip))
# data$Pliq <- data$Precip - data$Psol
# data$Precip <- NULL
# }
data.xts <- xts(data[, -1L], order.by = data$DatesR)
dg <- dygraph(data.xts, main = main)
dg <- dySeries(dygraph = dg, name = "Qobs", axis = 'y' , color = col.Q[1L], drawPoints = TRUE)
dg <- dySeries(dygraph = dg, name = "Qsim", axis = 'y' , color = col.Q[2L])
dg <- dySeries(dygraph = dg, name = "Precip", axis = 'y2', plotter = barChartPrecip, color = col.Precip)
dg <- dyAxis(dygraph = dg, name = "y", label = ylab[1L],
valueRange = range(data.xts[, grep("^Q", colnames(data.xts))], na.rm = TRUE) * c(0.01, 1.59))
valueRange = range(data.xts[, grep("^Q", colnames(data.xts))], na.rm = TRUE) * c(0.01, 1.59))
dg <- dyAxis(dygraph = dg, name = "y2", label = ylab[2L], independentTicks = FALSE,
valueRange = c(max(data.xts[, "Precip"], na.rm = TRUE), -1e-3) * c(2.99, 0.01))
dg <- dySeries(dygraph = dg, name = "Qobs", drawPoints = TRUE)
dg <- dySeries(dygraph = dg, name = tail(grep("^Q", colnames(data.xts), value = TRUE), 1),
axis = 'y' , color = col.Q[seq_along(grep("^Q", colnames(data.xts)))])
dg <- dySeries(dygraph = dg, name = "Precip", axis = 'y2', plotter = barChartPrecip, color = col.Precip)
valueRange = rev(Plim) * c(2.99, 0.01))
# if (any(names(x$InputsModel) == "LayerPrecip")) {
# dg <- dyStackedBarGroup(dygraph = dg, name = c("Psol", "Pliq"), axis = "y2", color = c("lightblue", col.Precip))
# dg <- dyAxis(dygraph = dg, name = "y2", label = ylab[2L], independentTicks = FALSE,
# valueRange = rev(Plim))# * c(0.01, 2.99))
# } else {
# dg <- dySeries(dygraph = dg, name = "Precip", axis = 'y2', plotter = barChartPrecip, color = col.Precip)
# dg <- dyStackedBarGroup(dygraph = dg, name = c("Precip"), axis = "y2", color = col.Precip)
# dg <- dyAxis(dygraph = dg, name = "y2", label = ylab[2L], independentTicks = FALSE,
# valueRange = rev(Plim) * c(0.01, 2.99))
# }
# if (ModelPeriod) {
# dg <- dyShading(dygraph = dg, from = x$PeriodModel$WarmUp[1L], to = x$PeriodModel$WarmUp[2L], color = "orangered")
# dg <- dyShading(dygraph = dg, from = x$PeriodModel$Run[1L] , to = x$PeriodModel$Run[2L] , color = "blue")
......
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