Skip to content

Commit

Permalink
Merge branch 'release/v2.14.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
vogt31337 committed Mar 28, 2024
2 parents 6718045 + 72b7872 commit d6f0d93
Show file tree
Hide file tree
Showing 94 changed files with 762 additions and 746 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Change Log
[upcoming release] - 2024-..-..
-------------------------------

[2.14.5] - 2024-03-28
-------------------------------
- [CHANGED] added possibility to provide custom weights to switches and transformers (before - always zero) when creating a graph
- [FIXED] many futurewarnings and deprecation warnings

[2.14.4] - 2024-03-28
-------------------------------
- [FIXED] internal pgm test returns ANOTHER error when using python 3.8
Expand Down Expand Up @@ -66,6 +71,7 @@ Change Log
- [ADDED] cim2pp: added description fields for each asset and added BusbarSection information to nodes
- [CHANGED] cim2pp: reformat documentation for reading in files
- [CHANGED] allow providing grid_tables as a parameter to the function that downloads net from PostgreSQL
- [FIXED] avoid FutureWarning of pandas 2.2
- [FIXED] compatibility with lightsim2grid after new version 0.8.0
- [ADDED] allow passing custom runpp-function to pp.diagnostic

Expand Down
4 changes: 2 additions & 2 deletions pandapower/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,9 @@ def _clean_up(net, res=True):
# res_bus.drop(xward_buses, inplace=True)
if len(net["dcline"]) > 0:
dc_gens = net.gen.index[(len(net.gen) - len(net.dcline) * 2):]
net.gen.drop(dc_gens, inplace=True)
net.gen = net.gen.drop(dc_gens)
if res:
net.res_gen.drop(dc_gens, inplace=True)
net.res_gen = net.res_gen.drop(dc_gens)


