Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f84cd8

Browse files
author
David
committed
fix(Ungauged): fixed parameters inside ungauged node cluster
Refs #168
1 parent363b4e9 commit8f84cd8

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

‎R/Calibration.GRiwrmInputsModel.R‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Calibration.GRiwrmInputsModel <- function(InputsModel,
5353
IM<-l$InputsModel
5454
message("Calibration.GRiwrmInputsModel: Processing sub-basins '",
5555
paste(names(IM),collapse="', '"),"' with '",id,"' as gauged donor...")
56-
IM$FUN_MOD<-"RunModel_Ungauged"
5756
attr(RunOptions[[id]],"GRiwrmRunOptions")<-l$RunOptions
5857
}else {
5958
message("Calibration.GRiwrmInputsModel: Processing sub-basin '",id,"'...")
@@ -92,11 +91,10 @@ Calibration.GRiwrmInputsModel <- function(InputsModel,
9291
}
9392

9493
if (hasUngauged) {
95-
# Select nodes with model in the sub-network
96-
g<- attr(IM,"GRiwrm")
97-
Ids<-g$id[!is.na(g$donor)&g$donor==id&g$id!=id]
94+
Ids<- names(IM)
95+
Ids<-Ids[Ids!=id]
9896
for (uIdinIds) {
99-
if (!IM[[uId]]$isReservoir) {
97+
if (IM[[uId]]$gaugedId==id) {
10098
# Add OutputsCalib for ungauged nodes
10199
OutputsCalib[[uId]]<-list(
102100
ParamFinalR= transferGRparams(InputsModel,

‎R/Calibration.R‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#' function using the provided functions.
55
#'
66
#' This function can be used either for a catchment (with an \emph{InputsModel}
7-
#' object) or for a network (with a \emph{GRiwrmInputsModel} object)
7+
#' object), for a network (with a \emph{GRiwrmInputsModel} object), or for an
8+
#' ungauged node cluster (with a \emph{Ungauged} object).
89
#'
910
#' @param InputsModel \[object of class \emph{InputsModel} or \emph{GRiwrmInputsModel}\] see [CreateInputsModel]
1011
#' @param RunOptions \[object of class \emph{RunOptions} or \emph{GRiwrmRunOptions}\] see [CreateRunOptions]
@@ -35,3 +36,10 @@
3536
Calibration<-function(InputsModel,...) {
3637
UseMethod("Calibration",InputsModel)
3738
}
39+
40+
#' @rdname Calibration
41+
#' @export
42+
Calibration.Ungauged<-function(InputsModel,...) {
43+
InputsModel$FUN_MOD<-"RunModel_Ungauged"
44+
NextMethod()
45+
}

‎R/utils.Calibration.R‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ updateParameters4Ungauged <- function(GaugedId,
115115
}
116116
}
117117

118-
# Add class InputsModel for airGR::Calibration checks
119-
class(InputsModel)<- c("InputsModel", class(InputsModel))
118+
# Add class RunModel_Ungauged and InputsModel for preprocessind
119+
# and processing airGR::Calibration
120+
class(InputsModel)<- c("Ungauged","InputsModel", class(InputsModel))
120121

121122
### Modify RunOptions for the reduced network ###
122123
RunOptions<- reduceGRiwrmObj4Ungauged(g,RunOptions)

‎tests/testthat/test-RunModel_Ungauged.R‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ test_that("Gauged node inside ungauged cluster must only work if parameters are
366366
for (xin ls(e)) assign(x, get(x,e))
367367
rm(e)
368368
expect_error(Calibration(InputsModel,RunOptions,InputsCrit,CalibOptions),
369-
regexp="")
370-
369+
regexp="Node '54032' .* must have its parameters fixed")
370+
CalibOptions[["54032"]]$FixedParam<-ParamMichel[["54032"]]
371+
OC<- Calibration(InputsModel,RunOptions,InputsCrit,CalibOptions)
372+
expect_equal(OC[["54032"]]$ParamFinalR,ParamMichel[["54032"]])
371373
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp