Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGRteaching
Commits
b871d1d4
Commit
b871d1d4
authored
Feb 07, 2020
by
Delaigue Olivier
Browse files
v0.2.8.15 NEW: PrepGR now runs if all Qobs are NA
#8
CalGR: stop SimGR: warning about the absence of efficiency criterion
parent
8c889638
Changes
5
Show whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
b871d1d4
Package: airGRteaching
Type: Package
Title: Teaching Hydrological Modelling with the GR Rainfall-Runoff Models ('Shiny' Interface Included)
Version: 0.2.8.1
4
Version: 0.2.8.1
5
Date: 2020-02-07
Authors@R: c(
person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
...
...
NEWS.md
View file @
b871d1d4
...
...
@@ -4,7 +4,7 @@
### 0.2.8.1
4
Release Notes (2020-02-07)
### 0.2.8.1
5
Release Notes (2020-02-07)
#### New features
...
...
R/CalGR.R
View file @
b871d1d4
...
...
@@ -5,6 +5,11 @@ CalGR <- function(PrepGR, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
}
isQobs
<-
!
all
(
is.na
(
PrepGR
$
Qobs
))
if
(
!
isQobs
)
{
stop
(
"\"PrepGR\" does not contain any Qobs values. It is not possible to calibrate the model"
)
}
WupInd
<-
NULL
if
(
!
is.null
(
WupPer
))
{
WupPer
<-
as.POSIXct
(
WupPer
,
tz
=
"UTC"
)
...
...
R/PrepGR.R
View file @
b871d1d4
...
...
@@ -3,7 +3,7 @@ PrepGR <- function(ObsDF = NULL, DatesR = NULL, Precip = NULL, PotEvap = NULL, Q
HydroModel
,
CemaNeige
=
FALSE
)
{
if
(
is.null
(
ObsDF
)
&&
(
is.null
(
DatesR
)
|
is.null
(
Precip
)
|
is.null
(
PotEvap
)
|
is.null
(
Qobs
)
))
{
if
(
is.null
(
ObsDF
)
&&
(
is.null
(
DatesR
)
|
is.null
(
Precip
)
|
is.null
(
PotEvap
)))
{
stop
(
"Missing input data"
)
}
...
...
@@ -13,6 +13,12 @@ PrepGR <- function(ObsDF = NULL, DatesR = NULL, Precip = NULL, PotEvap = NULL, Q
}
}
if
(
!
is.null
(
Qobs
))
{
Qobs
<-
Qobs
}
else
{
Qobs
<-
NA
}
if
(
!
is.null
(
TempMean
))
{
TempMean
<-
TempMean
}
else
{
...
...
R/SimGR.R
View file @
b871d1d4
...
...
@@ -5,10 +5,14 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
}
isQobs
<-
!
all
(
is.na
(
PrepGR
$
Qobs
))
if
(
!
isQobs
)
{
warning
(
"\"PrepGR\" does not contain any Qobs values. The efficiency criterion is not computed"
)
}
if
(
!
missing
(
CalGR
))
{
warning
(
"Deprecated \"CalGR\" argument. Use \"Param\" instead"
)
}
### to remove when the CalGR will be removed
if
(
missing
(
Param
))
{
Param
<-
NULL
...
...
@@ -19,12 +23,10 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
if
(
is.null
(
CalGR
)
&
is.null
(
Param
))
{
stop
(
"Arguments \"CalGR\" and \"Param\" are missing, with no default. You must fill in one of these two arguments"
)
}
if
(
is.null
(
Param
))
{
Param
<-
CalGR
$
OutputsCalib
$
ParamFinalR
}
###
if
(
inherits
(
Param
,
"CalGR"
))
{
Param
<-
Param
$
OutputsCalib
$
ParamFinalR
}
...
...
@@ -74,19 +76,29 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
transfo
<-
transfo
[
1L
]
}
MOD_opt
<-
CreateRunOptions
(
FUN_MOD
=
get
(
PrepGR
$
TypeModel
),
InputsModel
=
PrepGR
$
InputsModel
,
IndPeriod_WarmUp
=
WupInd
,
IndPeriod_Run
=
SimInd
,
verbose
=
verbose
)
if
(
isQobs
)
{
MOD_crt
<-
CreateInputsCrit
(
FUN_CRIT
=
FUN_CRIT
,
InputsModel
=
PrepGR
$
InputsModel
,
RunOptions
=
MOD_opt
,
Obs
=
PrepGR
$
Qobs
[
SimInd
],
transfo
=
transfo
)
}
else
{
MOD_crt
<-
NULL
}
SIM
<-
RunModel
(
InputsModel
=
PrepGR
$
InputsModel
,
RunOptions
=
MOD_opt
,
Param
=
Param
,
FUN_MOD
=
get
(
PrepGR
$
TypeModel
))
if
(
isQobs
)
{
CRT
<-
ErrorCrit
(
InputsCrit
=
MOD_crt
,
OutputsModel
=
SIM
,
verbose
=
verbose
)
}
else
{
CRT
<-
NULL
}
SimGR
<-
list
(
OptionsSimul
=
MOD_opt
,
OptionsCrit
=
MOD_crt
,
OutputsModel
=
SIM
,
Qobs
=
PrepGR
$
Qobs
[
SimInd
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment