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

77 setup 1d laterals #81

Merged
merged 34 commits into from
Nov 28, 2023
Merged

77 setup 1d laterals #81

merged 34 commits into from
Nov 28, 2023

Conversation

xldeltares
Copy link
Collaborator

@xldeltares xldeltares commented Sep 15, 2023

Issue addressed

Fixes #77

Explanation

Explain how you addressed the bug/feature request, what choices you made and why.

Checklist

  • Updated tests or added new tests
  • Branch is up to date with main
  • Tests
  • pre-commit hooks pass --> in a seperate issue
  • Updated documentation if needed
  • Updated changelog.rst if needed
  • update model api
  • update boundares.py when could not reproject for geodataset hydromt#613 is resolved. --> wait for the next release

Additional Notes (optional)

Add any additional notes or information that may be helpful.

@xldeltares xldeltares linked an issue Sep 15, 2023 that may be closed by this pull request
3 tasks
@sonarcloud
Copy link

sonarcloud bot commented Oct 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

No Coverage information No Coverage information
1.7% 1.7% Duplication

@xldeltares
Copy link
Collaborator Author

Hi @hboisgon , I have finalized the 1D lateral branch needed for PUB. could you please review it? Thanks!

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.

Nice work @xldeltares! I have some suggestions for geodataset objects especially in the workflow before approving and merging.

I still wonder if separating functions for boundaries and laterals into constant and timeseries (geodataset) would not make things more clear both for user and developper? If so can be tackled here or open an issue for later.

While reviewing I also think we might want to open some issues in core. They wont be solved and released fast I guess so we can keep what we have here as well.

hydromt_delft3dfm/dflowfm.py Show resolved Hide resolved
hydromt_delft3dfm/dflowfm.py Show resolved Hide resolved
hydromt_delft3dfm/dflowfm.py Outdated Show resolved Hide resolved
hydromt_delft3dfm/dflowfm.py Outdated Show resolved Hide resolved
time_tuple=(tstart, tstop),
).rename(forcing_name)
# error if time mismatch
if np.logical_and(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this happen? Now that I think I think I had the issue with wflow. Might be an idea to have better support in core then ie an option to raise error when reading if time mismatch or no error but return a flag or dataset actual (start, end) tuple. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it is mainly because the datetime parsing in case of a csv. It could easily go wrong. In that case, we issue an error and ask explicitly for yyyy-mm-dd HH:MM:SS.

Copy link
Contributor

Choose a reason for hiding this comment

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

Csv or netcdf maybe still an issue for core? That if a time_tuple is passed to any of the get_data we should do an extra check in core to make sure the slicing happened?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, true! I added this request to hydromt issues.: Deltares/hydromt#665

hydromt_delft3dfm/dflowfm.py Outdated Show resolved Hide resolved
hydromt_delft3dfm/workflows/boundaries.py Show resolved Hide resolved
hydromt_delft3dfm/workflows/boundaries.py Show resolved Hide resolved
hydromt_delft3dfm/workflows/boundaries.py Show resolved Hide resolved
hydromt_delft3dfm/workflows/boundaries.py Show resolved Hide resolved
@hboisgon
Copy link
Contributor

I had a look at Deltares/hydromt#613 and fixed it in a PR. Good catch! Not sure about when it would be released though so we may have to keep your workaround (if any) longer and open an issue to remind us to come back to it when hydromt is released again (shame it was not in the release from last week).

@xldeltares
Copy link
Collaborator Author

xldeltares commented Nov 24, 2023

HI @hboisgon , thanks for the nice review and feedback! I agree with your comments on the current way of setting up forcing. I think that should be a more general discuss, therefore, a new issue has been created: #117 . It is a quite big issue and several sub issues can be created from it, but for now I kept it as one big issue. Hope that we could pick it up earlier next year!

Could you re-review this PR (hopefully an easy approve) and also check if you agree with #117?

note that the sonarcloud code is not passing because of two critical cognitive complex functions write_1dlateral and write_geoms. But I could not think of an easy way to address it yet so I left them as they are now.

@hboisgon
Copy link
Contributor

Hi @xldeltares , thanks for the changes! Looks good to merge now.

I think that the quality gate is failing because of code duplication (should be <= 3%).
It was at 4.8 and I now reduced to 3.1 so almost there...
Can you check my changes? Especially for the new _read_forcingfile function. For each forcing boundary/meteo etc there was a lot of duplicates that I simplified into one function. I needed to add a lot of flags (true/false). Could you check that these flags are indeed needed or actually in some cases we did not do it correctly? Also for read_meteo I actually changed the behavior (set factor and offset to 0 and 1 instead of reading from df forcing as I think when reading we do the conversion so the new values should be 0 and 1 - you can compare now and either from main or previous commit version)

If all looks good we can merge and for the remaining 0.1% duplication, I leave it up to you if it is worth the effort

Copy link

sonarcloud bot commented Nov 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

No Coverage information No Coverage information
0.3% 0.3% Duplication

@xldeltares
Copy link
Collaborator Author

@hboisgon , nice changes! I did similar for the rest of the duplication so we are now green! will merge the pull request and close the branch.

@xldeltares xldeltares merged commit a97d2b4 into main Nov 28, 2023
7 checks passed
@xldeltares xldeltares deleted the 77-setup-1d-laterals branch November 28, 2023 15:08
veenstrajelmer added a commit that referenced this pull request Oct 17, 2024
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.

Setup 1D laterals
2 participants