setEnsemblePaths.Rd
Propagates a filename pattern into the relevant paths of a multi-site
settings. For example if your files are named like "mymet/siteA/scenario1.nc"
up through "mymet/siteZ/scenario50.nc",
setEnsemblePaths(settings, n_reps = 50, "mymet/{id}/scenario{n}.nc")
will
add them all to your settings in one shot.
setEnsemblePaths(
settings,
n_reps,
input_type = c("met", "poolinitcond", "soilinitcond"),
path_template = "./{id}/{n}.nc",
...
)
updated settings object
Operates on one input section (met, poolinitcond, etc) at a time because it's common to have different path conventions for met vs IC.
The path template should be a string recognized by glue::glue()
,
with curly braces wrapping any expressions to be interpolated.
{n}
will be replaced with each value of 1:n_reps
, {id}
will be
replaced with the siteid of each site, and any other variables need to be
passed as named arguments in ...
.
Note that for consistency, every site in settings
must contain an
element named inputs$<input_type>
before you call this.
If inputs$<input_type>$path
does not exist it will be created;
if it does exist it will be overwritten.
s <- as.Settings(list(
run = list(
start.date = "TBD",
site = list(),
inputs = list(
met = list(),
poolinitcond = list()
)
)
))
m <- createMultiSiteSettings(s, c("a1", "b2"))
m1 <- setEnsemblePaths(m, 2)
m1$run$site.a1$inputs
#> $met
#> $met$path
#> $met$path$path1
#> [1] "./a1/1.nc"
#>
#> $met$path$path2
#> [1] "./a1/2.nc"
#>
#>
#>
#> $poolinitcond
#> list()
#>
m2 <- setEnsemblePaths(
m, 2, "poolinitcond",
icdir = "some/long/path",
path_template = "{icdir}/{id}/{n}.nc"
)
m2$run$site.a1$inputs
#> $met
#> list()
#>
#> $poolinitcond
#> $poolinitcond$path
#> $poolinitcond$path$path1
#> [1] "some/long/path/a1/1.nc"
#>
#> $poolinitcond$path$path2
#> [1] "some/long/path/a1/2.nc"
#>
#>
#>