Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue #442 clipping msw pkg #1476

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

Merged
merged 10 commits into from
Mar 6, 2025
Merged

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Mar 5, 2025

Fixes #442 and #542

Description

@HendrikKok asked me to clip a model for him to send it to Wageningen and I thought this would be a trivial exercise, only I realized we still lacked MetaSWAP clipping support. I noticed this was low-hanging fruit, so instead of writing some special one-off script, I thought I might as well add it to iMOD Python immediately.

This PR:

  • Small refactor: Move clipping logic in imod.mf6.Package.clip_box to imod.common.utilities.clip module.
  • Adds support to clip MetaSWAP packages
  • Add unittests
  • Boyscouting: Move clipping tests to test_common/test_utilities
  • Boyscouting: Move confusing name test_common.py to test_prepare/test_common.py

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

@JoerivanEngelen JoerivanEngelen requested a review from Manangka March 5, 2025 16:06

# If the first time matches exactly, xarray will have done thing we
# wanted and our work with the time dimension is finished.
if (time_start is not None) and (time_start != first_time):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can reverse this if statement to return immediately. This avoid having to need a nested if statement. It also makes it clear that the part in the if statement is additional work

if (time_start is None) or (time_start  == first_time):
  # xarray has done the what we wanted
  return

# More work is needed
...

x_max=x_max,
y_min=y_min,
y_max=y_max,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like how you cleaned up this method. Really easy to read!

Copy link

sonarqubecloud bot commented Mar 6, 2025

@JoerivanEngelen JoerivanEngelen merged commit 5a1d7e8 into master Mar 6, 2025
3 of 7 checks passed
@JoerivanEngelen JoerivanEngelen deleted the issue_#442_clipping_msw_pkg branch March 6, 2025 15:34
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.

Add clipping method to MetaSwapPackage
2 participants