Build demo data
This notebook regenerates outputs for the demonstrations. We generally do not want to run it every time.
This is a big run, best to do it in parallel.
future::plan(future::multisession)
# Outer directory for scenario
project_dir <- file.path("more_scenarios")
# Preexisting data
# Hydrographs (expected to exist already)
hydro_dir <- file.path(project_dir, "hydrographs")
# Generated data
# EWR outputs (will be created here in controller, read from here in aggregator)
ewr_results <- file.path(project_dir, "module_output", "EWR")
# outputs of aggregator. There may be multiple modules
agg_results <- file.path(project_dir, "aggregator_output")
Run the EWR tool
Using rparallel = TRUE
for speed to parallelise over all scenarios.
if (params$REBUILD_EWR) {
ewr_out <- prep_run_save_ewrs(
hydro_dir = hydro_dir,
output_parent_dir = project_dir,
outputType = list("yearly"),
rparallel = TRUE
)
}
Aggregate
Use a ‘standard’ aggregation sequence, as in getting started.
Some of the example gauges provide information into other sdl units, but since we do not have full gauge coverage in those units, we clip to only those that are relevant.
aggseq <- list(
all_time = "all_time",
ewr_code = c("ewr_code_timing", "ewr_code"),
env_obj = c("ewr_code", "env_obj"),
sdl_units = sdl_clip,
Target = c("env_obj", "Target"),
mdb = basin,
target_5_year_2024 = c("Target", "target_5_year_2024")
)
funseq <- list(
all_time = "ArithmeticMean",
ewr_code = "CompensatingFactor",
env_obj = "ArithmeticMean",
sdl_units = "ArithmeticMean",
Target = "ArithmeticMean",
mdb = "SpatialWeightedMean",
target_5_year_2024 = "ArithmeticMean"
)
Be explicit instead of using auto_ewr_PU
if (params$REBUILD_AGG) {
aggout <- read_and_agg(
datpath = ewr_results,
type = "achievement",
geopath = bom_basin_gauges,
causalpath = causal_clip,
groupers = "scenario",
aggCols = "ewr_achieved",
group_until = list(
SWSDLName = is_notpoint,
planning_unit_name = is_notpoint,
gauge = is_notpoint
),
pseudo_spatial = "sdl_units",
aggsequence = aggseq,
funsequence = funseq,
saveintermediate = TRUE,
namehistory = FALSE,
keepAllPolys = FALSE,
returnList = TRUE,
savepath = agg_results,
rparallel = TRUE,
add_max = FALSE
)
}