diff --git a/DESCRIPTION b/DESCRIPTION index 3fd81ccf72883bd8053801196e428160135e836b..e5be887bb4afc77cb299d704498e931756ae7857 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.4.7.6 +Version: 1.4.8.0 Date: 2020-05-04 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.md b/NEWS.md index dc91fc92ff98d9bbfc61eb3e364a94e796659bfc..b614454ffa391dee53e18f6dd7fa10b73d58f32f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ -### 1.4.7.6 Release Notes (2020-05-04) +### 1.4.8.0 Release Notes (2020-05-04) #### New features @@ -13,6 +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. #### Deprecated and defunct diff --git a/R/Utils.R b/R/Utils.R index 2c7a7ba636fecafd59d70f721d606913a67e6215..158606f77b3a81fccd83ce34d6b99a9106b1f44a 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -12,6 +12,29 @@ # } + +## ================================================================================= +## function to manage Fortran outputs +## ================================================================================= + +.AggregOutputs <- 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") + ) + if (length(Table$Outputs) != length(Table$Aggreg)) { + 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 <- ifelse(any(is.na(iRes)), NA, iRes) + }) + return(res) +} + + + ## ================================================================================= ## function to manage Fortran outputs ## =================================================================================