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

Allow missing 'Basin / time' data #1028

Merged
merged 3 commits into from
Feb 2, 2024
Merged

Allow missing 'Basin / time' data #1028

merged 3 commits into from
Feb 2, 2024

Conversation

Huite
Copy link
Contributor

@Huite Huite commented Feb 1, 2024

This is a very opportunistic fix to #1027

I'm not sure the !isnan(value) check currently does anything meaningful to be honest?

It's still a bit tedious to setup: to get it working I need to explicitly set the first date to zero, otherwise it triggers the following error: error("Missing initial data for the Basin variable drainage")

One way of dealing with this would be to initialize to zeros, and allow "unset" values for optionals. Not sure about it.

Needs a decision, and then we could add some simple tests.

@Huite Huite requested a review from visr February 1, 2024 10:33
@Huite Huite marked this pull request as draft February 1, 2024 10:33
@Huite
Copy link
Contributor Author

Huite commented Feb 1, 2024

From the imod coupler perspective, it's a bit onerous. Having to set all entries to NaN, except the first feels very specific.

Ideally, I think the following would work as preparation for the coupling step:

df = ribasim_model.basin.df
df.loc[df["node_id"].isin(coupled_node_ids), ["drainage", "infiltration"]] = np.nan

Requires altering this in Ribasim:

    drainage = fill(NaN, length(node_id))
    infiltration = fill(NaN, length(node_id))

using zeros instead and ommitting the check.

Having zero as values if they are not defined here feels reasonable?

Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

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

I initialized with zeros and allowed NaN for the other columns as well.
Also added a simple test model.
Does this work well for you?

@visr visr marked this pull request as ready for review February 1, 2024 21:30
@visr visr changed the title Allow for NaNs for drainage and infiltration Allow missing Basin / time data Feb 1, 2024
@visr visr changed the title Allow missing Basin / time data Allow missing 'Basin / time' data Feb 1, 2024
@Huite
Copy link
Contributor Author

Huite commented Feb 2, 2024

Judging from the test, this does exactly the right thing. I'll try and run this branch on one of my local models to be sure.

@Huite Huite merged commit 2dc5d74 into main Feb 2, 2024
18 of 19 checks passed
@Huite Huite deleted the allow-missing-time branch February 2, 2024 09:58
Huite added a commit that referenced this pull request Feb 5, 2024
Missing is currently only allowed in the basin.time, thanks to
#1028.

This makes it consistent and allows it for basin.static as well (which
is currently the reason a bunch of imod_coupler tests are failing).

---------

Co-authored-by: Martijn Visser <[email protected]>
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