Skip to content

Add postprocessing module for the PWN model (09pwnmodel2) - #40

Merged
bdestombe merged 1 commit into
mainfrom
add-postprocessing-module
Jul 6, 2026
Merged

bdestombe merged 1 commit into
mainfrom
add-postprocessing-module

Conversation

@bdestombe

Copy link
Copy Markdown
Member

What

Extracts the post-run steps of modelscripts/09pwnmodel2/01_pwnmodel2.py (everything after nlmod.sim.write_and_run) into nhflotools.postprocessing:

  • check_budget_discrepancy — mass-balance guard (flopy Mf6ListBudget)
  • add_output_to_ds — loads heads/concentration; derives head_filled, conc_filled, freshwater_head, grensvlak_zoet/grensvlak_brak, concentration_mean, dconcentration_mean
  • interface_elevation — fresh/salt interface via nlmod.dims.get_isosurface
  • plot_result_maps — the standard result maps

Superseding + correctness

The old layer-discretised grensvlak (botm of the last fresh layer) is replaced by an interpolated interface. Review caught that get_isosurface returns the first sign change in either direction (its own docstring has left/right backwards); the module pins salt-at-surface columns to the model top and fills dry cells, so the result matches the old logic at the limits while interpolating the crossing. Verified on real model output: the z(1000) ≥ z(8000) ordering invariant holds for all 80069 (time×cell) columns — 0 violations, 0 NaN.

Tests

tests/test_postprocessing.py — 8 tests pinning the limits, interpolation, inverted/salt-topped profiles (shallowest up-crossing), trailing-NaN columns, threshold monotonicity, and the budget guard's abs/threshold semantics.

Note

The companion modelscripts/09pwnmodel2 change (calling this module) must land after this PR, or its import breaks the model CI.

Extract the post-MODFLOW-run steps of modelscripts/09pwnmodel2 into a reusable module: the
mass-balance discrepancy guard, loading heads/concentration, the freshwater head, the fresh/salt
interface (grensvlak), the thickness-weighted mean concentration, and the result maps.

The interface is computed with nlmod.dims.get_isosurface (linear interpolation of the elevation
where chloride crosses the threshold), pinning salt-at-surface columns to the model top and
never-salt columns to the model bottom, and filling dry cells at both ends. Regression tests pin
the fresh/salt limits, the shallowest up-crossing on inverted profiles, trailing-NaN columns,
threshold monotonicity, and the budget-guard semantics.
@bdestombe
bdestombe merged commit e44c716 into main Jul 6, 2026
1 check passed
@bdestombe
bdestombe deleted the add-postprocessing-module branch July 7, 2026 08:13
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.

1 participant