Skip to content

Issue #1823 regrid imod5 cap data#1824

Merged
JoerivanEngelen merged 20 commits intomasterfrom
issue_#1823_regrid_imod5_cap_data
Apr 30, 2026
Merged

Issue #1823 regrid imod5 cap data#1824
JoerivanEngelen merged 20 commits intomasterfrom
issue_#1823_regrid_imod5_cap_data

Conversation

@JoerivanEngelen
Copy link
Copy Markdown
Contributor

@JoerivanEngelen JoerivanEngelen commented Apr 23, 2026

Fixes #1823

Description

Regrid iMOD5 CAP data immediately to MODFLOW6 discretization in MetaSwapModel.from_imod5_data . I'm doing this regridding prior to calling the individual from_imod5_data methods of each MetaSwap package as we can then be sure that all grids in the iMOD5 CAP data are on to the right grid (which is not necessarily the case with the data in projectfile), before other grid operations like get_cell_area_from_imod5_data are done. Furthermore, the keys in the CAP data differ from the variable names in packages.

This differs slightly from the approach in the MODFLOW6 module, where regridding is done in Package.from_imod5_data.

Fixes the following:

  • Regrid CAP data
  • Let _regrid_array return a DataArray without any dimensions instead of a numpy array if_scalar is True, this is consistent with the type annotation, and has the advantage that these scalars can be broadcasted without having to do additional type conversions in the masking operation later.
  • Boyscouting: Fix typo in "conductivity_factor" key that is used mostly internally

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example
  • If feature added: Added feature to API documentation
  • If pixi.lock was changed: Ran pixi run generate-sbom and committed changes

@JoerivanEngelen JoerivanEngelen marked this pull request as ready for review April 28, 2026 14:07
Comment thread imod/msw/utilities/imod5_converter.py Outdated
def regrid_imod5_data(
imod5_data: Imod5DataDict,
target_dis: StructuredDiscretization,
regridder_types: Optional[CapDataRegridMethod] = None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this being optional you can assign it a default value of CapDataRegridMethod(). That way you can remove the if None statement at line 147

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did it this way to keep things consistent with how regridder_types are provided in the mf6 module. Looking at the mf6 module, I think there with the current setup it is the best way to do things, but here it isn't really necessary. I'll provide the default value of CapDataRegridMethod() to MetaSwapModel.from_imod5_data.

JoerivanEngelen and others added 10 commits April 29, 2026 11:52
@sonarqubecloud
Copy link
Copy Markdown

@JoerivanEngelen JoerivanEngelen added this pull request to the merge queue Apr 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Apr 30, 2026
@JoerivanEngelen JoerivanEngelen merged commit 89f3b8d into master Apr 30, 2026
8 checks passed
@JoerivanEngelen JoerivanEngelen deleted the issue_#1823_regrid_imod5_cap_data branch April 30, 2026 12:31
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.

[FEATURE] - Regrid iMOD5 data for MetaSWAP models as well.

2 participants