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

Real wflow basins #266

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Real wflow basins #266

wants to merge 10 commits into from

Conversation

dalmijn
Copy link
Collaborator

@dalmijn dalmijn commented Apr 24, 2024

Issue addressed

Fixes #173, #83

Explanation

Code.

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)

No.

@dalmijn dalmijn changed the title High basins; save geoms with less decimals Real wflow basins Apr 24, 2024
@dalmijn dalmijn linked an issue Apr 24, 2024 that may be closed by this pull request
@dalmijn dalmijn marked this pull request as ready for review April 24, 2024 13:01
@dalmijn dalmijn requested a review from hboisgon April 24, 2024 14:19
Copy link
Contributor

@hboisgon hboisgon left a comment

Choose a reason for hiding this comment

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

Hi Brendan, nice! And nice find for the set_precision method, rounding for geodataframe was actually not so easy not too long ago I did not realize...
Just a couple of comments but I dont think we need a really keep track of the basins_highres, it's just nice if it's in your geoms but that's it.

Could you maybe update the examples with the new basins and basins_highres geojson ? I think we are really relaxed in the tests so maybe that's why they did not complain but I think good to keep the examples up to date with this.

hydromt_wflow/wflow.py Outdated Show resolved Hide resolved
hydromt_wflow/wflow.py Show resolved Hide resolved
hydromt_wflow/wflow.py Outdated Show resolved Hide resolved
hydromt_wflow/wflow.py Show resolved Hide resolved
docs/changelog.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@hboisgon hboisgon left a comment

Choose a reason for hiding this comment

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

Thanks for updating the examples model @dalmijn ! Not sure why the inmaps for some models got updated as well?

Also why did you add two new changes to the code? In read_tables and the index column name in basins?

You are going to hate me but I had more time to think and I actually think you got it right the first time with using basins_highres when available to filter hydrological objects such as lakes/reservoirs/glaciers. So I wonder if we should not put it back in the end for these three? In a way, it's a temporary fix for the Piave case before we address issue #262 properly but as we are talking of releasing, I'm a little uncomfortable to release without the basins high res... What do you think?
For gauges I wonder. For discharge gauges, it may help in very few cases but for precipitation it may make it worse. So maybe here keep low res basins.

hydromt_wflow/wflow.py Show resolved Hide resolved
@@ -3684,7 +3700,6 @@ def basins(self):
.set_index("value")
.sort_index()
)
gdf.index.name = self._MAPS["basins"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this line? This would change the name of the index column from wflow_subcatch to value. Apparently we don't use this in other places in the code but why change?

Copy link
Collaborator Author

@dalmijn dalmijn Apr 29, 2024

Choose a reason for hiding this comment

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

It broke the tests. It's looking specifically for the value column...
The old basin (most of the time) did not pass this and would not have it as the name anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Which test did it break? Maybe actually using wflow_subcatch rather than value as name is better no? While we are breaking behavior of self.basins anyhow :)

@@ -3163,14 +3171,22 @@ def read_staticgeoms(
def write_geoms(
self,
geom_fn: str = "staticgeoms",
precision: int = 5,
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we said we would change default precision to 6?

Copy link
Contributor

Choose a reason for hiding this comment

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

And maybe in the code, you could check is the mod.crs.is_projected and then adjust the default value to 1 for 0.1 meter? And document it in the docstring?
Which I now see should maybe be updated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hehe, forgot that one. Good catch!

@dalmijn
Copy link
Collaborator Author

dalmijn commented Apr 29, 2024

@hboisgon, I do think the model res basins are better for consistency, but I do agree with you that for now (until #262 is fixed) that the highres basins are then better as a temporary fix. I'll change it back. Good thinking.

@dalmijn dalmijn requested a review from hboisgon April 29, 2024 09:46
Copy link
Contributor

@hboisgon hboisgon left a comment

Choose a reason for hiding this comment

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

Thanks for updating @dalmijn !
Two last remarks:

  • the index name of self.geoms["basins"]
  • the update of the examples. I agree that the geosjon should change with the new rounding precision but why inmaps. staticmaps and wflow_sbm files should change?

@@ -3684,7 +3700,6 @@ def basins(self):
.set_index("value")
.sort_index()
)
gdf.index.name = self._MAPS["basins"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Which test did it break? Maybe actually using wflow_subcatch rather than value as name is better no? While we are breaking behavior of self.basins anyhow :)

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.

Saving the actual wflow basins in staticgeoms write staticgeoms with less decimals in coordinates
2 participants