Create GRiwrmRunOptions object for running and calibrating model in airGRiwrm.

# S3 method for GRiwrmInputsModel
CreateRunOptions(InputsModel, ...)

Arguments

InputsModel

object of class GRiwrmInputsModel, see CreateInputsModel.GRiwrm for details.

...

further arguments passed to airGR::CreateRunOptions.

Value

GRiwrmRunOptions object for running and calibrating model in airGRiwrm.

Examples

################################################################# # Run the `airGRRunModel_Lag` example in the GRiwrm fashion way # ################################################################# # Run airGR RunModel_Lag example for harvesting necessary data library(airGR)
#> #> Attaching package: 'airGR'
#> The following objects are masked from 'package:airGRiwrm': #> #> Calibration, CreateCalibOptions, CreateInputsCrit, #> CreateInputsModel, CreateRunOptions, RunModel
example(RunModel_Lag)
#> #> RnMd_L> ##################################################################### #> RnMd_L> ## Simulation of a reservoir with a purpose of low-flow mitigation ## #> RnMd_L> ##################################################################### #> RnMd_L> #> RnMd_L> ## ---- preparation of the InputsModel object #> RnMd_L> #> RnMd_L> ## loading package and catchment data #> RnMd_L> library(airGR) #> #> RnMd_L> data(L0123001) #> #> RnMd_L> ## the reservoir withdraws 1 m3/s when it's possible considering the flow observed in the basin #> RnMd_L> Qupstream <- matrix(-sapply(BasinObs$Qls / 1000 - 1, function(x) { #> RnMd_L+ min(1, max(0, x, na.rm = TRUE)) #> RnMd_L+ }), ncol = 1) #> #> RnMd_L> ## except between July and September when the reservoir releases 3 m3/s for low-flow mitigation #> RnMd_L> month <- as.numeric(format(BasinObs$DatesR, "%m")) #> #> RnMd_L> Qupstream[month >= 7 & month <= 9] <- 3 #> #> RnMd_L> Qupstream <- Qupstream * 86400 ## Conversion in m3/day #> #> RnMd_L> ## the reservoir is not an upstream subcachment: its areas is NA #> RnMd_L> BasinAreas <- c(NA, BasinInfo$BasinArea) #> #> RnMd_L> ## delay time between the reservoir and the catchment outlet is 2 days and the distance is 150 km #> RnMd_L> LengthHydro <- 150 #> #> RnMd_L> InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, #> RnMd_L+ Precip = BasinObs$P, PotEvap = BasinObs$E, #> RnMd_L+ Qupstream = Qupstream, LengthHydro = LengthHydro, #> RnMd_L+ BasinAreas = BasinAreas) #> #> RnMd_L> ## ---- simulation of the basin with the reservoir influence #> RnMd_L> #> RnMd_L> ## run period selection #> RnMd_L> Ind_Run <- seq(which(format(BasinObs$DatesR, format = "%Y-%m-%d")=="1990-01-01"), #> RnMd_L+ which(format(BasinObs$DatesR, format = "%Y-%m-%d")=="1999-12-31")) #> #> RnMd_L> ## creation of the RunOptions object #> RnMd_L> RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, #> RnMd_L+ InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
#> Warning: model warm up period not defined: default configuration used #> the year preceding the run period is used
#> #> RnMd_L> ## simulation of the runoff of the catchment with a GR4J model #> RnMd_L> Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208) #> #> RnMd_L> OutputsModelDown <- RunModel_GR4J(InputsModel = InputsModel, #> RnMd_L+ RunOptions = RunOptions, Param = Param) #> #> RnMd_L> ## with a delay of 2 days for 150 km, the flow velocity is 75 km per day #> RnMd_L> Velocity <- (LengthHydro * 1e3 / 2) / (24 * 60 * 60) ## Conversion km/day -> m/s #> #> RnMd_L> ## run the lag model which routes precipitation-runoff model and upstream flows #> RnMd_L> OutputsModel <- RunModel_Lag(InputsModel = InputsModel, #> RnMd_L+ RunOptions = RunOptions, #> RnMd_L+ Param = Velocity, #> RnMd_L+ QcontribDown = OutputsModelDown) #> #> RnMd_L> ## results preview of comparison between naturalised (observed) and influenced flow (simulated) #> RnMd_L> plot(OutputsModel, Qobs = OutputsModel$QsimDown)
# detach the package because airGR overwrite airGRiwrm functions here detach("package:airGR") # This example is a network of 2 nodes which can be describe like this: db <- data.frame(id = c("Reservoir", "GaugingDown"), length = c(LengthHydro, NA), down = c("GaugingDown", NA), area = c(NA, BasinInfo$BasinArea), model = c(NA, "RunModel_GR4J"), stringsAsFactors = FALSE) # Create GRiwrm object from the data.frame griwrm <- CreateGRiwrm(db) str(griwrm)
#> Classes 'GRiwrm' and 'data.frame': 2 obs. of 5 variables: #> $ id : chr "Reservoir" "GaugingDown" #> $ down : chr "GaugingDown" NA #> $ length: num 150 NA #> $ model : chr NA "RunModel_GR4J" #> $ area : num NA 360
# Formatting observations for the hydrological models # Each input data should be a matrix or a data.frame with the good id in the name of the column Precip <- matrix(BasinObs$P, ncol = 1) colnames(Precip) <- "GaugingDown" PotEvap <- matrix(BasinObs$E, ncol = 1) colnames(PotEvap) <- "GaugingDown" # Observed flows are integrated now because we mix: # - flows that are directly injected in the model # - flows that could be used for the calibration of the hydrological models Qobs = matrix(c(Qupstream, BasinObs$Qmm), ncol = 2) colnames(Qobs) <- griwrm$id str(Qobs)
#> num [1:10593, 1:2] -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 ... #> - attr(*, "dimnames")=List of 2 #> ..$ : NULL #> ..$ : chr [1:2] "Reservoir" "GaugingDown"
# Creation of the GRiwrmInputsModel object (= a named list of InputsModel objects) InputsModels <- CreateInputsModel(griwrm, DatesR = BasinObs$DatesR, Precip = Precip, PotEvap = PotEvap, Qobs = Qobs)
#> CreateInputsModel.GRiwrm: Treating sub-basin GaugingDown...
str(InputsModels)
#> List of 1 #> $ GaugingDown:List of 11 #> ..$ DatesR : POSIXlt[1:10593], format: "1984-01-01" "1984-01-02" ... #> ..$ Precip : num [1:10593] 4.1 15.9 0.8 0 0 0 0 0 2.9 0 ... #> ..$ PotEvap : num [1:10593] 0.2 0.2 0.3 0.3 0.1 0.3 0.4 0.4 0.5 0.5 ... #> ..$ Qupstream : num [1:10593, 1] -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 -86400 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : NULL #> .. .. ..$ : chr "Reservoir" #> ..$ LengthHydro : Named num 150 #> .. ..- attr(*, "names")= chr "Reservoir" #> ..$ BasinAreas : Named num [1:2] NA 360 #> .. ..- attr(*, "names")= chr [1:2] "Reservoir" "GaugingDown" #> ..$ id : chr "GaugingDown" #> ..$ down : chr NA #> ..$ UpstreamNodes : chr "Reservoir" #> ..$ UpstreamIsRunoff: logi FALSE #> ..$ FUN_MOD : chr "RunModel_GR4J" #> ..- attr(*, "class")= chr [1:4] "InputsModel" "daily" "GR" "SD" #> - attr(*, "class")= chr [1:2] "GRiwrmInputsModel" "list" #> - attr(*, "GRiwrm")=Classes 'GRiwrm' and 'data.frame': 2 obs. of 5 variables: #> ..$ id : chr [1:2] "Reservoir" "GaugingDown" #> ..$ down : chr [1:2] "GaugingDown" NA #> ..$ length: num [1:2] 150 NA #> ..$ model : chr [1:2] NA "RunModel_GR4J" #> ..$ area : num [1:2] NA 360 #> - attr(*, "TimeStep")= num 86400
# Creation of the GriwmRunOptions object RunOptions2 <- CreateRunOptions(InputsModels, IndPeriod_Run = Ind_Run)
#> Warning: model warm up period not defined: default configuration used #> the year preceding the run period is used
str(RunOptions2)
#> List of 1 #> $ GaugingDown:List of 6 #> ..$ IndPeriod_WarmUp: int [1:365] 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 ... #> ..$ IndPeriod_Run : int [1:3652] 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 ... #> ..$ IniStates : num [1:67] 0 0 0 0 0 0 0 0 0 0 ... #> ..$ IniResLevels : num [1:4] 0.3 0.5 NA NA #> ..$ Outputs_Cal : chr "Qsim" #> ..$ Outputs_Sim : chr [1:20] "DatesR" "PotEvap" "Precip" "Prod" ... #> ..- attr(*, "class")= chr [1:3] "RunOptions" "daily" "GR" #> - attr(*, "class")= chr [1:2] "list" "GRiwrmRunOptions"
# Parameters of the SD models should be encapsulated in a named list Param2 <- list(`GaugingDown` = c(Velocity, Param)) # RunModel for the whole network OutputsModels <- RunModel(InputsModels, RunOptions = RunOptions2, Param = Param2)
#> RunModel.GRiwrmInputsModel: Treating sub-basin GaugingDown...
str(OutputsModels)
#> List of 1 #> $ GaugingDown:List of 22 #> ..$ DatesR : POSIXlt[1:3652], format: "1990-01-01" "1990-01-02" ... #> ..$ PotEvap : num [1:3652] 0.3 0.4 0.4 0.3 0.1 0.1 0.1 0.2 0.2 0.3 ... #> ..$ Precip : num [1:3652] 0 9.3 3.2 7.3 0 0 0 0 0.1 0.2 ... #> ..$ Prod : num [1:3652] 196 199 199 201 200 ... #> ..$ Pn : num [1:3652] 0 8.9 2.8 7 0 0 0 0 0 0 ... #> ..$ Ps : num [1:3652] 0 3.65 1.12 2.75 0 ... #> ..$ AE : num [1:3652] 0.2833 0.4 0.4 0.3 0.0952 ... #> ..$ Perc : num [1:3652] 0.645 0.696 0.703 0.74 0.725 ... #> ..$ PR : num [1:3652] 0.645 5.946 2.383 4.992 0.725 ... #> ..$ Q9 : num [1:3652] 1.78 1.52 3.86 3.17 3.45 ... #> ..$ Q1 : num [1:3652] 0.2 0.195 0.271 0.387 0.365 ... #> ..$ Rout : num [1:3652] 53.9 53.6 55.3 56.1 56.9 ... #> ..$ Exch : num [1:3652] 0.181 0.18 0.176 0.197 0.207 ... #> ..$ AExch1 : num [1:3652] 0.181 0.18 0.176 0.197 0.207 ... #> ..$ AExch2 : num [1:3652] 0.181 0.18 0.176 0.197 0.207 ... #> ..$ AExch : num [1:3652] 0.362 0.36 0.353 0.393 0.414 ... #> ..$ QR : num [1:3652] 2.05 1.99 2.36 2.55 2.78 ... #> ..$ QD : num [1:3652] 0.381 0.375 0.447 0.584 0.572 ... #> ..$ Qsim : num [1:3652] 2.43 2.37 2.56 2.9 3.11 ... #> ..$ StateEnd:List of 4 #> .. ..$ Store :List of 4 #> .. .. ..$ Prod: num 189 #> .. .. ..$ Rout: num 48.9 #> .. .. ..$ Exp : num NA #> .. .. ..$ Int : num NA #> .. ..$ UH :List of 2 #> .. .. ..$ UH1: num [1:20] 0.514 0.54 0.148 0 0 ... #> .. .. ..$ UH2: num [1:40] 0.056306 0.057176 0.042254 0.012188 0.000578 ... #> .. ..$ CemaNeigeLayers:List of 4 #> .. .. ..$ G : num NA #> .. .. ..$ eTG : num NA #> .. .. ..$ Gthr : num NA #> .. .. ..$ Glocmax: num NA #> .. ..$ SD :List of 1 #> .. .. ..$ : num [1:3] -86400 -86400 -86400 #> .. ..- attr(*, "class")= chr [1:3] "IniStates" "GR" "daily" #> ..$ QsimDown: num [1:3652] 2.43 2.37 2.8 3.14 3.35 ... #> ..$ Qsim_m3 : num [1:3652] 875333 851839 922461 1042434 1119947 ... #> ..- attr(*, "class")= chr [1:3] "OutputsModel" "daily" "GR" #> - attr(*, "class")= chr [1:2] "GRiwrmOutputsModel" "list" #> - attr(*, "Qm3s")=Classes 'Qm3s' and 'data.frame': 3652 obs. of 3 variables: #> ..$ DatesR : POSIXct[1:3652], format: "1990-01-01" "1990-01-02" ... #> ..$ Reservoir : num [1:3652] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... #> ..$ GaugingDown: num [1:3652] 10.13 9.86 10.68 12.07 12.96 ...
# Comparison between GRiwrm simulation and airGR simulation plot(OutputsModels, Qobs = data.frame(`GaugingDown` = OutputsModel$Qsim))
#> [[1]] #> NULL #>