Commit 312d7369 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.4.8.2 refactor: .AggregOutputs function renamed into AggregConvertFun #41

local variables of the function also renamed
parent 0786007e
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.4.8.1
Version: 1.4.8.2
Date: 2020-05-04
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -4,7 +4,7 @@
### 1.4.8.1 Release Notes (2020-05-04)
### 1.4.8.2 Release Notes (2020-05-04)
#### New features
......@@ -13,7 +13,7 @@
- Added <code>SeriesAggreg2.InputsModel()</code> function.
- Added <code>SeriesAggreg2.OutputsModel()</code> function.
- Added <code>SeriesAggreg2.data.frame()</code> function. This new verson of the <code>SeriesAggreg()</code> function allows to compute regimes.
- Added<code>.AggregOutputs()</code> private function in order to choose automatically the <code>ConvertFun</code> to apply on each element of <code>InputsModel</code> and <code>OutputsModel</code> ojects.
- Added<code>.AggregConvertFun()</code> private function in order to choose automatically the <code>ConvertFun</code> to apply on each element of <code>InputsModel</code> and <code>OutputsModel</code> ojects.
#### Deprecated and defunct
......
......@@ -17,17 +17,18 @@
## function to manage Fortran outputs
## =================================================================================
.AggregOutputs <- function(Outputs) {
.AggregConvertFun <- function(Outputs) {
Table <- list(
Outputs = c("PotEvap", "Precip", "Prod", "Pn", "Ps", "AE", "Perc", "PR", "Q9", "Q1", "Rout", "Exch", "AExch1", "AExch2", "AExch", "QR", "QRExp", "Exp", "QD", "Qsim", "Pliq", "Psol", "SnowPack", "ThermalState", "Gratio", "PotMelt", "Melt", "PliqAndMelt", "Temp", "Gthreshold", "Glocalmax", "LayerPrecip", "LayerTempMean", "LayerFracSolidPrecip"),
Aggreg = c("sum", "sum", "mean", "sum", "sum", "sum", "sum", "sum", "sum", "sum", "mean", "sum", "sum", "sum", "sum", "sum", "sum", "mean", "sum", "sum", "sum", "sum", "mean", "mean", "mean", "sum", "sum", "sum", "mean", "mean", "mean", "sum", "mean", "sum")
Outputs = c("PotEvap", "Precip", "Prod", "Pn", "Ps", "AE", "Perc", "PR", "Q9", "Q1", "Rout", "Exch", "AExch1", "AExch2", "AExch", "QR", "QRExp", "Exp", "QD", "Qsim", "Pliq", "Psol", "SnowPack", "ThermalState", "Gratio", "PotMelt", "Melt", "PliqAndMelt", "Temp", "Gthreshold", "Glocalmax", "LayerPrecip", "LayerTempMean", "LayerFracSolidPrecip"),
ConvertFun = c("sum", "sum", "mean", "sum", "sum", "sum", "sum", "sum", "sum", "sum", "mean", "sum", "sum", "sum", "sum", "sum", "sum", "mean", "sum", "sum", "sum", "sum", "mean", "mean", "mean", "sum", "sum", "sum", "mean", "mean", "mean", "sum", "mean", "sum")
)
if (length(Table$Outputs) != length(Table$Aggreg)) {
if (length(Table$Outputs) != length(Table$ConvertFun)) {
stop("'.AggregOutputs' is out of order")
}
match.arg(Outputs, choices = Table$Outputs, several.ok = TRUE)
res <- sapply(Outputs, function(iOutputs) {
iRes <- Table$Aggreg[Table$Outputs == iOutputs]
iRes <- Table$ConvertFun[Table$Outputs == iOutputs]
# iRes <- Table$ConvertFun[pmatch(iOutputs, Table$Outputs)]
iRes <- ifelse(any(is.na(iRes)), NA, iRes)
})
return(res)
......
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