Commit 213e4c9b authored by Dorchies David's avatar Dorchies David
Browse files

feat(SeriesAggreg): include AggregConvertFunTable into getAggregConvertFun

Refs #41
parent 95b30045
Pipeline #18825 passed with stages
in 12 minutes and 9 seconds
......@@ -36,22 +36,21 @@ getSeriesAggregClass <- function(Format) {
Y = "yearly")
}
.AggregConvertFunTable <- rbind(
data.frame(ConvertFun = "mean",
Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState",
"Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T"),
stringsAsFactors = FALSE), # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
data.frame(ConvertFun = "sum",
Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9",
"Q1","Exch","AExch1","AExch2","AExch","QR","QRExp",
"QD","Qsim","Pliq","Psol","PotMelt","Melt","PliqAndMelt",
"LayerPrecip","LayerFracSolidPrecip", "Qmm", "Qls", "E", "P", "Qupstream"),
stringsAsFactors = FALSE) # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
)
getAggregConvertFun <- function(Outputs) {
AggregConvertFunTable <- rbind(
data.frame(ConvertFun = "mean",
Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState",
"Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T"),
stringsAsFactors = FALSE), # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
data.frame(ConvertFun = "sum",
Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9",
"Q1","Exch","AExch1","AExch2","AExch","QR","QRExp",
"QD","Qsim","Pliq","Psol","PotMelt","Melt","PliqAndMelt",
"LayerPrecip","LayerFracSolidPrecip", "Qmm", "Qls", "E", "P", "Qupstream"),
stringsAsFactors = FALSE) # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
)
res <- sapply(Outputs, function(iOutputs) {
iRes <- .AggregConvertFunTable$ConvertFun[.AggregConvertFunTable$Outputs == iOutputs]
iRes <- AggregConvertFunTable$ConvertFun[AggregConvertFunTable$Outputs == iOutputs]
iRes <- ifelse(test = any(is.na(iRes)), yes = NA, no = iRes) # R < 4.0 compatibility
})
if (length(res) > 0) {
......
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