Forked from HYCAR-Hydro / airGR
Source project has a limited visibility.
CreateInputsModel.R 10.28 KiB
CreateInputsModel <- function(FUN_MOD,
                              DatesR,
                              Precip, PrecipScale = TRUE,
                              PotEvap = NULL,
                              TempMean = NULL, TempMin = NULL, TempMax = NULL,
                              ZInputs = NULL, HypsoData = NULL, NLayers = 5,
                              verbose = TRUE) {
    ObjectClass <- NULL
    FUN_MOD <- match.fun(FUN_MOD)
    ##check_FUN_MOD
    BOOL <- FALSE
    if (identical(FUN_MOD, RunModel_GR4H)) {
      ObjectClass <- c(ObjectClass, "hourly", "GR")
      TimeStep <- as.integer(60 * 60)
      BOOL <- TRUE
    if (identical(FUN_MOD, RunModel_GR4J) |
        identical(FUN_MOD, RunModel_GR5J) |
        identical(FUN_MOD, RunModel_GR6J)) {
      ObjectClass <- c(ObjectClass, "daily", "GR")
      TimeStep <- as.integer(24 * 60 * 60)
      BOOL <- TRUE
    if (identical(FUN_MOD, RunModel_GR2M)) {
      ObjectClass <- c(ObjectClass, "GR", "monthly")
      TimeStep <- as.integer(c(28, 29, 30, 31) * 24 * 60 * 60)
      BOOL <- TRUE
    if (identical(FUN_MOD, RunModel_GR1A)) {
      ObjectClass <- c(ObjectClass, "GR", "yearly")
      TimeStep <- as.integer(c(365, 366) * 24 * 60 * 60)
      BOOL <- TRUE
    if (identical(FUN_MOD, RunModel_CemaNeige)) {
      ObjectClass <- c(ObjectClass, "daily", "CemaNeige")
      TimeStep <- as.integer(24 * 60 * 60)
      BOOL <- TRUE
    if (identical(FUN_MOD, RunModel_CemaNeigeGR4J) |
        identical(FUN_MOD, RunModel_CemaNeigeGR5J) |
        identical(FUN_MOD, RunModel_CemaNeigeGR6J)) {
      ObjectClass <- c(ObjectClass, "daily", "GR", "CemaNeige")
      TimeStep <- as.integer(24 * 60 * 60)
      BOOL <- TRUE
    if (!BOOL) {
      stop("incorrect 'FUN_MOD' for use in 'CreateInputsModel'")
    ##check_arguments
    if ("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass) {
      if (is.null(DatesR)) {
        stop("'DatesR' is missing")