• Mathias Chouet's avatar
    refactor nubs · 7b6e5403
    Mathias Chouet authored
    merged cParamsCanal and ParamsSection
    Structures are now only defined by their LoiDebit (no more StructureType)
    Session : fixed serialization of lately registered Nubs
    Sections are now defined by a CalculatorType and a NodeType
    fixed bug in findFirstSingleParameter
    added tests for session serialisation
    7b6e5403
Calibration_Michel.R 16.41 KiB
Calibration_Michel <- function(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD, FUN_CRIT, FUN_TRANSFO = NULL, verbose = TRUE) {
##_____Arguments_check_____________________________________________________________________
    if (!inherits(InputsModel, "InputsModel")) {
      stop("InputsModel must be of class 'InputsModel' \n")
      return(NULL)
    }  
    if (!inherits(RunOptions, "RunOptions")) {
      stop("RunOptions must be of class 'RunOptions' \n")
      return(NULL)
    if (!inherits(InputsCrit, "InputsCrit")) {
      stop("InputsCrit must be of class 'InputsCrit' \n")
      return(NULL)
    if (!inherits(CalibOptions, "CalibOptions")) {
      stop("CalibOptions must be of class 'CalibOptions' \n")
      return(NULL)
    if (!inherits(CalibOptions, "HBAN")) {
      stop("CalibOptions must be of class 'HBAN' if Calibration_Michel is used \n")
      return(NULL)
   ##_check_FUN_TRANSFO
    if (is.null(FUN_TRANSFO)) {
      if (identical(FUN_MOD, RunModel_GR4H         )) {
        FUN_TRANSFO <- TransfoParam_GR4H
      if (identical(FUN_MOD, RunModel_GR4J         )) {
        FUN_TRANSFO <- TransfoParam_GR4J
      if (identical(FUN_MOD, RunModel_GR5J         )) {
        FUN_TRANSFO <- TransfoParam_GR5J
      if (identical(FUN_MOD, RunModel_GR6J         )) {
        FUN_TRANSFO <- TransfoParam_GR6J
      if (identical(FUN_MOD, RunModel_GR2M         )) {
        FUN_TRANSFO <- TransfoParam_GR2M
      if (identical(FUN_MOD, RunModel_GR1A         )) {
        FUN_TRANSFO <- TransfoParam_GR1A
      if (identical(FUN_MOD, RunModel_CemaNeige    )) {
        FUN_TRANSFO <- TransfoParam_CemaNeige
      if (identical(FUN_MOD, RunModel_CemaNeigeGR4J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) {
        if (identical(FUN_MOD, RunModel_CemaNeigeGR4J)) {
          FUN1 <- TransfoParam_GR4J
          FUN2 <- TransfoParam_CemaNeige
        if (identical(FUN_MOD, RunModel_CemaNeigeGR5J)) {
          FUN1 <- TransfoParam_GR5J
          FUN2 <- TransfoParam_CemaNeige
        if (identical(FUN_MOD,RunModel_CemaNeigeGR6J)) {
          FUN1 <- TransfoParam_GR6J
          FUN2 <- TransfoParam_CemaNeige
        FUN_TRANSFO <- function(ParamIn, Direction) {
          Bool <- is.matrix(ParamIn)
          if (Bool == FALSE) {
            ParamIn <- rbind(ParamIn)
          ParamOut <- NA*ParamIn
          NParam   <- ncol(ParamIn)
          ParamOut[,          1:(NParam-2)] <- FUN1(ParamIn[,          1:(NParam-2)], Direction)