Add postprocessing module for the PWN model (09pwnmodel2) - #40
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts the post-run steps of
modelscripts/09pwnmodel2/01_pwnmodel2.py(everything afternlmod.sim.write_and_run) intonhflotools.postprocessing:check_budget_discrepancy— mass-balance guard (flopyMf6ListBudget)add_output_to_ds— loads heads/concentration; deriveshead_filled,conc_filled,freshwater_head,grensvlak_zoet/grensvlak_brak,concentration_mean,dconcentration_meaninterface_elevation— fresh/salt interface vianlmod.dims.get_isosurfaceplot_result_maps— the standard result mapsSuperseding + correctness
The old layer-discretised
grensvlak(botm of the last fresh layer) is replaced by an interpolated interface. Review caught thatget_isosurfacereturns the first sign change in either direction (its own docstring hasleft/rightbackwards); 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: thez(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/09pwnmodel2change (calling this module) must land after this PR, or its import breaks the model CI.