Skip to content

Dev#14

Open
mrustl wants to merge 11 commits into
mainfrom
dev
Open

Dev#14
mrustl wants to merge 11 commits into
mainfrom
dev

Conversation

@mrustl

@mrustl mrustl commented Jun 3, 2026

Copy link
Copy Markdown
Member

No description provided.

claude and others added 11 commits June 3, 2026 12:28
ET0 fix: both full workflows now divide the daily ET0 by its interval in hours
(period_et = 24) before writing //Kurven/ET0, mirroring the rain conversion.
The kernel reads the ET0 curve as a mm/h rate, so unconverted daily values were
integrated 24x too high.

RAM: run_one() now thins each run to its single optimisation row immediately
(get_simulation_results_optim(lean = TRUE) + add_overflow_events_and_waterbalance)
and returns it; run_scenarios() collects the one-row tibbles and the analyse
chunk just binds them. This removes the get_simulation_results_optim_parallel()
pass that loaded every run's full time series into memory at once. New 'lean'
arg on get_simulation_results_optim() reads only the fields the optimisation
summary needs (element rates + both water balances), nulling states/meta/
connected-area rates; its intro message is gated behind debug.
Apply the same memory fix as Wien/BadAussee: run_one() now thins each run to
its optimisation row immediately (get_simulation_results_optim(lean = TRUE) +
add_overflow_events_and_waterbalance) and returns it; run_scenarios() collects
the rows and the analyse chunk binds them, replacing the
get_simulation_results_optim_parallel() pass that held every run's full time
series at once. No ET0 unit change here: the Eisenstadt workflows use the
base.h5 constant ET0 placeholder (0.2 mm/h) and the template rain (already
mm/h), so there is no mm/d daily series to convert.
Summary page linking the per-site brute-force outputs (workflow html, result
tables, CSVs, interactive plots). Added to .Rbuildignore so R CMD check does
not build/execute it; render it manually into the assembled results directory.
Result-file links match each workflow's paths$modelname (Wien, BadAussee,
Eisenstadt_2005).
Since the workflows now thin per run inside run_one(), reading happens inside
the future_lapply batch. A result file that exists but cannot be opened/read
(engine crashed mid-write for a scenario, or a transient lock) previously threw
H5File.open() 'unable to open file' and aborted the whole render at the
run_model chunk. Wrap the open+read in an inner function (own on.exit for handle
cleanup) plus tryCatch: such a file is now treated like a missing one -- warn,
name the scenario, return NULL -- so add_overflow_events_and_waterbalance()
emits an NA row and the batch completes.
R CMD check failed with a codoc WARNING because the .Rd still documented the
old signature (no 'lean'). Regenerate the usage block and add the \item{lean}
documentation to match R/get_simulation_results_optim.R (devtools::document()
equivalent), clearing the only WARNING (the 3 NOTEs are pre-existing).
to do: adapt Eisenstadt to the same parameter
Consistency:

- workflow_eisenstadt-2005.Rmd and workflow_eisenstadt-2005_neu.Rmd
  now unconditionally set
  //Massnahmenelemente/Mulde_Rigole/Parameter_Evapotranspiration/LAI_LeafAreaIndex
  = 3.9 (Hoernschemeyer grass value, Water 2023, 15, 2840, Tab. 6,
  plant type 5). Wien already sweeps LAI over c(3.9, 8.5); Bad
  Aussee uses the same sweep grid as Wien; Eisenstadt was the
  outlier still running on the base.h5 default 8.5.

New feature:

- plot_cost_vs_overflow_volume() -- new exported ggplot helper
  mirroring plot_wb_tradeoff_overflows() for cost-aware optimisation.
  x = cost_total (EUR), y = overflow volume in m3 (computed from
  sum_overflows [mm] * mulde_area [m2] / 1000), points coloured
  discretely by n_overflows using the same 0..x / ">x" palette and
  top legend. Plotly tooltip carries the cost breakdown
  (cost_excavation / _profiling / _filter / _storage / _total) plus
  the varying param_grid entries.

- Each of the four case-study workflow vignettes
  (workflow_wien, workflow_badaussee, workflow_eisenstadt-2005,
  workflow_eisenstadt-2005_neu) now renders the plot as
  simulation_results_optimisation_<site>_cost-vs-overflow-volume.html
  right after the existing water-balance render, matching its PDF /
  saveWidget pattern exactly.

- vignettes/index.Rmd gains a new "Kosten vs. Überlaufvolumen"
  section under "Interaktive Visualisierungen" that links to the
  three top-level sites (Eisenstadt 2005, Wien, Bad Aussee).

