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

Bugfix/generic geodata #568

Merged
Merged
Changes from all commits
Commits
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
14 changes: 5 additions & 9 deletions pandapipes/plotting/generic_geodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def build_igraph_from_ppipes(net, junctions=None):
"""
This function uses the igraph library to create an igraph graph for a given pandapipes network.
Pipes and valves are respected.
Any branch component is respected.
Performance vs. networkx: https://graph-tool.skewed.de/performance

:param net: The pandapipes network
Expand Down Expand Up @@ -50,19 +50,15 @@ def build_igraph_from_ppipes(net, junctions=None):
g.vs["label"] = list(junction_index)
pp_junction_mapping = dict(list(zip(junction_index, list(range(nr_junctions)))))

mask = _get_element_mask_from_nodes(net, "pipe", ["from_junction", "to_junction"], junctions)
for pipe in net.pipe[mask].itertuples():
g.add_edge(pp_junction_mapping[pipe.from_junction], pp_junction_mapping[pipe.to_junction],
weight=pipe.length_km)

for comp in net['component_list']:
if not isinstance(comp, BranchComponent):
if not issubclass(comp, BranchComponent):
continue
fjc, tjc = comp.from_to_node_cols()
mask = _get_element_mask_from_nodes(net, comp.table_name(), [fjc, tjc], junctions)
for comp_data in net[comp.table_name()][mask].itertuples():
g.add_edge(pp_junction_mapping[comp_data[fjc]], pp_junction_mapping[comp_data[tjc]],
weight=0.001)
weight = 0.001 if 'length_km' not in dir(comp_data) else getattr(comp_data, 'length_km')
g.add_edge(pp_junction_mapping[getattr(comp_data, fjc)], pp_junction_mapping[getattr(comp_data, tjc)],
weight=weight)

meshed = _igraph_meshed(g)
roots = [pp_junction_mapping[s] for s in net.ext_grid.junction.values if s in junction_index]
Expand Down
Loading