Commit 73a1183b authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.4.2.6 UPDATE: tested_values argument renamed into TestedValues into the Imax fun #13

Showing with 10 additions and 10 deletions
+10 -10
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.4.2.5 Version: 1.4.2.6
Date: 2019-12-10 Date: 2019-12-10
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
### 1.4.2.5 Release Notes (2019-12-10) ### 1.4.2.6 Release Notes (2019-12-10)
#### New features #### New features
......
Imax <- function(InputsModel, Imax <- function(InputsModel,
IndPeriod_Run, IndPeriod_Run,
tested_values = seq(from = 0.1, to = 3, seq = 0.1)) { TestedValues = seq(from = 0.1, to = 3, seq = 0.1)) {
##_____Arguments_check_____________________________________________________________________ ##_____Arguments_check_____________________________________________________________________
if (!inherits(InputsModel, "InputsModel")) { if (!inherits(InputsModel, "InputsModel")) {
...@@ -22,9 +22,9 @@ Imax <- function(InputsModel, ...@@ -22,9 +22,9 @@ Imax <- function(InputsModel,
stop("'IndPeriod_Run' must be a continuous sequence of integers") stop("'IndPeriod_Run' must be a continuous sequence of integers")
} }
##tested_values ##TestedValues
if (!(is.numeric(tested_values))) { if (!(is.numeric(TestedValues))) {
stop("'tested_values' must be 'numeric'") stop("'TestedValues' must be 'numeric'")
} }
...@@ -40,8 +40,8 @@ Imax <- function(InputsModel, ...@@ -40,8 +40,8 @@ Imax <- function(InputsModel,
##calculate total interception of the GR5H interception store on the period ##calculate total interception of the GR5H interception store on the period
## and compute difference with daily values ## and compute difference with daily values
differences <- array(NA, c(length(tested_values))) differences <- array(NA, c(length(TestedValues)))
for (Imax in tested_values) { for (Imax in TestedValues) {
C0 <- 0 C0 <- 0
cum_hourly <- 0 cum_hourly <- 0
for (i in IndPeriod_Run) { for (i in IndPeriod_Run) {
...@@ -50,10 +50,10 @@ Imax <- function(InputsModel, ...@@ -50,10 +50,10 @@ Imax <- function(InputsModel,
C0 <- C0 + InputsModel$Precip[i] - Ec - Pth C0 <- C0 + InputsModel$Precip[i] - Ec - Pth
cum_hourly <- cum_hourly + Ec cum_hourly <- cum_hourly + Ec
} }
differences[which(Imax == tested_values)] <- abs(cum_hourly - cum_daily) differences[which(Imax == TestedValues)] <- abs(cum_hourly - cum_daily)
} }
##return the Imax value that minimises the difference ##return the Imax value that minimises the difference
return(tested_values[which.min(differences)]) return(TestedValues[which.min(differences)])
} }
Supports Markdown
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