https://claude.ai/code/session_014QrjF51tg7cMVmsgjmfPNG
Builds on the cost-vs-overflow-volume plot (PR #15) with a new
cost-by-overflow-count boxplot (three best-selection variants), richer
tooltips and i18n parameter labels, and fixes the Eisenstadt cost
pipeline the PR review flagged.

Bug fix (PR #15 review blocker):

- vignettes/workflow_eisenstadt-2005.Rmd now pipes the joined
  optimisation results through kwb.raindrop::compute_costs(), like the
  Wien and Bad Aussee workflows already did. Without it the vignette's
  plot_cost_vs_overflow_volume() call aborted with "missing column(s):
  cost_excavation, ..." on Windows, so the cost PDF/HTML was never
  produced and the exported CSV lacked the cost columns.

New plot -- plot_cost_overflow_boxplot() (exported):

- Boxplot of total construction cost (EUR, y) per number of overflow
  events (x). Counts 0..x each get their own box (x = max_n_overflows,
  as in the sibling plots); higher counts collapse into a single ">x"
  catch-all box (furthest right, red), keeping the axis readable for the
  long-tailed 15-year runs (Wien / Bad Aussee reach several hundred
  overflow events). The ">x" box highlights the scenario with the fewest
  overflow events above x (closest to valid), best_by breaking ties.
- Individual scenarios are overlaid as jittered points whose size
  scales with a chosen variable (size_by): the overflow volume (m3,
  default) or the element evapotranspiration share (%). The size scale
  is calibrated to the valid region (0..x) and capped, with a minimum
  size, so the many-overflow outliers of the ">x" box do not shrink the
  valid-region points to invisible dots.
- One best scenario per box is highlighted with a black-outlined diamond
  in that box's group colour (so its tooltip inherits the group colour)
  and the best of all boxes are joined by a frontier line (mark_best /
  connect_best). best_by picks the objective, cost as tie-breaker --
  "min_cost" (cheapest), "min_overflow" (smallest overflow volume) or
  "max_evapotranspiration" (highest evapotranspiration) -- so the three
  variants trace three different frontier lines; label_best annotates
  the marker ("NN m3 / NN %" or "NN %").
- Each case-study vignette loops the three variants into
  *_cost-by-overflows-boxplot-{cheapest,min-overflow,max-evap}.html,
  all linked from vignettes/index.Rmd, which now groups the cost plots
  under one "Kosten" heading with sub-points (toc_depth 4).

Tooltip enrichment (shared helpers in R/cost_tooltip.R):

- The plotly tooltip of plot_cost_vs_overflow_volume() now carries the
  element water balance (evapotranspiration / infiltration / overflow,
  all in %) in addition to the cost breakdown, and names the chosen
  storage type on its own bold line, bilingually ("Sickerbox /
  Infiltration box" or "Schotterrigol / Gravel trench").
- The "varying parameters" block is translated via the new exported
  default_param_labels() helper -- a hovered point shows e.g.
  "Muldenflaeche [m2]=125" (de) / "Swale area [m2]=125" (en) instead of
  the raw "mulde_area=125"; override with param_labels =.
- cost_tooltip_labels() / cost_tooltip_text() / build_varying_param_html()
  are shared so both cost plots emit byte-identical tooltips.

Code hygiene:

- All non-ASCII characters in R code (string literals in the plot
  functions and in the vignette code chunks) are unicode-escaped
  (\uXXXX); the few non-ASCII code comments were rewritten in plain
  ASCII ("Hoernschemeyer", "2xN"). Markdown prose keeps UTF-8.

New exports: plot_cost_overflow_boxplot(), default_param_labels().
Both plot_cost_vs_overflow_volume() and plot_cost_overflow_boxplot()
now append the share of scenarios meeting the validity criterion
(n_overflows <= x) to the plot title, e.g.
"Kosten vs. Ueberlaufvolumen (39 % mit <= 5 Ueberlaeufen)" /
"Cost vs. overflow volume (39 % with <= 5 overflows)".
It goes in the title, not a ggplot subtitle: ggplotly drops subtitles,
so the share would be lost in the interactive HTML the vignettes export.
The scatter title drops its old "(Anzahl Ueberlaeufe <= x)"
parenthetical, which the share now supersedes.
vignettes/index.Rmd now spells out the per-site validity threshold that
drives this share: Eisenstadt <= 1 (1-year simulation), Wien / Bad
Aussee <= 5 (15-year rain/ET series).
…flow-plot

Cost-vs-overflow-volume plot + Eisenstadt LAI 3.9 consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants