airGR issueshttps://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues2023-10-31T13:54:43+01:00https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/183Change webGR URLs of english pages2023-10-31T13:54:43+01:00Delaigue OlivierChange webGR URLs of english pagesSince the language plugin no longer works on webGR.inrae.fr, all links must be modified in the package documentation and vignettes.Since the language plugin no longer works on webGR.inrae.fr, all links must be modified in the package documentation and vignettes.v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/154Error in vignettes\V03_param_sets_GR4J.Rmd2023-10-24T11:05:34+02:00Dorchies DavidError in vignettes\V03_param_sets_GR4J.RmdLine 203-204:
```r
OutputsModel_Cal <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions_Cal,
Param = OutputsCalib$ParamFinalR, FUN = RunModel_GR4J)
```
The argument should be `FUN_MOD` instead o...Line 203-204:
```r
OutputsModel_Cal <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions_Cal,
Param = OutputsCalib$ParamFinalR, FUN = RunModel_GR4J)
```
The argument should be `FUN_MOD` instead of `FUN`.
This huge bug was not detected before because the chunk is flagged `include=FALSE` instead of `eval=FALSE` so it is not run in the automatic tests.
TODO:
- [x] Change `FUN` to `FUN_MOD`
- [ ] Change `include` to `eval`v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/157Improve computation time of propose candidates grid2023-10-19T18:08:30+02:00Delaigue OlivierImprove computation time of propose candidates gridCurrently, the `ProposeCandidatesGrid()` function from `Calibration_Michel()` removes duplicated values after the creation of the table of proposed candidates grid using `expand.grid()` in order to compute all combinations of parameters....Currently, the `ProposeCandidatesGrid()` function from `Calibration_Michel()` removes duplicated values after the creation of the table of proposed candidates grid using `expand.grid()` in order to compute all combinations of parameters.
In addition, the function is not clean because it use the `DistribParamR` external variable (but the result was not wrong).
**Current function**:
```r
ProposeCandidatesGrid <- function(DistribParam) {
NewCandidates <- expand.grid(lapply(seq_len(ncol(DistribParamR)), function(x) DistribParam[, x]))
NewCandidates <- unique(NewCandidates) # to avoid duplicates when a parameter is set
Output <- list(NewCandidates = NewCandidates)
}
```
**Benchmarking**:
It is more efficient to remove duplicated values on each parameter instead of the whole table.
In addition, it is not necessary to return a list.
```r
## original one removing duplcated values on the whole data.frame (but DistribParamR replacedby DistribParam)
ProposeCandidatesGrid1 <- function(DistribParam) {
NewCandidates <- expand.grid(lapply(seq_len(ncol(DistribParam)), function(x) DistribParam[, x]))
NewCandidates <- unique(NewCandidates) # to avoid duplicates when a parameter is set
Output <- list(NewCandidates = NewCandidates)
}
## original one removing duplicated values on the whole data.frame & returning data.frame instead of a list
ProposeCandidatesGrid2 <- function(DistribParam) {
NewCandidates <- expand.grid(lapply(seq_len(ncol(DistribParam)), function(x) DistribParam[, x]))
unique(NewCandidates) # to avoid duplicates when a parameter is set
}
## new one removing duplicated values on each parameter & returning a list
ProposeCandidatesGrid3 <- function(DistribParam) {
NewCandidates <- expand.grid(lapply(seq_len(ncol(DistribParam)), function(x) unique(DistribParam[, x])))
Output <- list(NewCandidates = NewCandidates)
}
## new one removing duplicated values on each parameter & returning data.frame instead of a list
ProposeCandidatesGrid4 <- function(DistribParam) {
expand.grid(lapply(seq_len(ncol(DistribParam)), function(x) unique(DistribParam[, x])))
}
```
```r
ParamT <- matrix(c(+3.60, -1.00, +3.30, -9.10, -0.90, +3.00,
+3.90, -0.50, +4.10, -8.70, +0.10, +4.00,
+4.50, +0.50, +5.00, -8.10, +1.10, +5.00), ncol = 6, byrow = TRUE)
microbenchmark(ProposeCandidatesGrid1(ParamT),
ProposeCandidatesGrid2(ParamT),
ProposeCandidatesGrid3(ParamT),
ProposeCandidatesGrid4(ParamT),
times = 50L,
unit = "milliseconds")
## Unit: milliseconds
## expr min lq mean median uq max neval
## ProposeCandidatesGrid1(ParamT) 1.7160 1.8258 2.176492 1.85945 1.9305 5.4754 50
## ProposeCandidatesGrid2(ParamT) 1.7570 1.8292 2.090968 1.88125 1.9109 5.5252 50
## ProposeCandidatesGrid3(ParamT) 0.2275 0.2456 0.275084 0.26530 0.2881 0.5601 50
## ProposeCandidatesGrid4(ParamT) 0.2337 0.2466 0.318084 0.26510 0.2856 2.7356 50
```
```r
ParamT <- matrix(c(+1.9, +2.7, -1.1, -9.6, -5.5, +1.0, +3.4, -0.2, +4.5, +3.5, +4.3, -1.5, -4.2, -4.4,
+3.5, +3.4, -0.3, -9.2, -1.6, +2.0, +3.7, +0.0, +5.1, +5.3, +5.6, -0.5, -3.6, -2.7),
ncol = 14, byrow = TRUE)
microbenchmark(ProposeCandidatesGrid1(ParamT),
ProposeCandidatesGrid2(ParamT),
ProposeCandidatesGrid3(ParamT),
ProposeCandidatesGrid4(ParamT),
times = 50L,
unit = "milliseconds")
## Unit: milliseconds
## expr min lq mean median uq max neval
## ProposeCandidatesGrid1(ParamT) 88.6652 92.7099 100.529286 96.37210 100.7031 169.4589 50
## ProposeCandidatesGrid2(ParamT) 84.6542 90.4932 104.274102 95.62470 109.4955 167.5425 50
## ProposeCandidatesGrid3(ParamT) 1.3705 1.4359 1.909450 1.50210 1.5678 15.6336 50
## ProposeCandidatesGrid4(ParamT) 1.3880 1.4408 1.503504 1.48280 1.5404 2.2734 50
}
```
```r
ParamT <- matrix(c(+1.9, +2.7, -1.1, -9.6, -5.5, +1.0, +3.4, -0.2, +4.5, +3.5, +4.3, -1.5, -4.2, -4.4,
+3.5, +3.4, -0.3, -9.2, -1.6, +2.0, +3.7, +0.0, +5.1, +5.3, +5.6, -0.5, -3.6, -2.7,
+3.5, +3.4, -0.3, -9.2, -1.6, +4.0, +3.7, +0.0, +5.1, +5.3, +5.6, -0.5, -3.6, -2.7),
ncol = 14, byrow = TRUE)
ParamT [3, ] <- Sacramento[3, ] + 1
microbenchmark(ProposeCandidatesGrid1(ParamT),
ProposeCandidatesGrid2(ParamT),
ProposeCandidatesGrid3(ParamT),
ProposeCandidatesGrid4(ParamT),
times = 50L,
unit = "milliseconds")
## Unit: milliseconds
## expr min lq mean median uq max neval
## ProposeCandidatesGrid1(ParamT) 31527.7280 35190.369 36366.143 36351.8798 38167.122 40490.213 10
## ProposeCandidatesGrid2(ParamT) 31889.5226 33820.050 35162.053 34758.2704 37117.132 38873.993 10
## ProposeCandidatesGrid3(ParamT) 350.7097 371.400 1505.988 481.6215 2297.846 5384.131 10
## ProposeCandidatesGrid4(ParamT) 347.6815 372.925 1410.104 427.5523 2170.164 4755.841 10
```v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/159Remove useless variables in 'ErrorCrit_NSE'2023-10-19T18:07:35+02:00Delaigue OlivierRemove useless variables in 'ErrorCrit_NSE'The following command lines, usefull for 'ErrorCrit_KGE' and 'ErrorCrit_KGE2', are useless in 'ErrorCrit_NSE' and have to be removed, because the `meanVarObs` and `meanVarSim` objects are note used in the function.
```r
## Other variab...The following command lines, usefull for 'ErrorCrit_KGE' and 'ErrorCrit_KGE2', are useless in 'ErrorCrit_NSE' and have to be removed, because the `meanVarObs` and `meanVarSim` objects are note used in the function.
```r
## Other variables preparation
meanVarObs <- mean(EC$VarObs[!EC$TS_ignore])
meanVarSim <- mean(EC$VarSim[!EC$TS_ignore])
```v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/168Error message slightly wrong for TransfoParamGR5J2023-10-19T18:07:29+02:00Thirel GuillaumeError message slightly wrong for TransfoParamGR5JSee below (it only occurs for TransfoParam_GR5J):
```
> airGR::TransfoParam_GR5J(rep(-9.99, 4), Direction = "TR")
Error in airGR::TransfoParam_GR5J(rep(-9.99, 4), Direction = "TR") :
the GR4J model requires 5 parameters
```
Monkey ...See below (it only occurs for TransfoParam_GR5J):
```
> airGR::TransfoParam_GR5J(rep(-9.99, 4), Direction = "TR")
Error in airGR::TransfoParam_GR5J(rep(-9.99, 4), Direction = "TR") :
the GR4J model requires 5 parameters
```
Monkey tester, à votre service !v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/180Remove use of DLLEXPORT command in Fortran codes2023-10-19T18:06:55+02:00Delaigue OlivierRemove use of DLLEXPORT command in Fortran codesOn 09.08.2023 11:37, Prof Brian Ripley wrote:
> The manual now says
```
Warning to package maintainers: the Intel Fortran compilers interpret comments intended for Visual Fortran like
!DEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'kd...On 09.08.2023 11:37, Prof Brian Ripley wrote:
> The manual now says
```
Warning to package maintainers: the Intel Fortran compilers interpret comments intended for Visual Fortran like
!DEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'kdenestmlcvb' :: kdenestmlcvb
The DLLEXPORT gives a warning but the remainder silently generates incorrectly named entry points. Such comment lines need to be removed from code for use with R (even if using Intel Fortran on Windows).
```
> Such comments are seen in
>
> MixtureRegLTIC PBRF WWR airGR conTree concreg coxphf coxphw groupsubsetselection rBDAT stima
>
> with warnings showing (in an hour or two) as an 'Intel' additional issue on the CRAN resuls page.
>
> Please remove them in your next update.v1.7.6https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/81Remove of the oldest deprecated arguments and functions2022-07-07T14:10:53+02:00Delaigue OlivierRemove of the oldest deprecated arguments and functionsCheck the box when the argument or function is removed.
### 1.0.9.64 Release Notes (2017-11-10)
- [x] `RunSnowModule` argument is now deprecated in `CreateRunOptions()`.
### 1.0.14.1 Release Notes (2018-09-28)
- [x] `LatRad` argum...Check the box when the argument or function is removed.
### 1.0.9.64 Release Notes (2017-11-10)
- [x] `RunSnowModule` argument is now deprecated in `CreateRunOptions()`.
### 1.0.14.1 Release Notes (2018-09-28)
- [x] `LatRad` argument is now deprecated in `PEdaily_Oudin()` and replaced by the `Lat` argument.
- [x] unused `Ind_zeroes` argument of the `CreateInputsCrit()` function is now deprecated.
- [x] `verbose` argument is now deprecated in `CreateInputsCrit()` and replaced by the `warnings` argument.
### 1.2.13.16 Release Notes (2019-04-03)
- [x] `Qobs` argument is now deprecated in `CreateInputsCrit()` and has been renamed `Obs`.
- [x] `FUN_CRIT` argument is now deprecated in `ErrorCrit()`. This function now gets this information from the `InputsCrit` argument.
- [ ] `FUN_CRIT` argument is now deprecated in `Calibration_Michel()`. This function now gets this information from the `InputsCrit` argument.
### 1.3.2.23 Release Notes (2019-06-20)
- [x] `PEdaily_Oudin()` function is deprecated and his use has been replaced by the use of `PE_Oudin()`.
### 1.6.8.44 Release Notes (2021-01-08)
- [ ] `TimeFormat` argument is now deprecated in `SeriesAggreg()`.
- [ ] `NewTimeFormat` argument is now deprecated in `SeriesAggreg()` and replaced by the `Format` argument.v1.8https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/125Remove warnings about parameter threshold during GR5H calibration2022-07-07T14:10:40+02:00Dorchies DavidRemove warnings about parameter threshold during GR5H calibrationTry this:
```r
library(airGR)
example("RunModel_GR5H")
str(RunOptions) # Line ignored when all lines are copy-paste together. Don't know why
CalibOptions <- CreateCalibOptions(RunModel_GR5H)
OutputsCalib <- Calibration(InputsModel = Inp...Try this:
```r
library(airGR)
example("RunModel_GR5H")
str(RunOptions) # Line ignored when all lines are copy-paste together. Don't know why
CalibOptions <- CreateCalibOptions(RunModel_GR5H)
OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions,
InputsCrit = InputsCrit, CalibOptions = CalibOptions,
FUN_MOD = RunModel_GR5H)
```
You get:
```
Grid-Screening in progress (0% 20% 40% 60% 80% 100%)
Screening completed (243 runs)
Param = 55.147, -0.400, 228.149, 11.050, 0.126
Crit. NSE[Q] = 0.0650
Steepest-descent local search in progress
Calibration completed (68 iterations, 913 runs)
Param = 451.901, -0.494, 143.170, 3.555, 0.188
Crit. NSE[Q] = 0.9184
There were 24 warnings (use warnings() to see them)
```
And then:
```
> warnings()
Warning messages:
1: In FUN_MOD(InputsModel = InputsModel, RunOptions = RunOptions, ... :
Param[4] (X4: unit hydrograph time constant [h]) < 0.50
X4 set to 0.50
2: In FUN_MOD(InputsModel = InputsModel, RunOptions = RunOptions, ... :
Param[4] (X4: unit hydrograph time constant [h]) < 0.50
X4 set to 0.50
...
```
I suppose that the bounds of the parameter should be correctly handled in the calibration to avoid this kind of warnings.v1.8https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/124RunOptions always warning "model states initialisation not defined" on GR1A m...2022-07-07T14:10:06+02:00Dorchies DavidRunOptions always warning "model states initialisation not defined" on GR1A modelThe following code:
```r
library(airGR)
data(L0123001)
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J,
DatesR = BasinObs$DatesR,
Precip = BasinObs$P,
...The following code:
```r
library(airGR)
data(L0123001)
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J,
DatesR = BasinObs$DatesR,
Precip = BasinObs$P,
PotEvap = BasinObs$E)
# conversion of InputsModel to target time step
InputsModel <- SeriesAggreg(InputsModel, Format = "%Y")
Ind_WarmUp <- seq(
which(format(InputsModel$DatesR, format = "%Y")=="1985"),
which(format(InputsModel$DatesR, format = "%Y")=="1985")
)
Ind_Run <- seq(
which(format(InputsModel$DatesR, format = "%Y")=="1986"),
which(format(InputsModel$DatesR, format = "%Y")=="2011")
)
# preparation of the RunOptions object
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR1A,
InputsModel = InputsModel,
IndPeriod_Run = Ind_Run,
IndPeriod_WarmUp = Ind_WarmUp)
```
results with the following warning:
```
Warning message:
In CreateRunOptions(FUN_MOD = RunModel_GR1A, InputsModel = InputsModel, :
model states initialisation not defined: default configuration used
```
If I let the default warm up, the warning appears with the usual default warm-up warning:
```r
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR1A,
InputsModel = InputsModel,
IndPeriod_Run = Ind_Run)
```
There is still a warning indicating a wrong initialisation...
```
Warning messages:
1: In CreateRunOptions(FUN_MOD = RunModel_GR1A, InputsModel = InputsModel, :
model warm up period not defined: default configuration used
the year preceding the run period is used
2: In CreateRunOptions(FUN_MOD = RunModel_GR1A, InputsModel = InputsModel, :
model states initialisation not defined: default configuration used
```
Is it a normal behavior? I don't see any clue about this in the documentation.v1.8https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/141Vignette about CemaNeige hysteresis to complete2022-02-21T11:13:52+01:00Thirel GuillaumeVignette about CemaNeige hysteresis to completeAs explained in Riboust et al. (2019)'s paper, the CemaNeige hysteresis must be used with a MeanAnSolidPrecip argument of CreateRunOptions set to different values for each elevation zone. As a consequence, we must add/modify a couple of ...As explained in Riboust et al. (2019)'s paper, the CemaNeige hysteresis must be used with a MeanAnSolidPrecip argument of CreateRunOptions set to different values for each elevation zone. As a consequence, we must add/modify a couple of things in the vignette showing how to use it, as well as in the example of RunModel_CemaNeigeGR4J.
In the vignette:
```r
SolidPrecip_Cal <- rep(0, 5)
SolidPrecip_Val <- rep(0, 5)
for(iLayer in 1:5){
SolidPrecip_Cal[iLayer] <- mean(InputsModel$LayerFracSolidPrecip[[iLayer]][Ind_Cal]*InputsModel$LayerPrecip[[iLayer]][Ind_Cal]);
SolidPrecip_Val[iLayer] <- mean(InputsModel$LayerFracSolidPrecip[[iLayer]][Ind_Val]*InputsModel$LayerPrecip[[iLayer]][Ind_Val]);
}
if(inherits(InputsModel,"hourly" )){ Factor <- 365.25*24; }
if(inherits(InputsModel,"daily" )){ Factor <- 365.25; }
if(inherits(InputsModel,"monthly")){ Factor <- 12; }
if(inherits(InputsModel,"yearly" )){ Factor <- 1; }
SolidPrecip_Cal <- SolidPrecip_Cal*Factor
SolidPrecip_Val <- SolidPrecip_Val*Factor
## preparation of RunOptions object
RunOptions_Cal <- CreateRunOptions(FUN_MOD = RunModel_CemaNeigeGR4J,
InputsModel = InputsModel, IndPeriod_Run = Ind_Cal, IsHyst = TRUE,
MeanAnSolidPrecip = SolidPrecip_Cal)
## preparation of RunOptions object
RunOptions_Val <- CreateRunOptions(FUN_MOD = RunModel_CemaNeigeGR4J,
InputsModel = InputsModel, IndPeriod_Run = Ind_Val, IsHyst = TRUE,
MeanAnSolidPrecip = SolidPrecip_Val)
```
In the example:
```r
SolidPrecip <- rep(0, 5)
for(iLayer in 1:5){
SolidPrecip[iLayer] <- mean(InputsModel$LayerFracSolidPrecip[[iLayer]][Ind_Run]*InputsModel$LayerPrecip[[iLayer]][Ind_Run]);
}
if(inherits(InputsModel,"hourly" )){ Factor <- 365.25*24; }
if(inherits(InputsModel,"daily" )){ Factor <- 365.25; }
if(inherits(InputsModel,"monthly")){ Factor <- 12; }
if(inherits(InputsModel,"yearly" )){ Factor <- 1; }
SolidPrecip <- SolidPrecip*Factor
## preparation of the RunOptions object
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_CemaNeigeGR4J, InputsModel = InputsModel,
IndPeriod_Run = Ind_Run, IsHyst = TRUE, MeanAnSolidPrecip = SolidPrecip)
```
@olivier.delaigue, please make it R beautiful. :D
I'm doing some tests and confirm tomorrow.
Thanks @francois.bourgin for spotting that.v1.8https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/147Clean plot.OutputsModel?2022-02-15T08:54:59+01:00Thirel GuillaumeClean plot.OutputsModel?Are lines 821-822 and 834-835 useful? These variables seem not to be used (anymore?).
```r
SeqQuant <- seq(0, 1, by = 1/(length(DATA2)))
Quant <- as.numeric(quantile(DATA2, SeqQuant, na.rm = TRUE))
```
```r
SeqQ...Are lines 821-822 and 834-835 useful? These variables seem not to be used (anymore?).
```r
SeqQuant <- seq(0, 1, by = 1/(length(DATA2)))
Quant <- as.numeric(quantile(DATA2, SeqQuant, na.rm = TRUE))
```
```r
SeqQuant <- seq(0, 1, by = 1/(length(DATA2)))
Quant <- as.numeric(quantile(DATA2, SeqQuant, na.rm = TRUE))
```v1.7.0https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/117Check the compatibility between the RunOptions and the InputsModel obects2021-11-03T14:24:36+01:00Dorchies DavidCheck the compatibility between the RunOptions and the InputsModel obectsHere the necessary data: [GR4J_crash.RData](/uploads/8f44ff6a10af128a396c78110b9a7e6e/GR4J_crash.RData)
And the code tested on the last `dev` version:
```r
> library(airGR)
> load("GR4J_crash.RData")
> ls()
[1] "InputsModel" "Param" ...Here the necessary data: [GR4J_crash.RData](/uploads/8f44ff6a10af128a396c78110b9a7e6e/GR4J_crash.RData)
And the code tested on the last `dev` version:
```r
> library(airGR)
> load("GR4J_crash.RData")
> ls()
[1] "InputsModel" "Param" "RunOptions"
> Param
[1] 169.017118 -2.375568 20.697233 1.417417
> RunModel_GR4J(InputsModel, RunOptions, Param)
Error in RunModel_GR4J(InputsModel, RunOptions, Param) :
NA/NaN/Inf in foreign function call (arg 2)
```
The error occurs in the Fortran call. I don't know how to debug that...v1.8Delaigue OlivierDelaigue Olivierhttps://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/133SeriesAggreg: Reorder regime time series and keep original data.frame column ...2021-07-15T09:56:33+02:00Delaigue OlivierSeriesAggreg: Reorder regime time series and keep original data.frame column names
## Row order
When a user wants to calculate the monthly regime from a time series that does not start in January, the resulting time series is not ordered chronologically:
```r
## loading catchment data
data(L0123002)
## preparation...
## Row order
When a user wants to calculate the monthly regime from a time series that does not start in January, the resulting time series is not ordered chronologically:
```r
## loading catchment data
data(L0123002)
## preparation of the initial time series data frame at the daily time step
TabSeries <- BasinObs[-c(1:100), c("DatesR", "P", "E", "T", "Qmm")]
## monthly regimes
NewTabSeries <- SeriesAggreg(TabSeries,
Format = "%m",
ConvertFun = c("sum", "sum", "mean", "sum"))
NewTabSeries
```
```
DatesR P E T Qmm
25 1985-01-01 4561.75 0.000 -4.38509320 801.5458
1638 1985-02-01 3628.40 137.333 -3.19772073 885.9376
2514 1985-03-01 3285.26 918.967 -0.06520829 1419.2986
3204 1984-04-10 2951.83 1945.714 3.62350569 3228.6649
4204 1984-05-01 3039.24 3060.999 7.44770178 6952.6141
5151 1984-06-01 2550.69 3655.168 11.41753270 5886.3055
6049 1984-07-01 1463.55 3980.017 15.21047230 1728.8110
6857 1984-08-01 1369.97 3609.238 15.05654527 528.8462
7770 1984-09-01 1914.48 2685.482 10.52281546 407.1385
8724 1984-10-01 2596.42 1697.494 4.53778871 487.0308
9587 1984-11-01 4752.38 645.070 -2.62700563 750.2040
10440 1984-12-01 4870.14 44.293 -5.27928687 903.0798
```
This can lead to a counter-intuitive behavior...
```r
plot(NewTabSeries[, c("DatesR", "Qmm")], type = "l")
```
![image](/uploads/c1dbe9fff6950039947a5eb5446976f1/image.png)
One possibility is to reorder the table by the date culumn. The other solution, which I prefer, is to impose the same year (which doesn't really make sense).
## Column names
Another problem that we have already talked about. But the function automatically renames the date column of a data.frame, which is not very polite to the user.
```r
## preparation of the initial time series data frame at the daily time step
TabSeries <- BasinObs[-c(1:100), c("DatesR", "P", "E", "T", "Qmm")]
colnames(TabSeries) <- LETTERS[1:5]
## monthly regimes
NewTabSeries <- SeriesAggreg(TabSeries,
Format = "%m",
ConvertFun = c("sum", "sum", "mean", "sum"))
head(NewTabSeries)
```
```
DatesR B C D E
25 1985-01-01 4561.75 0.000 -4.38509320 801.5458
1638 1985-02-01 3628.40 137.333 -3.19772073 885.9376
2514 1985-03-01 3285.26 918.967 -0.06520829 1419.2986
3204 1984-04-10 2951.83 1945.714 3.62350569 3228.6649
4204 1984-05-01 3039.24 3060.999 7.44770178 6952.6141
5151 1984-06-01 2550.69 3655.168 11.41753270 5886.3055
```v1.7.0https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/84Add the use of '['.OutputsModel in plot.OutputsModel2021-07-14T10:14:45+02:00Delaigue OlivierAdd the use of '['.OutputsModel in plot.OutputsModelIt could be nice to simplify the code of the `plot.OutputsModel()` function by the use of '['.OutputsModel in order to manage the `IndPeriod_Plot` argument.It could be nice to simplify the code of the `plot.OutputsModel()` function by the use of '['.OutputsModel in order to manage the `IndPeriod_Plot` argument.v2.0https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/42Add new function to manage time steps2021-04-19T09:09:56+02:00Delaigue OlivierAdd new function to manage time stepsIt is maybe a good idea to create an internal function to manage the time steps in order to avoid command lines in many functions:
```
if ("daily" %in% class(XXXXXXX)) {
TimeStep <- 60 * 60 * 24
}
if ("hourly" %in% class(XXXXXXX)) {
...It is maybe a good idea to create an internal function to manage the time steps in order to avoid command lines in many functions:
```
if ("daily" %in% class(XXXXXXX)) {
TimeStep <- 60 * 60 * 24
}
if ("hourly" %in% class(XXXXXXX)) {
TimeStep <- 60 * 60
}
```https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/56Remove useless time step checks in the plot.OutputsModel function2021-04-19T09:08:06+02:00Delaigue OlivierRemove useless time step checks in the plot.OutputsModel functionThe time step of the `OutputsModel` argument is checked by the `plot.OutputsModel()` function (the time step is checked by comparing with the calculation of the difference of the last two time steps). This seems useless, because we alrea...The time step of the `OutputsModel` argument is checked by the `plot.OutputsModel()` function (the time step is checked by comparing with the calculation of the difference of the last two time steps). This seems useless, because we already check the class of this object, which is therefore assumed to be necessarily valid.
In addition, this stops the function from being used on an aggregated series returned by the `SeriesAggreg2.OutputsModel ()` function.https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/93Warning at compilation due to potentially uninitialised variable2021-01-27T17:39:16+01:00Pelletier AntoineWarning at compilation due to potentially uninitialised variableA warning is produced by GCC Fortran compiler while installing airGR version 1.6.9.27, due to a _may be uninitialized variable_.
## How to reproduce the bug?
1. Clone master branch of repository at commit `88db83a415ac97742353fc06245c4...A warning is produced by GCC Fortran compiler while installing airGR version 1.6.9.27, due to a _may be uninitialized variable_.
## How to reproduce the bug?
1. Clone master branch of repository at commit `88db83a415ac97742353fc06245c40255535f6e7`
2. Run `R CMD build airgr`
3. Run `R CMD INSTALL airGR_1.6.9.27.tar.gz`
**Used software:** openSUSE Leap 15.2 with Linux 5.3.18-lp152.60-default kernel; GNU Fortran 11.0.0 20210122 for SUSE Linux; R version 4.0.3
**Compilation flags:** `-fno-optimize-sibling-calls -fpic -std=f2018 -fmessage-length=0 -grecord-gcc-switches -O3 -Wall -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection`
## Expected behaviour
Compilation and installation without warning.
## Actual behaviour
Warning while compiling `frun_GR5H.f90`:
```console
gfortran -fno-optimize-sibling-calls -fpic -std=f2018 -fmessage-length=0 -grecord-gcc-switches -O3 -Wall -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -c frun_GR5H.f90 -o frun_GR5H.o
frun_GR5H.f90:93:26:
93 | IF (IsIntStore .EQV. .TRUE.) St(3) = StateStart(4)
| ^
Avertissement: « isintstore » may be used uninitialized [-Wmaybe-uninitialized]
frun_GR5H.f90:71:27:
71 | logical :: IsIntStore ! TRUE if interception store is used, FALSE otherwise
| ^
note: « isintstore » déclaré ici
```
## Proposed solution
Change lines 79 and 80 of `frun_GR5H.f90` to an if-else statement:
```fortran
IF (Imax .LT. 0.) THEN
IsIntStore = .FALSE.
ELSE
IsIntStore = .TRUE.
ENDIF
```v1.6.10https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/92Stop Imax when the time series is not complete2021-01-27T13:41:19+01:00Delaigue OlivierStop Imax when the time series is not complete`Imax()` does not work if the aggregated daily time series is not complete.
In this example Ind_Run1 stops at 11 p.m and Ind_Run2 stops at 10 p.m.
```r
library(airGR)
## loading catchment data
data(L0123003)
## preparation of the In...`Imax()` does not work if the aggregated daily time series is not complete.
In this example Ind_Run1 stops at 11 p.m and Ind_Run2 stops at 10 p.m.
```r
library(airGR)
## loading catchment data
data(L0123003)
## preparation of the InputsModel object
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR5H, DatesR = BasinObs$DatesR,
Precip = BasinObs$P, PotEvap = BasinObs$E)
## run period selection
Ind_Run1 <- seq(which(format(BasinObs$DatesR, format = "%Y-%m-%d %H:%M")=="2006-01-01 00:00"),
which(format(BasinObs$DatesR, format = "%Y-%m-%d %H:%M")=="2006-12-31 23:00"))
Ind_Run2 <- Ind_Run1[-length(Ind_Run1)]
## Imax computation on Ind_Run1
Imax(InputsModel = InputsModel, IndPeriod_Run = Ind_Run1,
TestedValues = seq(from = 0, to = 3, by = 0.2))
##
## 1.4
##
## Imax computation on Ind_Run1
Imax(InputsModel = InputsModel, IndPeriod_Run = Ind_Run2,
TestedValues = seq(from = 0, to = 3, by = 0.2))
##
## numeric(0)
##
```
This is caused by the new behavior of `SerriesAggreg()` ()line 35 that returns a NA value when the time series is not complete for the aggregated time step.
```
DatesR Precip PotEvap
17377 2006-12-26 0.00 0.10
17401 2006-12-27 0.00 0.20
17425 2006-12-28 0.00 0.38
17449 2006-12-29 1.87 0.38
17473 2006-12-30 6.88 0.52
17497 2006-12-31 NA NA
```
So in this case, it would be better to stop the computation of `Imax()`.
In addition, the code could be simplified using the `[.InputsModel` method (line 32).v1.6.10https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/95Move CemaNeige daily gradients outside DataAltiExtrapolation_Valery2021-01-27T13:40:43+01:00Delaigue OlivierMove CemaNeige daily gradients outside DataAltiExtrapolation_ValeryMove `GradT_Valery2010()` in an utils file, outside `DataAltiExtrapolation_Valery()` in order to make it more readable.
In additon, set `GradP_Valery2010` as a vector and `GradT_Valery2010` as a data.frame instead of functions.
Rename ...Move `GradT_Valery2010()` in an utils file, outside `DataAltiExtrapolation_Valery()` in order to make it more readable.
In additon, set `GradP_Valery2010` as a vector and `GradT_Valery2010` as a data.frame instead of functions.
Rename `GradT_Valery2010` into `.GradT_Valery2010`.v1.6.10https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/issues/91Remove plot.OutputsModel from NAMESPACE2021-01-15T08:47:47+01:00Delaigue OlivierRemove plot.OutputsModel from NAMESPACEThe `plot.OutputsModel()` function has been export again in order not to break the reverse dependency of the current version of airGRteaching (v0.2.9.25) available on the CRAN (see #89, ab853bd3). This break has already been fixed in the...The `plot.OutputsModel()` function has been export again in order not to break the reverse dependency of the current version of airGRteaching (v0.2.9.25) available on the CRAN (see #89, ab853bd3). This break has already been fixed in the development version of airGRteaching ([v0.2.10](https://gitlab.irstea.fr/HYCAR-Hydro/airgrteaching/-/milestones/1)) that will be submitted to CRAN shortly after airGR [v1.6](https://gitlab.irstea.fr/HYCAR-Hydro/airgr/-/milestones/2).
Once the new versions of airGR and airGRteaching will be available on CRAN. This function can be removed from the NAMESPACE again from the development version of airGR.v2.0