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

States #252

Merged
merged 13 commits into from
Apr 3, 2024
Merged

States #252

merged 13 commits into from
Apr 3, 2024

Conversation

hboisgon
Copy link
Contributor

@hboisgon hboisgon commented Mar 6, 2024

Issue addressed

Fixes #18

Explanation

Added:

  • read and write methods for states
  • clip method for states
  • prepare cold states method

To be precise in the cold states method as this can be done after a wflow model has been updated and calibrated, I added a new function to get the right values based on value/scale/offset options in the config file with a new utils.get_grid_from_config function.

Checklist

  • Updated tests or added new tests
  • Branch is up to date with main
  • Tests & pre-commit hooks pass
  • Updated documentation if needed

Additional Notes (optional)

Add any additional notes or information that may be helpful.

@hboisgon hboisgon self-assigned this Mar 6, 2024
@dalmijn dalmijn self-requested a review March 7, 2024 08:54
Copy link
Collaborator

@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

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

@hboisgon, Thanks for the good work! For the most part, it looks very solid!

I had a few points:

  • path_input is not set (could cause issues with custom config files)
  • Same argument goes for the states themselves
    ( I realise we rely upon the blueprint settings files, but this makes it a bit more future proof)
  • Nodata value of waterlevel_lake
  • A bit more documentation maybe in the building (or updating) model notebooks that this can be done. I'd say it's really key that the states can be set like this.

hydromt_wflow/utils.py Show resolved Hide resolved
hydromt_wflow/wflow.py Show resolved Hide resolved
hydromt_wflow/workflows/states.py Outdated Show resolved Hide resolved
@hboisgon
Copy link
Contributor Author

Thanks for the review @dalmijn ! I addressed most of comments. Could you check again?
Some extra replies:

@hboisgon, Thanks for the good work! For the most part, it looks very solid!

I had a few points:

  • path_input is not set (could cause issues with custom config files)

This is handled in the read_states and write_states methods normally :)

  • Same argument goes for the states themselves
    ( I realise we rely upon the blueprint settings files, but this makes it a bit more future proof)

I added.

  • Nodata value of waterlevel_lake

Updated.

  • A bit more documentation maybe in the building (or updating) model notebooks that this can be done. I'd say it's really key that the states can be set like this.

The only use case for this I know is using wflow in Delft-FEWS because Wflow.jl can setup its own cold states so you don't want to prepare them by default (so should not be included in the wflow_build.yml template). The use is also not really complex so not sure if I need a specific update example for it. It's already documented in the list of available methods in the wflow docs and properly listed in the API. Do you think we really need to add an example?

@hboisgon hboisgon requested a review from dalmijn March 25, 2024 07:35
Copy link
Collaborator

@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

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

Thanks @hboisgon for addressing the comments!

Everything looks good except for one:

@hboisgon, Thanks for the good work! For the most part, it looks very solid!
I had a few points:

  • path_input is not set (could cause issues with custom config files)

This is handled in the read_states and write_states methods normally :)

This is not handled properly in write_states. state.path_input will not be set.
An error will be thrown in write_states as there is no value for it in the config.

A bit more documentation maybe in the building (or updating) model notebooks that this can be done. I'd say it's really
key that the states can be set like this.

The only use case for this I know is using wflow in Delft-FEWS because Wflow.jl can setup its own cold states so you don't
want to prepare them by default (so should not be included in the wflow_build.yml template). The use is also not really
complex so not sure if I need a specific update example for it. It's already documented in the list of available methods in the > wflow docs and properly listed in the API. Do you think we really need to add an example?

I agree, I was more thinking of a added cell in the current update or build notebook, not a separate one.

hydromt_wflow/wflow.py Outdated Show resolved Hide resolved
@dalmijn dalmijn self-requested a review March 25, 2024 12:13
Copy link
Collaborator

@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

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

@hboisgon, Thanks for the update :)!

I have one last point remaining.

  • setting state.path_input

hydromt_wflow/wflow.py Outdated Show resolved Hide resolved
@hboisgon hboisgon requested a review from dalmijn March 26, 2024 05:52
Copy link
Collaborator

@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

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

LGTM.

@hboisgon could you take a quick look at the make_path_relative functionm?

@hboisgon
Copy link
Contributor Author

hboisgon commented Apr 3, 2024

Hi @dalmijn. In the end I preferred to handle this similarly to other components like forcing.
While checking forcing and grid, I realized that wflow also supports dir_input as relative path to all input files including states so I added that as well.
In the end I do not think we need the function to deal with relative path that you added (even if it was a good one to check for mount first). If you agree then we can remove it I think.

@dalmijn
Copy link
Collaborator

dalmijn commented Apr 3, 2024

@hboisgon, It look good to me. I'll delete the excess functions.

@dalmijn dalmijn merged commit 8e29d76 into main Apr 3, 2024
6 checks passed
@hboisgon hboisgon deleted the states branch April 23, 2024 05:10
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.

Implement wflow states object
2 participants