Commit a2592d9e authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

feat(Utils): add tools to manage model prameters and time steps

- FeatModelsGR.csv: model features
- .FeatModels: return a table with model features
- .GetFeatModel: get model features
Refs #106
parent 0c03e304
Pipeline #21757 passed with stages
in 8 minutes and 9 seconds
...@@ -66,6 +66,7 @@ export(TransfoParam_GR5J) ...@@ -66,6 +66,7 @@ export(TransfoParam_GR5J)
export(TransfoParam_GR6J) export(TransfoParam_GR6J)
export(TransfoParam_Lag) export(TransfoParam_Lag)
export(.ErrorCrit) export(.ErrorCrit)
export(.FeatModels)
##################################### #####################################
......
...@@ -13,6 +13,47 @@ ...@@ -13,6 +13,47 @@
## =================================================================================
## function to extract model features
## =================================================================================
## table of feature models
.FeatModels <- function() {
path <- system.file("modelsFeatures/FeatModelsGR.csv", package = "airGR")
read.table(path, header = TRUE, sep = ";")
}
## function to extract model features
.GetFeatModel <- function(FUN_MOD) {
FeatMod <- .FeatModels()
FUN_MOD <- match.fun(FUN_MOD)
NameFunMod <- ifelse(test = FeatMod$Class %in% "GR",
yes = paste("RunModel", FeatMod$NameMod, sep = "_"),
no = FeatMod$NameMod)
FunMod <- lapply(NameFunMod, FUN = get)
IdMod <- which(sapply(FunMod, FUN = function(x) identical(FUN_MOD, x)))
if (length(IdMod) < 1) {
stop("'FUN_MOD' must be one of ", paste(NameFunMod, collapse = ", "))
} else {
res <- as.list(FeatMod[IdMod, ])
res$NameFunMod <- NameFunMod[IdMod]
res$TimeStep <- switch(res$TimeUnit,
hourly = 1,
daily = 24,
monthly = 28:31,
yearly = 365:366)
res$TimeStep <- res$TimeStep * 3600
res$Class <- c(res$TimeUnit, res$Class)
if (grepl("CemaNeige", res$NameFunMod)) {
res$Class <- c(res$Class, "CemaNeige")
}
return(res)
}
}
## ================================================================================= ## =================================================================================
## function to manage Fortran outputs ## function to manage Fortran outputs
## ================================================================================= ## =================================================================================
......
CodeMod;NameMod;NbParam;TimeUnit;Id;Class;Pkg
GR1A;GR1A;1;yearly;NA;GR;airGR
GR2M;GR2M;2;monthly;NA;GR;airGR
GR4J;GR4J;4;daily;NA;GR;airGR
GR5J;GR5J;5;daily;NA;GR;airGR
GR6J;GR6J;6;daily;NA;GR;airGR
GR4H;GR4H;4;hourly;NA;GR;airGR
GR5H;GR5H;5;hourly;NA;GR;airGR
CemaNeige;CemaNeige;2;NA;NA;GR;airGR
CemaNeigeGR4J;CemaNeigeGR4J;6;daily;NA;GR;airGR
CemaNeigeGR5J;CemaNeigeGR5J;7;daily;NA;GR;airGR
CemaNeigeGR6J;CemaNeigeGR6J;8;daily;NA;GR;airGR
CemaNeigeGR4H;CemaNeigeGR4H;6;hourly;NA;GR;airGR
CemaNeigeGR5H;CemaNeigeGR5H;7;hourly;NA;GR;airGR
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