-
Notifications
You must be signed in to change notification settings - Fork 282
Add codes to extract SoilGrids soil texture data and derive ensemble … #3406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bbb795d
968ccca
c5f51f8
326e18d
14be6bf
b280f00
f0319d5
53283f5
3d68b74
a07004f
c0c557c
6cbf62b
b731ed2
cca24fd
844042a
54babea
d17a239
b26c47f
a85b9bd
de04744
75987ce
73d1098
7ff6c05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,17 +355,47 @@ sda.enkf.multisite <- function(settings, | |
| #reformatting params | ||
| new.params <- sda_matchparam(settings, ensemble.samples, site.ids, nens) | ||
| } | ||
| #sample met ensemble members | ||
| #TODO: incorporate Phyllis's restart work | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please retain this comment, which will be helpful to the folks working on uncertainty partitioning.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| # sample all inputs specified in the settings$ensemble not just met | ||
| inputs <- PEcAn.settings::papply(conf.settings,function(setting) { | ||
| PEcAn.uncertainty::input.ens.gen( | ||
| settings = setting, | ||
| input = "met", | ||
| method = setting$ensemble$samplingspace$met$method, | ||
| parent_ids = NULL | ||
| ) | ||
| }) | ||
|
|
||
|
|
||
| #TODO: incorporate Phyllis's restart work | ||
| #sample all inputs specified in the settings$ensemble | ||
| #now looking into the xml | ||
| samp <- conf.settings$ensemble$samplingspace | ||
| #finding who has a parent | ||
| parents <- lapply(samp,'[[', 'parent') | ||
| #order parents based on the need of who has to be first | ||
| order <- names(samp)[lapply(parents, function(tr) which(names(samp) %in% tr)) %>% unlist()] | ||
| #new ordered sampling space | ||
| samp.ordered <- samp[c(order, names(samp)[!(names(samp) %in% order)])] | ||
| #performing the sampling | ||
| inputs <- vector("list", length(conf.settings)) | ||
| #for the tags specified in the xml, do the sampling for a random site and then replicate the same sample ids for the remaining sites for each ensemble member | ||
| for (i in seq_along(samp.ordered)) { | ||
| random_site <- sample(1:length(conf.settings),1) | ||
| if (is.null(inputs[[random_site]])) { | ||
| inputs[[random_site]] <- list() | ||
| } | ||
| input_tag<-names(samp.ordered)[i] | ||
| #call the function responsible for generating the ensemble for the random site | ||
| inputs[[random_site]][[input_tag]] <- PEcAn.uncertainty::input.ens.gen(settings=conf.settings[[random_site]], | ||
| input=input_tag, | ||
| method=samp.ordered[[i]]$method, | ||
| parent_ids=NULL) | ||
| #replicate the same ids for the remaining sites | ||
| for (s in seq_along(conf.settings)) { | ||
| if (s!= random_site) { | ||
| if (is.null(inputs[[s]])) { | ||
| inputs[[s]] <- list() | ||
| } | ||
| input_path <- conf.settings[[s]]$run$inputs[[tolower(input_tag)]]$path | ||
| inputs[[s]][[input_tag]]$ids<-inputs[[random_site]][[input_tag]]$ids | ||
| inputs[[s]][[input_tag]]$samples<- input_path[inputs[[random_site]][[input_tag]]$ids] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good start. Tagging @blesson07asd so he's aware of these changes and can account for them when he further generalizes ensemble sampling. Eventually this will need to be expanded to account for parameter sampling too, but we can do that later. |
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| ###------------------------------------------------------------------------------------------------### | ||
| ### loop over time ### | ||
| ###------------------------------------------------------------------------------------------------### | ||
|
|
@@ -380,7 +410,7 @@ sda.enkf.multisite <- function(settings, | |
| #for next time step split the met if model requires | ||
| #-Splitting the input for the models that they don't care about the start and end time of simulations and they run as long as their met file. | ||
| inputs.split <- metSplit(conf.settings, inputs, settings, model, no_split = FALSE, obs.times, t, nens, restart_flag = FALSE, my.split_inputs) | ||
|
|
||
| #---------------- setting up the restart argument for each site separately and keeping them in a list | ||
| restart.list <- | ||
| furrr::future_pmap(list(out.configs, conf.settings %>% `class<-`(c("list")), params.list, inputs.split), | ||
|
|
@@ -412,9 +442,8 @@ sda.enkf.multisite <- function(settings, | |
| X <- X | ||
| }else{ | ||
| if (control$debug) browser() | ||
| out.configs <- conf.settings %>% | ||
| `class<-`(c("list")) %>% | ||
| furrr::future_map2(restart.list, function(settings, restart.arg) { | ||
|
|
||
| out.configs <-furrr::future_pmap(list(conf.settings %>% `class<-`(c("list")),restart.list, inputs), function(settings, restart.arg, inputs) { | ||
| # Loading the model package - this is required bc of the furrr | ||
| library(paste0("PEcAn.",settings$model$type), character.only = TRUE) | ||
| # wrtting configs for each settings - this does not make a difference with the old code | ||
|
|
@@ -425,6 +454,7 @@ sda.enkf.multisite <- function(settings, | |
| model = settings$model$type, | ||
| write.to.db = settings$database$bety$write, | ||
| restart = restart.arg, | ||
| samples=inputs, | ||
| rename = TRUE | ||
| ) | ||
| }) %>% | ||
|
|
@@ -767,4 +797,5 @@ sda.enkf.multisite <- function(settings, | |
| # } | ||
| ## MCD: I commented the above "if" out because if you are restarting from a previous forecast, this might delete the files in that earlier folder | ||
| } ### end loop over time | ||
| } # sda.enkf | ||
| } # sda.enkf | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.