Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #365 add regrid to msw packages #982

Conversation

luitjansl
Copy link
Contributor

Fixes #365

Description

Adds regrid functionality to a number of metaswap packages
Adds unittests for regridding these packages

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

@luitjansl luitjansl marked this pull request as draft April 24, 2024 09:30
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen left a comment

Choose a reason for hiding this comment

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

Looks good so far, I'm quite impressed adding regridding support doesn't seem to require that much additions to the existing code base. Fruits of our labour generalizing things, and moving logic outside Modflow6 package objects.

I miss regridding of the most crucial grid package though: GridData. The landuse variable here can be regridded with the mode (or modus?) method.

Furthermore you changed some things to the infiltration package input arguments without explanation; so I'd like to know the reasoning behind that.

Grid packages that still require regridding:

  • GridData (landuse variable can use mode option``)
  • sprinkling (Still requires some work for the grid agnostic well, that might be the reason you haven't done it yet here)
  • IdfMapping

Comment on lines +63 to +67
"downward_resistance": (RegridderType.OVERLAP, "mean"),
"upward_resistance": (
RegridderType.OVERLAP,
"mean",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

These are vertical resistances, meaning thickness/conductivity. Vertical hydraulic conductivity is regridded with the harmonic_mean method. Shouldn't we use this one as well here? Perhaps @HendrikKok has an opinion on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have introduced the same method for all parameters, and left the fine-tuning of choosing the correct parameter for each array for a future issue. If these are permeability-like parameters then it indeed be harmonic as it deals with parallel resistors. But since I couldn't find how these inputs are used by metaswap,, I wouldn't know how to upscale them. Besides @HendrikKok , also this "Paul" person could be consulted for this I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you open an issue that we still need to select appropriate methods?

RegridderType.OVERLAP,
"mean",
),
"bottom_resistance": (RegridderType.OVERLAP, "mean"),
Copy link
Contributor

Choose a reason for hiding this comment

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

See other comment about regridding resistances

Comment on lines +168 to +183
if interception_capacity_per_LAI is not None:
self.dataset["interception_capacity_per_LAI_Rutter"] = (
interception_capacity_per_LAI
)
else:
self.dataset["interception_capacity_per_LAI_Rutter"] = (
interception_capacity_per_LAI_Rutter
)
if interception_capacity_per_LAI is not None:
self.dataset["interception_capacity_per_LAI_VonHoyningen"] = (
interception_capacity_per_LAI
)
else:
self.dataset["interception_capacity_per_LAI_VonHoyningen"] = (
interception_capacity_per_LAI_VonHoyningen
)
Copy link
Contributor

Choose a reason for hiding this comment

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

What were your reasons to change this? This adds more complexity to the code. I also see no changes to the docstring.

Copy link
Contributor Author

@luitjansl luitjansl Apr 24, 2024

Choose a reason for hiding this comment

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

The reason is this:
-in most datasets, the list of keys in the dataset matches the arguments of the__init__ function of the package
-so in _regrid we can regrid all the arrays, and then call __init__ on the regridded package with the regridded arrays
-but for this package, the arguments of the __init__ function did not match the keys of the package dataset because one init parameter( xxx) was placed in the dataset under 2 names: xxx_VonHoyningen and xxx_Rutter
-so now I added the option to pass xxx_VonHoyningen and xxx_Rutter directly to the initializer , so the _regrid function will work just like for any other package.
-I also preserved the original parameter so that user code wil keep working
-I now updated the docstring to inform users that the new init-parameters are for internal use and the user should ignore them

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, this makes sense.

imod/typing/grid.py Outdated Show resolved Hide resolved
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen left a comment

Choose a reason for hiding this comment

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

Approved. There are some loose ends though, could you make issues for:

  • That we still need to assess proper default regridding methods for MetaSWAP grid data
  • The GridData, Sprinkling, IdfMapping package still need an implementation for regridding.

@luitjansl
Copy link
Contributor Author

Approved. There are some loose ends though, could you make issues for:

  • That we still need to assess proper default regridding methods for MetaSWAP grid data
  • The GridData, Sprinkling, IdfMapping package still need an implementation for regridding.

issues were made for these 2 loose ends: #1001 and #1002

@luitjansl luitjansl marked this pull request as ready for review April 30, 2024 14:19
@luitjansl luitjansl merged commit 0038faf into metaswap_regridding_feature_branch Apr 30, 2024
7 checks passed
@luitjansl luitjansl deleted the issue_#365_add_regrid_to_msw_packages branch April 30, 2024 14:20
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