Skip to content

Commit

Permalink
Add access to s_res of Results()
Browse files Browse the repository at this point in the history
  • Loading branch information
gplessm committed Sep 8, 2017
1 parent f9a76c1 commit 1a62f0c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions edisgo/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
# Print voltage level of all nodes
# print(network.results.pfa_v_mag_pu)

# Print apparent power at lines
# print(network.results.s_res([_['line'] for _ in network.mv_grid.graph.graph_edges()]))

# Print voltage levels for all lines
# print(network.results.s_res())

# for now create results object
# ToDo: Werte in DataFrame als List oder Array?
# results = Results()
Expand Down
41 changes: 41 additions & 0 deletions edisgo/grid/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from os import path
import pandas as pd
from edisgo.tools import interfaces
from math import sqrt


class Network:
Expand Down Expand Up @@ -526,6 +527,46 @@ def pfa_v_mag_pu(self, pypsa):
self._pfa_v_mag_pu = pd.concat([self._pfa_v_mag_pu, pypsa], axis=1)



def s_res(self, lines=None):
"""
Get resulting apparent power at line(s)
Parameters
----------
lines : line object or list of
Returns
-------
DataFrame
Apparent power for `lines`
"""
# TODO: exclud and report on lines where results are missing
# TODO: return all results if `lines` not given

labels_included = []
labels_not_included = []

labels = [repr(l) for l in lines]

if lines is not None:
for label in labels:
if label in list(self.pfa_p.columns) and label in list(self.pfa_q.columns):
labels_included.append(label)
else:
labels_not_included.append(label)
print(
"Apparent power for {lines} are not returned from PFA".format(
lines=labels_not_included))
else:
labels_included = labels

s_res = ((self.pfa_p[labels_included] ** 2 + self.pfa_q[
labels_included] ** 2) * 1e3).applymap(sqrt)

return s_res

def v_res(self, nodes, level):
"""
Get resulting voltage level at node
Expand Down

0 comments on commit 1a62f0c

Please sign in to comment.