Skip to content

Commit

Permalink
Merge pull request #2331 from e2nIEE/feature/fix_for_issue_2330
Browse files Browse the repository at this point in the history
Feature/fix for issue 2330
vogt31337 authored Jul 4, 2024
2 parents 5b15c72 + 34a0ad9 commit 00d9e22
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pandapower/test/toolbox/test_grid_modification.py
Original file line number Diff line number Diff line change
@@ -190,6 +190,28 @@ def test_merge_with_groups():
assert list(pp.group_element_index(net, 4, "line")) == list(np.array([1, 3], dtype=np.int64) + \
net1.line.shape[0])

def test_merge_with_characteristics():
from pandapower.networks.simple_pandapower_test_networks import simple_four_bus_system
from pandapower.control.util.characteristic import Characteristic

# create two networks
net1 = simple_four_bus_system()
net2 = simple_four_bus_system()

# create two characteristic
Characteristic(net1, x_values=[0.85, 1.15], y_values=[5, 15])
Characteristic(net2, x_values=[0.95, 1.05], y_values=[10, 20])

# assign the characteristic ids to the trafos
net1.trafo.loc[:, "vk_percent_characteristic"] = 0
net2.trafo.loc[:, "vk_percent_characteristic"] = 0

# merge networks
merged, lookup = pp.merge_nets(net1, net2, validate=False, return_net2_reindex_lookup=True)

# The second transformer should have the second characteristic
assert merged.trafo.loc[1, "vk_percent_characteristic"] == 1


def test_select_subnet():
# This network has switches of type 'l' and 't'
11 changes: 11 additions & 0 deletions pandapower/toolbox/data_modification.py
Original file line number Diff line number Diff line change
@@ -283,6 +283,17 @@ def reindex_elements(net, element_type, new_indices=None, old_indices=None, look
reindex_buses(net, lookup)
return

if element_type == "characteristic":
for old_id, new_id in lookup.items():
for ele in ['vk_percent_characteristic', 'vkr_percent_characteristic']:
if ele in net.trafo:
net.trafo.loc[net.trafo[ele] == old_id, ele] = new_id

for ele in ['vk_hv_percent_characteristic', 'vkr_hv_percent_characteristic', 'vk_mv_percent_characteristic',
'vkr_mv_percent_characteristic', 'vk_lv_percent_characteristic', 'vkr_lv_percent_characteristic']:
if ele in net.trafo3w:
net.trafo3w.loc[net.trafo3w[ele] == old_id, ele] = new_id

# --- reindex
new_index = pd.Series(net[element_type].index, index=net[element_type].index)
if element_type != "group":

0 comments on commit 00d9e22

Please sign in to comment.