def _set_isolated_buses_out_of_service(net, ppc):
Expand Down
2 changes: 1 addition & 1 deletion pandapower/control/util/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def drop_same_type_existing_controllers(net, this_ctrl_type, index=None, matchin
same_type_existing_ctrl = get_controller_index(net, ctrl_type=this_ctrl_type,
parameters=matching_params)
if len(same_type_existing_ctrl):
net.controller.drop(same_type_existing_ctrl, inplace=True)
net.controller = net.controller.drop(same_type_existing_ctrl)
logger.debug("Controllers " + str(['%i' % idx for idx in same_type_existing_ctrl]) +
"got removed because of same type and matching parameters as new " +
"controller " + index + ".")
Expand Down
26 changes: 13 additions & 13 deletions pandapower/convert_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def _create_seperate_cost_tables(net, elements_to_deserialize):

def _rename_columns(net, elements_to_deserialize):
if _check_elements_to_deserialize('line', elements_to_deserialize):
net.line.rename(columns={'imax_ka': 'max_i_ka'}, inplace=True)
net.line = net.line.rename(columns={'imax_ka': 'max_i_ka'})
if _check_elements_to_deserialize('gen', elements_to_deserialize):
net.gen.rename(columns={"qmin_mvar": "min_q_mvar", "qmax_mvar": "max_q_mvar"}, inplace=True)
net.gen = net.gen.rename(columns={"qmin_mvar": "min_q_mvar", "qmax_mvar": "max_q_mvar"})
for typ, data in net.std_types["line"].items():
if "imax_ka" in data:
net.std_types["line"][typ]["max_i_ka"] = net.std_types["line"][typ].pop("imax_ka")
Expand All @@ -235,11 +235,11 @@ def _rename_columns(net, elements_to_deserialize):
net.measurement.loc[bus_measurements, "bus"].values
net.measurement.loc[~bus_measurements, "side"] = \
net.measurement.loc[~bus_measurements, "bus"].values
net.measurement.rename(columns={'type': 'measurement_type'}, inplace=True)
net.measurement.drop(["bus"], axis=1, inplace=True)
net.measurement = net.measurement.rename(columns={'type': 'measurement_type'})
net.measurement = net.measurement.drop(["bus"], axis=1)
if _check_elements_to_deserialize('controller', elements_to_deserialize):
if "controller" in net:
net["controller"].rename(columns={"controller": "object"}, inplace=True)
net["controller"] = net["controller"].rename(columns={"controller": "object"})
if "options" in net:
if "recycle" in net["options"]:
if "Ybus" in net["options"]["recycle"]:
Expand Down Expand Up @@ -371,7 +371,7 @@ def _update_trafo_parameter_names(net, elements_to_deserialize):
for element in update_data:
replace_cols = {col: _update_column(col) for col in net[element].columns if
col.startswith("tp") or col.startswith("vsc")}
net[element].rename(columns=replace_cols, inplace=True)
net[element] = net[element].rename(columns=replace_cols)
_update_trafo_type_parameter_names(net)


Expand Down Expand Up @@ -399,16 +399,16 @@ def _set_data_type_of_columns(net):

def _convert_to_mw(net):
replace = [("kw", "mw"), ("kvar", "mvar"), ("kva", "mva")]
for element, tab in net.items():
if isinstance(tab, pd.DataFrame):
for element in net.keys():
if isinstance(net[element], pd.DataFrame):
for old, new in replace:
diff = {column: column.replace(old, new) for column in tab.columns if old in column
and column != "pfe_kw"}
tab.rename(columns=diff, inplace=True)
if len(tab) == 0:
diff = {column: column.replace(old, new) for column in net[element].columns if
old in column and column != "pfe_kw"}
net[element] = net[element].rename(columns=diff)
if len(net[element]) == 0:
continue
for old, new in diff.items():
tab[new] *= 1e-3
net[element][new] *= 1e-3

for element, std_types in net.std_types.items():
for std_type, parameters in std_types.items():
Expand Down
2 changes: 1 addition & 1 deletion pandapower/converter/cim/cim2pp/build_pp_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def convert_to_pp(self, convert_line_to_switch: bool = False, line_r_limit: floa
# fuse boundary ConnectivityNodes with their TopologicalNodes
bus_t = self.net.bus.reset_index(level=0, drop=False)
bus_drop = bus_t.loc[bus_t[sc['o_prf']] == 'eq_bd', ['index', sc['o_id'], 'cim_topnode']]
bus_drop.rename(columns={'index': 'b1'}, inplace=True)
bus_drop = bus_drop.rename(columns={'index': 'b1'})
bus_drop = pd.merge(bus_drop, bus_t[['index', sc['o_id']]].rename(columns={'index': 'b2', sc['o_id']: 'o_id2'}),
how='inner', left_on='cim_topnode', right_on='o_id2')
if bus_drop.index.size > 0:
Expand Down
26 changes: 13 additions & 13 deletions pandapower/converter/cim/cim2pp/convert_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def create_measurements_from_analog(self):
'PowerSystemResource', 'positiveFlowIn']],
self.cim['eq']['AnalogValue'][['sensorAccuracy', 'MeasurementValueSource', 'Analog', 'value']],
how='inner', left_on='rdfId', right_on='Analog')
analogs.drop(columns=['rdfId', 'Analog'], inplace=True)
analogs = analogs.drop(columns=['rdfId', 'Analog'])
analogs = pd.merge(analogs, self.cim['eq']['MeasurementValueSource'], how='left',
left_on='MeasurementValueSource',
right_on='rdfId')
analogs.drop(columns=['rdfId', 'MeasurementValueSource'], inplace=True)
analogs = analogs.drop(columns=['rdfId', 'MeasurementValueSource'])
# collect all the assets (line, trafo, trafo3w) and its connections
assets = pd.DataFrame(None, columns=['element_type', 'side'])
append_dict = dict({'line': {'from_bus': 'from', 'to_bus': 'to'},
Expand All @@ -61,7 +61,7 @@ def create_measurements_from_analog(self):
temp['element_type'] = element_type
temp['side'] = side
assets = pd.concat([assets, temp], sort=False)
assets.rename(columns={'index': 'element'}, inplace=True)
assets = assets.rename(columns={'index': 'element'})
# now join the analogs with the assets
psr = pd.merge(analogs, assets, how='inner', left_on='PowerSystemResource', right_on=sc['o_id'])
# keep only entries which are associated to the terminal from the asset
Expand Down Expand Up @@ -96,24 +96,24 @@ def create_measurements_from_sv(self):
sc = cim_tools.get_pp_net_special_columns_dict()
# get the measurements from the sv profile and set the Terminal as index
sv_powerflow = self.cim['sv']['SvPowerFlow'][['Terminal', 'p', 'q']]
sv_powerflow.set_index('Terminal', inplace=True)
sv_powerflow = sv_powerflow.set_index('Terminal')

# ---------------------------------------measure: bus v---------------------------------------------------
busses_temp = self.net.bus[['name', 'vn_kv', sc['ct']]].copy()
busses_temp.reset_index(level=0, inplace=True)
busses_temp.rename(columns={'index': 'element', sc['ct']: 'TopologicalNode'}, inplace=True)
busses_temp = busses_temp.reset_index(level=0)
busses_temp = busses_temp.rename(columns={'index': 'element', sc['ct']: 'TopologicalNode'})
sv_sv_voltages = pd.merge(self.cim['sv']['SvVoltage'][['TopologicalNode', 'v']], busses_temp,
how='left', on='TopologicalNode')
# drop all the rows mit vn_kv == np.NaN (no measurements available for that bus)
sv_sv_voltages.dropna(subset=['vn_kv'], inplace=True)
sv_sv_voltages = sv_sv_voltages.dropna(subset=['vn_kv'])
sv_sv_voltages.reset_index(inplace=True)
if 'index' in sv_sv_voltages.columns:
sv_sv_voltages.drop(['index'], inplace=True, axis=1)
sv_sv_voltages = sv_sv_voltages.drop(['index'], axis=1)
# value -> voltage ()
sv_sv_voltages['value'] = sv_sv_voltages.v / sv_sv_voltages.vn_kv
sv_sv_voltages['value'].replace(0, np.nan, inplace=True)
# drop all the rows mit value == np.NaN
sv_sv_voltages.dropna(subset=['value'], inplace=True)
sv_sv_voltages = sv_sv_voltages.dropna(subset=['value'])
sv_sv_voltages.reset_index(inplace=True)
sv_sv_voltages['value_stddev'] = sv_sv_voltages.value * 0.001
sv_sv_voltages['vn_kv_stddev'] = 0.1 / sv_sv_voltages.vn_kv
Expand All @@ -136,7 +136,7 @@ def create_measurements_from_sv(self):
line_temp['q_to'] = \
pd.merge(line_temp[sc['t_to']], sv_powerflow['q'], left_on=sc['t_to'], right_index=True)['q']

line_temp.dropna(subset=['p_from', 'p_to', 'q_from', 'q_to'], thresh=4, inplace=True)
line_temp = line_temp.dropna(subset=['p_from', 'p_to', 'q_from', 'q_to'], thresh=4)

line_temp['stddev_line_from_p'] = abs(line_temp.p_from) * sigma_line + 1.
line_temp['stddev_line_to_p'] = abs(line_temp.p_to) * sigma_line + 1.
Expand Down Expand Up @@ -181,7 +181,7 @@ def create_measurements_from_sv(self):
trafo_temp['q_lv'] = \
pd.merge(trafo_temp[sc['t_lv']], sv_powerflow['q'], left_on=sc['t_lv'], right_index=True)['q']

trafo_temp.dropna(subset=['p_hv', 'p_lv', 'q_hv', 'q_lv'], thresh=4, inplace=True)
trafo_temp = trafo_temp.dropna(subset=['p_hv', 'p_lv', 'q_hv', 'q_lv'], thresh=4)

trafo_temp['stddev_trafo_hv_p'] = abs(trafo_temp.p_hv) * sigma_trafo + 1.
trafo_temp['stddev_trafo_lv_p'] = abs(trafo_temp.p_lv) * sigma_trafo + 1.
Expand Down Expand Up @@ -230,7 +230,7 @@ def create_measurements_from_sv(self):
trafo3w_temp['q_lv'] = \
pd.merge(trafo3w_temp[sc['t_lv']], sv_powerflow['q'], left_on=sc['t_lv'], right_index=True)['q']

trafo3w_temp.dropna(subset=['p_hv', 'p_mv', 'p_lv', 'q_hv', 'q_mv', 'q_lv'], thresh=6, inplace=True)
trafo3w_temp = trafo3w_temp.dropna(subset=['p_hv', 'p_mv', 'p_lv', 'q_hv', 'q_mv', 'q_lv'], thresh=6)

trafo3w_temp['stddev_trafo_hv_p'] = abs(trafo3w_temp.p_hv) * sigma_trafo3w + 1.
trafo3w_temp['stddev_trafo_mv_p'] = abs(trafo3w_temp.p_mv) * sigma_trafo3w + 1.
Expand Down Expand Up @@ -275,7 +275,7 @@ def create_measurements_from_sv(self):
self._copy_to_measurement(trafo3w_temp)

# remove NaN values
self.net.measurement.dropna(subset=['value'], inplace=True)
self.net.measurement = self.net.measurement.dropna(subset=['value'])
# set the element from float to default uint32
self._set_measurement_element_datatype()

Expand Down

0 comments on commit d6f0d93

Please sign in to comment.