Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Schaefer authored Dec 18, 2019
2 parents f2033fd + e24340b commit 7994840
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pandapower/plotting/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def create_line_collection(net, lines=None, line_geodata=None, bus_geodata=None,
bus_geodata if bus_geodata is not None else net["bus_geodata"], "line")
else:
lines_with_geo = lines[np.isin(lines, line_geodata.index.values)]
coords = list(line_geodata[lines_with_geo])
coords = list(line_geodata.loc[lines_with_geo, 'coords'])
lines_without_geo = set(lines) - set(lines_with_geo)
if lines_without_geo:
logger.warning("Could not plot lines %s. %s geodata is missing for those lines!"
Expand Down
3 changes: 2 additions & 1 deletion pandapower/test/timeseries/test_timeseries_recycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ def _run_recycle(net):
return vm_pu, ll


def _run_normal(net):
def _run_normal(net, time_steps=time_steps):
ow = OutputWriter(net, output_path=tempfile.gettempdir(), output_file_type=".json")
ow.log_variable("res_bus", "va_degree")
run_timeseries(net, time_steps, recycle=False)
return ow

Expand Down
4 changes: 4 additions & 0 deletions pandapower/timeseries/output_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def __repr__(self):
s += "\n'" + str(table) + "." + str(variable) + "'"
return s

def _monkey_patch(self, method, new):
from types import MethodType
setattr(self, method, MethodType(new, self))

def _add_log_defaults(self):
if self.log_variables is None:
self.log_variables = list()
Expand Down
22 changes: 18 additions & 4 deletions pandapower/timeseries/run_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ def init_time_series(net, time_steps, continue_on_divergence=False, verbose=True
ts_variables["time_steps"] = time_steps
# If True, a diverged power flow is ignored and the next step is calculated
ts_variables["continue_on_divergence"] = continue_on_divergence
# print settings
ts_variables["verbose"] = verbose

if logger.level is not 10 and verbose:
# simple progress bar
Expand All @@ -266,7 +268,7 @@ def init_time_series(net, time_steps, continue_on_divergence=False, verbose=True

def cleanup(ts_variables):
if isinstance(ts_variables["recycle_options"], dict):
# Todo: delete internal variaables and dumped results which are not needed
# Todo: delete internal variables and dumped results which are not needed
pass


Expand All @@ -285,6 +287,20 @@ def print_progress(i, time_step, time_steps, verbose, **kwargs):
func = kwargs["progress_function"]
func(i, time_step, time_steps, **kwargs)

def run_loop(net, ts_variables, **kwargs):
"""
runs the time series loop which calls pp.runpp (or another run function) in each iteration
Parameters
----------
net - pandapower net
ts_variables - settings for time series
"""
for i, time_step in enumerate(ts_variables["time_steps"]):
print_progress(i, time_step, ts_variables["time_steps"], ts_variables["verbose"], **kwargs)
run_time_step(net, time_step, ts_variables, **kwargs)


def run_timeseries(net, time_steps=None, continue_on_divergence=False, verbose=True, **kwargs):
"""
Expand All @@ -311,9 +327,7 @@ def run_timeseries(net, time_steps=None, continue_on_divergence=False, verbose=T
ts_variables = init_time_series(net, time_steps, continue_on_divergence, verbose, **kwargs)

control_diagnostic(net)
for i, time_step in enumerate(ts_variables["time_steps"]):
print_progress(i, time_step, ts_variables["time_steps"], verbose, **kwargs)
run_time_step(net, time_step, ts_variables, **kwargs)
run_loop(net, ts_variables, **kwargs)

# cleanup functions after the last time step was calculated
cleanup(ts_variables)

0 comments on commit 7994840

Please sign in to comment.