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

39 setup urban sewer network from global data project overview #60

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
255e348
add urban sewer network function heads
xldeltares Aug 15, 2023
40c7f30
add test placeholder
xldeltares Aug 15, 2023
c6da568
small fix
xldeltares Aug 15, 2023
1b2bf86
setup graph from osm network (draft)
xldeltares Aug 15, 2023
3b5836d
draft setup_graph_from_hydrography
xldeltares Aug 17, 2023
2e78283
update gitignore
xldeltares Aug 18, 2023
9f3d0c9
fixes
xldeltares Aug 18, 2023
f085499
allow user to use road_types only
xldeltares Aug 18, 2023
1bca52f
refactor graph workflows into utils
xldeltares Aug 18, 2023
92fb551
fix pre-commit hook where relevant
xldeltares Aug 18, 2023
116c2d5
Merge pull request #68 from Deltares/urbansewer/40-setup_network_from…
xldeltares Aug 18, 2023
54478d4
add utils for graph properties
xldeltares Aug 22, 2023
6476a1c
update graph based on dem
xldeltares Aug 22, 2023
e253bfa
small cleanup
xldeltares Aug 22, 2023
997700d
Merge branch 'main' into 69-create-street-slopes-based-on-a-hydrologi…
xldeltares Aug 31, 2023
93e3c36
update to main format
xldeltares Aug 31, 2023
5db789b
remove ra2ce dependency
xldeltares Sep 5, 2023
edd1af9
setup entire system from osm + refactor
xldeltares Sep 5, 2023
08052c7
setup urban sewer network topology from osm (include both open and cl…
xldeltares Sep 7, 2023
22978e9
code cleanup
xldeltares Sep 7, 2023
4bbd838
fix bug in reverse branch
xldeltares Sep 7, 2023
9c5ebe2
Merge pull request #75 from Deltares/69-create-street-slopes-based-on…
xldeltares Sep 18, 2023
fd72781
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
xldeltares Nov 30, 2023
4896a59
add missing function from merge action
xldeltares Nov 30, 2023
13df99c
add funcs from hybridurb (draft)
xldeltares Nov 30, 2023
9269561
adapt graph utils
xldeltares Dec 1, 2023
6cf7849
graph optimisation draft
xldeltares Dec 1, 2023
353002b
refactor
xldeltares Dec 4, 2023
9c33844
small fix for flwdir
xldeltares Dec 5, 2023
6c4c998
add pipe optimization
xldeltares Dec 13, 2023
76a9e0a
improvements and fixes for pipe topology optimization
xldeltares Dec 14, 2023
cc7c21d
draft of calculate hydraulic parameters
xldeltares Dec 14, 2023
1356c87
Initial commit for urbansewernetwork.py
MRadema Dec 21, 2023
bd3df8b
improve calculate hydraulic dimentions
xldeltares Dec 21, 2023
205b230
Merge remote-tracking branch 'origin/44-setup_network_dimentions_from…
xldeltares Dec 21, 2023
b6d5e65
add missing pieces (landuse and rainfall assumption)
xldeltares Dec 21, 2023
8bdf2df
add rainfall static and fix calculate hydraulic dimentions and others
xldeltares Dec 22, 2023
c4a2382
small fixes that was needed to build model from urban drainage system…
xldeltares Jan 9, 2024
f6c6ac0
crosssection funcs
xldeltares Jan 9, 2024
4f19560
add modelbuilding workflow for urban sewer network
xldeltares Jan 9, 2024
bde9a5e
resolved conflicts
veenstrajelmer Oct 16, 2024
5a44ab8
rename envname back
veenstrajelmer Oct 16, 2024
7aec12a
rename envname back
veenstrajelmer Oct 16, 2024
0125e26
fixed linting
veenstrajelmer Oct 16, 2024
515d409
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 16, 2024
8ce6f31
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 16, 2024
cafb032
minimized diff
veenstrajelmer Oct 16, 2024
e39831e
updated test_model_build
veenstrajelmer Oct 16, 2024
91e8189
prevented urbansewernetwork in test_model_class test
veenstrajelmer Oct 16, 2024
66786c1
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 18, 2024
441a811
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 18, 2024
0852fde
minimized diff
veenstrajelmer Oct 18, 2024
accf3ac
minimized diff
veenstrajelmer Oct 18, 2024
e859029
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 18, 2024
3655183
re-added additional dependencies
veenstrajelmer Oct 18, 2024
0fb25f4
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 18, 2024
1ce597b
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 18, 2024
43969f5
renamed file
veenstrajelmer Oct 24, 2024
892ed5b
Merge branch 'main' into 39-setup-urban-sewer-network-from-global-dat…
veenstrajelmer Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add rainfall static and fix calculate hydraulic dimentions and others
  • Loading branch information
xldeltares committed Dec 22, 2023

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit 8bdf2df2ed6676483528cf7f1403ed4f32d1f87d
167 changes: 111 additions & 56 deletions hydromt_delft3dfm/dflowfm.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

import geopandas as gpd
import hydromt
import networkx as nx
import numpy as np
import pandas as pd
import xarray as xr
@@ -870,47 +869,97 @@ def setup_urban_sewer_network_from_osm(
landuse_reclass_fn: Union[str, Path] = None,
runoff_distance: float = 30.0,
method_cost: str = "length",
pipe_spacing: float = 50.0,
pipe_depth: float = 0.5,
assumption_rainfall_intensity: float = 30.0,
assumption_flow_velocity: float = 1.0,
rainfall_stats_fn: Union[str, Path] = None,
**kwargs,
) -> None:
"""
BUild, optimize, and update the urban drainage system from osm.
Set up and optimizes an urban sewer network open datasets.

requires:
osm_data: Input data from OpenStreetMap to build the drainage network.
dem_data: Digital Elevation Model data for determining flow directions.
raster_data: Datasets representing various geographic and physical features.
rainfall_data: Historical rainfall data to update pipe dimensions.
The function builds a network topology from OSM data, integrates elevation data
from a Digital Elevation Model (DEM), and adds land use data to calculate runoff
areas. It optimizes the network for water flow based on given parameters and
adds physical parameters such as diameter based on historical rainfall data.

Parameters
----------
region : dict
Dictionary describing region of interest for extracting 1D branches,
e.g.:

* {'bbox': [xmin, ymin, xmax, ymax]}

* {'geom': 'path/to/polygon_geometry'}
Note that only crs=4326 is supported for 'bbox'.
network_type: str {"all_private", "all", "bike", "drive", "drive_service",
"walk"})
The type of street network to consider. This helps filter the OSM data
to include only relevant road types.
By default "drive"
road_types: list[str], optional
A list of road types to consider during the creation of the graph.
This further refines the data that is included from the OSM dataset.
A complete list can be found in: https://wiki.openstreetmap.org/wiki/Key:highway.
by default None.
hydrography_fn : str
Hydrography data (dem) to derive river shape and characteristics from.
* Required variables: ['elevtn']
* Optional variables: ['flwdir', 'uparea']
kwargs: key word arguments.
region : dict
The geographical region of interest for the sewer network.
The region can be defined by bounding box coordinates or a polygon geometry
file path.
Only CRS 4326 is supported for bounding box format.
Example:
{'bbox': [xmin, ymin, xmax, ymax]}
{'geom': 'path/to/polygon_geometry'}

waterway_types : list[str], optional
List of waterway types to be considered from OSM data.
Defaults to None, use default waterway types.

highway_types : list[str], optional
List of highway types to be considered from OSM data.
Defaults to None, use default highway types.

dem_fn : Union[str, Path], optional
File path for the Digital Elevation Model (DEM) data
used to determine flow directions.

landuse_fn : Union[str, Path], optional
File path for land use data used to derive runoff areas.

landuse_reclass_fn : Union[str, Path], optional
File path for reclassified land use data to derive runoff areas.

runoff_distance : float, optional
Maximum distance for runoff water to reach a sewer network.
Defaults to 30.0 meters.

method_cost : str, optional
Method used to determine the cost of network paths, typically based on
"length" or "static_cost".
Defaults to "length".

pipe_depth : float, optional
Assumed depth of the pipes in meters.
Defaults to 0.5 meters, measured to the top of the pipes.

assumption_rainfall_intensity : float, optional
Assumed intensity of rainfall in mm/hour.
Used to estimate the rainfall depth that the pipes needs to accomondate.
Defaults to 30.0 mm/hour.

assumption_flow_velocity : float, optional
Assumed flow velocity in the sewer network in m/s.
Used to estimate the concentration time of the pipes.
Defaults to 1.0 m/s.

rainfall_stats_fn : Union[str, Path], optional
File path for historical rainfall statistics data.
Used to derive rainfall intensity-duration relationships.

kwargs : dict
Additional keyword arguments.

Returns
-------
None
The function does not return anything but modifies the sewer network data
structure within the class.

Notes
-----
This function performs several steps:
- Builds the initial network topology from OSM data.
- Integrates elevation data from DEM to determine flow directions.
- Adds land use data to calculate runoff areas.
- Optimizes the network based on cost methods and hydrological parameters.
- Calculates and applies hydraulic parameters based on rainfall data and
assumptions about pipe dimensions and flow velocity.

The function requires certain datasets to be provided and may perform complex
computations and optimizations, which can be computationally intensive.
"""
self.logger.info("Preparing urban sewer network.")
region = workflows.parse_region_geometry(region, self.crs)
@@ -946,47 +995,53 @@ def setup_urban_sewer_network_from_osm(
logger=self.logger,
)

# 4. optimise graph directions
# add "geometry", "length" to edges
# TODO add method_for_weight as argument to main function
# seperate workflows
graph_rivers = workflows.select_connected_branches(graph, "river")
graph_pipes = workflows.select_connected_branches(graph, "pipe")

# 4. optimise graph directions
# add "geometry", "length", "gradient" to edges
graph_pipe_dag = workflows.optimise_pipe_topology(
graph=graph_pipes,
method_for_weight=method_cost,
logger=self.logger,
)
# FIXME missing edges in between adding them back result in a nondag
) # FIXME missing edges in between but nondag when add

