Skip to content

Refactor PWN layer models and add pwnlayers3 helpers#28

Merged
bdestombe merged 8 commits intomainfrom
pwnlayers2026
Feb 26, 2026
Merged

Refactor PWN layer models and add pwnlayers3 helpers#28
bdestombe merged 8 commits intomainfrom
pwnlayers2026

Conversation

@bdestombe
Copy link
Copy Markdown
Member

Bump project Python requirement to 3.13 and relax classifier. Comment out a couple of legacy imports in pwnlayers.layers. Refactor utilities: fix_missings_botms_and_min_layer_thickness now is a keyword-only function (top, botm), returns the fixed botm array and updates logging logic. Major rework of src/nhflotools/pwnlayers2/layers.py: add caching, reorganize imports, introduce get_pwn_layer_model and get_layer_model, rename and split many mensink/bergen helper functions into get_botm_values/get_kh_values/get_kv_values/get_botm_mask/get_botm_transition, adapt functions to use the 2024 dataset variable names, handle zero kh/kv values, compute idomain and return a consolidated Dataset. Remove/replace some old behaviors and commented legacy combinations. Add a new nhflotools.pwnlayers3 package with interpolation helper functions, IO and layers stubs (new files). Overall this commit restructures PWN layer handling and adds interpolation tooling to support the updated data/2024 workflow.

Bump project Python requirement to 3.13 and relax classifier. Comment out a couple of legacy imports in pwnlayers.layers. Refactor utilities: fix_missings_botms_and_min_layer_thickness now is a keyword-only function (top, botm), returns the fixed botm array and updates logging logic. Major rework of src/nhflotools/pwnlayers2/layers.py: add caching, reorganize imports, introduce get_pwn_layer_model and get_layer_model, rename and split many mensink/bergen helper functions into get_botm_values/get_kh_values/get_kv_values/get_botm_mask/get_botm_transition, adapt functions to use the 2024 dataset variable names, handle zero kh/kv values, compute idomain and return a consolidated Dataset. Remove/replace some old behaviors and commented legacy combinations. Add a new nhflotools.pwnlayers3 package with interpolation helper functions, IO and layers stubs (new files). Overall this commit restructures PWN layer handling and adds interpolation tooling to support the updated data/2024 workflow.
Large refactor of PWN layer model code and fixes for bottom elevation handling.

- merge_layer_models: ensure fix_missings_botms_and_min_layer_thickness is used as a pure function that returns a corrected botm DataArray (assign returned botm back to datasets). Remove 'top' from the overlap validation list.
- pwnlayers2.layers: tiny whitespace cleanup.
- pwnlayers3.layers: major rewrite — update caching attrs, change get_pwn_layer_model signature (new parameters: anisotropy, distance_transition, fill_value_kh/kv, etc.), and replace previous multi-source reader with a new pipeline that builds the PWN dataset via get_ds().
  - Added helper functions: get_ds, get_gdf_boundaries, get_botm, get_thickness, get_kh, get_kv, get_mask, get_transition, and a new fix_missings_botms_and_min_layer_thickness implementation.
  - New logic loads GeoJSON inputs, interpolates bottoms and conductances, computes thickness, kh/kv, masks and transition zones, and validates consistency before merging with REGIS dataset.
  - Preserve behavior to avoid zero kh/kv by replacing exact zeros with 1e-6 and propagate anisotropy/fill_value settings into layer filling.

These changes centralize PWN data processing, make botm correction functional (returning corrected arrays), improve parameterization and validation, and prepare the code to read the consolidated 2024 data layout.
Delete deprecated pwnlayers3 modules: interpolation_helper_functions.py and io.py. Removed helper routines for interpolation (CRS_RD, LEGEND_DICTS, get_internal_contour_lines, assign_poly_values_to_linestrings, combine_lists, join_contour_line_segments, get_point_values, interpolate_gdf, polyline_from_points) and the IO/script that created the interpolation grid and invoked those helpers. These files appeared to be superseded by pwnlayers2 implementations and were removed to clean up duplicated/obsolete code.
Delete the nhflotools.pwnlayers2 package by removing __init__.py and layers.py. These files contained PWN layer-model functionality (get_pwn_layer_model, aquitard interpolation, Mensink/Bergen kv/kh calculations, merging with REGIS, and related helpers). Removing this legacy module will break imports that reference nhflotools.pwnlayers2; update callers to use the replacement code or new API.
Document open concerns from the Edinsi Groundwater report (Vincent Post,
Aug 2024) that affect the PWN layer model processing: North Sea extent,
conductance anomalies, boundary gaps, and layer extension recommendations.
@bdestombe bdestombe merged commit 25a141d into main Feb 26, 2026
1 check failed
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