-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several fixes to processing of cross-sections (#153)
* changes to setup_crosssections from Santa Cruz project * improvements to xyz and point x-sections from Santa Cruz * improvements to yz x-sections from Santa Cruz * 3 points are sufficient to define x-section * changes to xyz cross-sections workflow * finalizing xyz test * formatting using black * include maxdist * Update changelog.rst * New author in pyproject.toml * removed dummy tests * removed 'special' x-section type --------- Co-authored-by: veenstrajelmer <[email protected]>
- Loading branch information
1 parent
8862432
commit 2d66900
Showing
5 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ authors = [ | |
{ name = "Xiaohan Li", email = "[email protected]" }, | ||
{ name = "Hélène Boisgontier", email = "[email protected]" }, | ||
{ name = "Jelmer Veenstra", email = "[email protected]" }, | ||
{ name = "Sebastian Hartgring", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"hydromt>=0.10.0, <1", # TODO: move to hydromt>=1: https://github.com/Deltares/hydromt_delft3dfm/issues/137 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from os.path import abspath, dirname, join | ||
import geopandas as gpd | ||
import pandas as pd | ||
import hydromt_delft3dfm.workflows.crosssections as xsec # needed to access private functions | ||
from shapely import Point, LineString | ||
|
||
EXAMPLEDIR = join(dirname(abspath(__file__)), "..", "examples") | ||
|
||
|
||
def test_set_xyz_crosssections(): | ||
# test on a single branch with 3 cross-sections (id = 1 .. 3) | ||
branches = gpd.GeoDataFrame(data={"frictionid": ["Manning_0.023"], "frictiontype": ["Manning"], "frictionvalue": [0.023]}, geometry=[LineString([[0, 0], [1000, 1000]])], crs=28992) | ||
|
||
xyz_crosssections_1 = gpd.GeoDataFrame( | ||
geometry=[Point(-10, 1), Point(0, 1), Point(10, 2), Point(20, 2)], | ||
data={"crsid": [1, 1, 1, 1], "order": [1, 2, 3, 4], "z": [10, 0, 1, 11]}, crs=28992) | ||
xyz_crosssections_2 = gpd.GeoDataFrame( | ||
geometry=[Point(890, 900), Point(900, 895), Point(910, 890), Point(920, 890)], | ||
data={"crsid": [2, 2, 2, 2], "order": [1, 2, 3, 4], "z": [9, -1, 0, 10]}, crs=28992) | ||
# cross-section 3 deliberately has too few points | ||
xyz_crosssections_3 = gpd.GeoDataFrame( | ||
geometry=[Point(995, 995), Point(1005, 1005)], | ||
data={"crsid": [3, 3], "order": [1, 2], "z": [8, 8]}, crs=28992) | ||
|
||
xyz_crosssections = pd.concat([xyz_crosssections_1, xyz_crosssections_2, xyz_crosssections_3]).reset_index(drop=True) | ||
crosssections = xsec.set_xyz_crosssections(branches=branches, crosssections=xyz_crosssections) | ||
|
||
assert len(crosssections) == 2 # check if the cross-section containing only 2 points is dropped | ||
#TODO more checks can be added |