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

Replace find_nearest_branch with hydromt alternative #74

Merged
merged 19 commits into from
Oct 18, 2024

Conversation

xldeltares
Copy link
Collaborator

@xldeltares xldeltares commented Aug 25, 2023

Issue addressed

Fixes #5

Explanation

a new find_nearest_branch function is created.
For now the function implemented "overal" and "intersecting" methods.
The former is used for point crossection and structures, the latter is used for xyz crossection.
The latter is also improved to handle situations where multiple branches are snapped to one crossection, in which case, an extra centroid will be computed from the line crossection and snapped to the branch with closest distance.

Checklist

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

Additional Notes (optional)

There is still a pending issue in the model built by the code: #56

@xldeltares xldeltares linked an issue Aug 25, 2023 that may be closed by this pull request
@sonarcloud
Copy link

sonarcloud bot commented Aug 25, 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 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 15, 2024

I just fixed the import errors. The only errors left are the following:

FAILED tests/test_hydromt.py::test_model_build[local] - KeyError: ['branch_offset']
FAILED tests/test_hydromt.py::test_model_build_local_code - KeyError: ['branch_offset']

These testcases are identical, the code version is easier to debug.

These are originating from the following setup functions: setup_bridges, setup_culverts
Furthermore, setup_1dlateral_from_points raises KeyError: 'chainage'

It could be related to #175, but it could also be unrelated since the main branch also shows the same behaviour. Either way, if the cause is clear, please add a unittest just like for the other functions.

edit: the above is resolved after fixes from @xldeltares

@veenstrajelmer veenstrajelmer marked this pull request as draft October 15, 2024 15:17
@veenstrajelmer veenstrajelmer mentioned this pull request Oct 15, 2024
5 tasks
@veenstrajelmer veenstrajelmer changed the title fix #5 Replace find_nearest_branch with hydromt alternative Oct 15, 2024
@veenstrajelmer veenstrajelmer changed the title Replace find_nearest_branch with hydromt alternative Replace find_nearest_branch with hydromt alternative Oct 15, 2024
@veenstrajelmer veenstrajelmer marked this pull request as ready for review October 15, 2024 22:26
@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 16, 2024

I also removed some of my commits and pushed them to a different branch. Furthermore, I moved all fixes that @xldeltares and myself wanted to do within this branch to #180 (fix docs build action) and #178 + #182 (align dflowfm build yml), which are now also merged. From #178 I have created follow up issue #177 (rainfall), not yet resolved/merged but this is not blocking for this PR. This branch was synced again with the main branch after merging the PR's.

So now this PR is now purely about updating a D-HyDAMO function to hydromt functionality. The new implementation does not update the dataframes in place, so the functions need to return the updated dataframes instead. I assume here that the old D-HyDAMO function did update the dataframe in place right? Otherwise I guess some of our tests should have failed, I think, but I cannot judge 100%.

After updating with main after merging the two PR's, I only get one error:

FAILED tests/test_hydromt.py::test_model_build[local] - AssertionError: {'config.geometry.structurefile': AssertionError('values not equal')}
assert False

So it might well be that it is after all not a lot of work to finish this PR. Also check #169 since it might be related. Alternatively it might just be enough to update the values of another geojson? Are the values in the geojson files expected to change with this update, or does it indicate a mistake in the implementation?

Copy link

sonarcloud bot commented Oct 18, 2024

Copy link
Collaborator

@veenstrajelmer veenstrajelmer left a comment

Choose a reason for hiding this comment

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

Looks good, all tests are now passing and the four example models are successfully built from the notebooks and also run successfully in the Delft3D FM Suite 2024.03 1D2D

@veenstrajelmer veenstrajelmer merged commit fa8c695 into main Oct 18, 2024
9 checks passed
@veenstrajelmer veenstrajelmer deleted the 5-replace-branchesfind_nearest_branch branch October 18, 2024 08:20
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.

Replace branches/find_nearest_branch()
2 participants