skeletonize#
module wntr.morph.skel
- skeletonize(wn, pipe_diameter_threshold, branch_trim=True, series_pipe_merge=True, parallel_pipe_merge=True, max_cycles=None, use_epanet=True, pipes_to_exclude=[], junctions_to_exclude=[], return_map=False, return_copy=True)[source]#
Perform network skeletonization using branch trimming, series pipe merge, and parallel pipe merge operations. Candidate pipes for removal is based on a pipe diameter threshold.
- Parameters:
wn (wntr WaterNetworkModel) – Water network model
pipe_diameter_threshold (float) – Pipe diameter threshold. Pipes with diameter <= threshold are candidates for removal
branch_trim (bool, optional) – If True, include branch trimming in skeletonization
series_pipe_merge (bool, optional) – If True, include series pipe merge in skeletonization
parallel_pipe_merge (bool, optional) – If True, include parallel pipe merge in skeletonization
max_cycles (int or None, optional) – Maximum number of cycles in the skeletonization process. One cycle performs branch trimming for all candidate pipes, followed by series pipe merging for all candidate pipes, followed by parallel pipe merging for all candidate pipes. If max_cycles is set to None, skeletonization will run until the network can no longer be reduced.
use_epanet (bool, optional) – If True, use the EpanetSimulator to compute headloss in pipes. If False, use the WNTRSimulator to compute headloss in pipes.
pipes_to_exclude (list, optional) – List of pipe names to exclude from skeletonization
junctions_to_exclude (list, optional) – List of junction names to exclude from skeletonization
return_map (bool, optional) – If True, return a skeletonization map. The map is a dictionary that includes original nodes as keys and a list of skeletonized nodes that were merged into each original node as values.
return_copy (bool, optional) – If True, modify and return a copy of the WaterNetworkModel object. If False, modify and return the original WaterNetworkModel object.
- Returns:
wntr WaterNetworkModel – Skeletonized water network model
dictionary – Skeletonization map (if return_map = True) which includes original nodes as keys and a list of skeletonized nodes that were merged into each original node as values.