Skip to content

Issue #1273 cleanup example #1274

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 15 commits into from
Nov 7, 2024
Merged

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Nov 6, 2024

Fixes #1273

Description

Add example of cleanup utilities to the user guide. I think it shows a common use-case for cleaning up data.

Technically the most challenging issue was to work around the fact that sphinx_gallery doesn't have an option to select expected errors in specific code blocks. There is this PR to introduce this, but unfortunately for us this has not been finished yet.

I resorted to trapping the error and printing it with a context manager, that seemed like the cleanest solution to me. I added this small context to the public API, so that users can also read in the online documentation what the context manager does.

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

# Update existing model with new data
# -----------------------------------
#
# Your dear colleague has brought you some new data for the river package, which
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 this :D

# Let's clean up the problematic river data using the
# :meth:`imod.mf6.River.cleanup` method. Note that this method changes the data
# inplace. This means that the package's will be updated, without returning a
# new copy of the package. This means that do comparisons of the
Copy link
Collaborator

Choose a reason for hiding this comment

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

"that do" = > "that to do"

riv_ds_old = gwf_model["riv"].dataset
# Existing RIV package has only layer coord with [1, 3, 5, 6]. This causes
# problems with some methods, at least with cleanup. Therefore align data
# here for the cleanup example. Not sure if we want to support river
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Not sure if we want to support river packages with limited layer coords"

I'm not sure if we should put the above in the comment.

Instead you could also write:
"River packages with limited layer coords are currently not supported."

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 agree, I changed it to "River packages with limited layer coords are currently not fully supported.", as you can apparently write a functional model with the river package in only limited layers, but cannot call cleanup on it. I wasn't sure if we want to support that to begin with.

@Manangka
Copy link
Collaborator

Manangka commented Nov 7, 2024

I really like this way of writing examples!!

Copy link

sonarqubecloud bot commented Nov 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@JoerivanEngelen JoerivanEngelen added this pull request to the merge queue Nov 7, 2024
Merged via the queue into master with commit 4871e1a Nov 7, 2024
5 of 6 checks passed
@JoerivanEngelen JoerivanEngelen deleted the issue_#1273_cleanup_example branch November 7, 2024 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 example showcasing cleanup utilities
2 participants