Skip to content

Commit

Permalink
added option to guess slider valve types; some small adaptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohmeier committed Dec 4, 2023
1 parent d5d25ae commit c425cb6
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 96 deletions.
47 changes: 26 additions & 21 deletions pandapipes/converter/stanet/preparing_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@
logger = logging.getLogger(__name__)


DEFAULT_STANET_KEYWORDS = {
"pipes": ['REM Leitungsdaten'],
"house_pipes": ['REM HA Leitungsdaten'],
"nodes": ['REM Knotendaten'],
"house_nodes": ["REM HA Knotendaten"],
"valves": ['REM Ventiledaten'],
"pumps_gas": ['REM Kompressorendaten'],
"pumps_water": ['REM Pumpendaten'],
"net_parameters": ['REM Netzparameterdaten'],
"houses": ["REM Hausdaten"],
"house_connections": ["REM HA Verbindungsdaten"],
"meters": ["REM HA Zählerdaten"],
"controllers": ["REM Reglerdaten"],
"slider_valves": ["REM Schieberdaten"],
"inflexion_points": ["REM Knickpunktdaten"],
"heat_exchangers": ["REM Wärmetauscherdaten"],
"customers": ["REM Abnehmerdaten"],
"house_inflexion_points": ["REM HA Knickpunktdaten"],
"layers": ["REM Layerdaten"]
}


def get_stanet_raw_data(stanet_path, read_options=None, add_layers=True, return_line_info=False,
keywords=None):
"""
Expand Down Expand Up @@ -52,24 +74,7 @@ def get_stanet_raw_data(stanet_path, read_options=None, add_layers=True, return_
# 4th line: STANET internal header of table (this is the first line to convert to pandas
# dataframe and return to the converter)
# everything until the next empty line will be added to the dataframe
keywords = {"pipes": ['REM Leitungsdaten'],
"house_pipes": ['REM HA Leitungsdaten'],
"nodes": ['REM Knotendaten'],
"house_nodes": ["REM HA Knotendaten"],
"valves": ['REM Ventiledaten'],
"pumps_gas": ['REM Kompressorendaten'],
"pumps_water": ['REM Pumpendaten'],
"net_parameters": ['REM Netzparameterdaten'],
"houses": ["REM Hausdaten"],
"house_connections": ["REM HA Verbindungsdaten"],
"meters": ["REM HA Zählerdaten"],
"controllers": ["REM Reglerdaten"],
"slider_valves": ["REM Schieberdaten"],
"inflexion_points": ["REM Knickpunktdaten"],
"heat_exchangers": ["REM Wärmetauscherdaten"],
"customers": ["REM Abnehmerdaten"],
"house_inflexion_points": ["REM HA Knickpunktdaten"],
"layers": ["REM Layerdaten"]}
keywords = DEFAULT_STANET_KEYWORDS
stored_data = dict()

logger.info("Reading STANET csv-file.")
Expand Down Expand Up @@ -230,9 +235,9 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe
coord = "x" if is_x else "y"
locat = "from" if is_start else "to"
run = 0 if is_x else 2
run += 0 if is_start else 1
run += 1 - int(is_start)
pipe_name = coord_names[run]
node_nr = node_cols[0] if is_start else node_cols[1]
node_nr = node_cols[1 - int(is_start)]
node_val = node_geo.loc[pipe_data.loc[pipes_to_check, node_nr].values, node_name].values

if pipe_name not in pipe_data.columns:
Expand Down Expand Up @@ -273,7 +278,7 @@ def adapt_pipe_data(stored_data, pipe_data, coord_names, use_clients):

# the following code is just a check whether pipe and node geodata fit together
# in case of deviations, the pipe geodata is adapted on the basis of the node geodata
pipe_rec = pipe_data.RECNO.values
pipe_rec = pipe_data.index.values
for is_x, is_start in product([True, False], [True, False]):
current_index_range = indices[0] if is_start else indices[1]
current_pipe_nums = pipe_rec[current_index_range.values]
Expand Down
8 changes: 6 additions & 2 deletions pandapipes/converter/stanet/stanet2pandapipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
# - maybe it will be necessary to remove deleted data from the STANET tables, otherwise they
# might be inserted into the pandapipes net erroneously
def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connections=True,
stanet_like_valves=False, read_options=None, add_layers=True, **kwargs):
stanet_like_valves=False, read_options=None, add_layers=True,
guess_slider_valve_types=False, **kwargs):
"""Converts STANET csv-file to pandapipesNet.
:param stanet_path: path to csv-file exported from STANET
Expand All @@ -50,6 +51,9 @@ def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connec
:param add_layers: If True, adds information on layers of different components if provided by \
STANET
:type add_layers: bool, default True
:param guess_slider_valve_types: If set to True, the slider valve status (opened / closed) is \
guessed based on the logic "even number = opened; odd number = closed".
:type guess_slider_valve_types: bool, default False
:return: net
:rtype: pandapipesNet
"""
Expand Down Expand Up @@ -99,7 +103,7 @@ def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connec
# pandapipes
create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_like_valves, add_layers)

create_slider_valves(net, stored_data, index_mapping, add_layers)
create_slider_valves(net, stored_data, index_mapping, add_layers, guess_slider_valve_types)

if "pumps_water" in stored_data:
create_pumps(net, stored_data['pumps_water'], index_mapping, add_layers)
Expand Down
Loading

0 comments on commit c425cb6

Please sign in to comment.