# TODO 4. get rainfall stats from historical data
# TODO: add a multiplier to rainfall
# rainfall_depth_function = workflows.get_idf_function_from_rainfall()
def rainfall_depth_function(x):
return assumption_rainfall_intensity * x / 3600.0
# 4. get rainfall_depth_function (of concentration time) from historical data
rainfall_depth_function = workflows.setup_rainfall_function_from_stats(
rainfall_fn=rainfall_stats_fn,
region=region,
data_catalog=self.data_catalog,
assumption_rainfall_intensity=assumption_rainfall_intensity,
)

# 5. Setup network physical parameters based on 4
# 5. Setup network physical parameters
# add "diameter", "invlev_up", "invlev_dn" to edges
graph_pipe_dag_with_dimention = workflows.calculate_hydraulic_parameters(
graph_pipe_dag,
pipe_depth=pipe_depth,
flow_velocity=assumption_flow_velocity,
rainfall_depth_function=rainfall_depth_function,
rounding_precision=1,
) # FIXME the calculated diameters are awfully large

graph_rivers = workflows.select_connected_branches(graph, "river")
) # FIXME the calculated diameters are still large

# 6. any additional steps to add the network to delft3dfm model
# _setup_branches
# _setup_crosssections
graph_complete = nx.compose(graph_rivers, graph_pipe_dag_with_dimention)
self.set_branches(graph_utils.graph_to_network(graph_complete)[0])
# TODO: think about call self.setup_rivers and self.setup_pipes
# but then you need to put all the parameters for these two functions

# TODO setup geoms: list in data will block saving
# TODO add to branches
# TODO update mesh
# TODO add geoms for network nodes and network edges
rivers = graph_utils.graph_to_network(graph_rivers)[0]
self.set_geoms(rivers, "rivers")
pipes = graph_utils.graph_to_network(graph_pipe_dag_with_dimention)[0]
self.set_geoms(pipes, "pipes")
self.write_geoms()

# FIXME error in build a model
self.setup_rivers(
region={"bbox": region.to_crs(4326).total_bounds},
rivers_fn=rivers,
)
self.setup_pipes(
region={"bbox": region.to_crs(4326).total_bounds},
pipes_fn=pipes,
)

# Appendixes.
# A1. Setup network connections based on flow directions from DEM
# read data
Loading