Skip to content

Commit 90da095

Browse files
author
Dongchen Zhang
committed
Add the input check.
1 parent 06b78e0 commit 90da095

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

modules/assim.sequential/R/sda.enkf_MultiSite.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,30 @@ sda.enkf.multisite <- function(settings,
329329
#reformatting params
330330
new.params <- sda_matchparam(settings, ensemble.samples, site.ids, nens)
331331
# if it's not a restart run, we will generate the joint input design.
332+
# following code tries to catch if there is any mismatch between
333+
# samplingspace and site inputs.
334+
# get the input names that are registered for sampling.
335+
names.sampler <- names(settings$ensemble$samplingspace)
336+
# remove parameters field from the list.
337+
names.sampler <- names.sampler[-which(names.sampler == "parameters")]
338+
mis.match.table <- settings %>% purrr::map(function(s){
339+
# get the input names for the current site.
340+
names.site.input <- names(s$run$inputs)
341+
# check if there is any mismatch.
342+
inds <- which(!names.sampler %in% names.site.input)
343+
# if this site has missing inputs.
344+
if (length(inds) > 0) {
345+
return(data.frame(site_id = s$run$site$id, missed.input = names.sampler[inds]))
346+
}
347+
}) %>% dplyr::bind_rows()
348+
# if we see any site that has missing inputs.
349+
if (nrow(mis.match.table) > 0) {
350+
PEcAn.logger::logger.info("There are sites that have missing inputs than the sampling space.")
351+
return(mis.match.table)
352+
}
353+
354+
# find a site that has all registered inputs except for the parameter field.
355+
if (all(names.sampler %in% names.site.input)) {}
332356
# get the joint input design.
333357
input_design <- PEcAn.uncertainty::generate_joint_ensemble_design(settings = settings[[1]],
334358
ensemble_samples = ensemble.samples,

0 commit comments

Comments
 (0)