Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/additional patches #2114

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5d696d2
Ground work for different sgen patches
hzraja Mar 21, 2023
193483f
Updated patch_maker with sgen WT (line based single blade)
hzraja Mar 28, 2023
411a3b7
Updated patch_maker for sgen type WT (3 blade design)
hzraja Mar 30, 2023
f303f99
Added support for PV patch & reworked WT patch
hzraja Apr 23, 2023
e6320bc
Added support for PV patch orientation
hzraja Apr 24, 2023
f981023
Added support for WT patch orientation
hzraja Apr 25, 2023
9de40f0
Removed unwanted imports
hzraja Apr 25, 2023
cb5c0ed
Merge branch 'develop' into personal_develop
hzraja Apr 25, 2023
5d59505
Merge branch 'develop' of https://github.com/e2nIEE/pandapower into p…
hzraja Apr 25, 2023
b14128a
Merge branch 'personal_develop' of https://github.com/hzraja/pandapow…
hzraja Apr 25, 2023
717a8d2
Fixed a bug where only 1 type of sgen patch was plotted on all nodes
hzraja Apr 26, 2023
77a4d71
mutiple patches on same node partial fix
hzraja May 15, 2023
70294d9
multiple patches hardcoded positions
hzraja May 22, 2023
67ac4ac
unique patch count implementation
hzraja May 26, 2023
71c5ffd
resolved arguments
hzraja May 30, 2023
7675b09
multiple patches v0.9
hzraja Jun 13, 2023
1caad82
Merge branch 'develop' of https://github.com/e2nIEE/pandapower into p…
hzraja Jun 14, 2023
c3f5945
multiple patches v0.91
hzraja Jun 21, 2023
fcf5196
multiple patches v0.92
hzraja Jun 29, 2023
2989128
multiple patches v0.93
hzraja Jul 4, 2023
b957c26
multiple patches v0.95
hzraja Jul 4, 2023
05b069a
Merge branch 'develop' of https://github.com/e2nIEE/pandapower into p…
hzraja Jul 4, 2023
5e2d93f
multiple patches v0.95 (updated changelog and doc-string)
hzraja Jul 4, 2023
89d5e0c
Update CHANGELOG.rst
jwiemer112 Jul 4, 2023
2bb4220
removed unused argument (patch_count)
hzraja Jul 4, 2023
e15487e
fixed simple_plot bugs to adapt to tutorial
hzraja Jul 5, 2023
8cc38ed
Merge branch 'personal_develop' of https://github.com/hzraja/pandapow…
hzraja Jul 5, 2023
9245414
fixed tutorial bug #2
hzraja Jul 5, 2023
ee3aecd
Fixed tutorial internal_datastructure bug
hzraja Jul 31, 2023
f5a5043
fixed tutorial distributed_slack bug
hzraja Aug 1, 2023
2ac7e9f
resolved conflicts
hzraja Aug 1, 2023
555ebf1
Fixed -sgen patches not appearing in some cases
hzraja Aug 7, 2023
b2197c5
Merge branch 'develop' of https://github.com/e2nIEE/pandapower into p…
hzraja Aug 8, 2023
a295e25
fixed pandapipes compatibility
hzraja Aug 16, 2023
54a4127
resolving conflicts
hzraja Aug 16, 2023
488db49
fixed codacy errors
hzraja Aug 16, 2023
8391813
Merge branch 'develop' into feature/additional_patches
hzraja Aug 21, 2023
869dfef
Merge branch 'develop' into feature/additional_patches
jwiemer112 Sep 1, 2023
b0d9cba
Merge branch 'develop' into feature/additional_patches
jwiemer112 Sep 15, 2023
2a498a9
q
hzraja Sep 15, 2023
d26acc9
Merge branch 'develop' into feature/additional_patches
jwiemer112 Sep 15, 2023
0017917
collections_implementation
hzraja Nov 16, 2023
a6a4d3e
seperated unique_angles and draw by type in draw collections
hzraja Dec 7, 2023
c6addd8
removed redundancies
hzraja Dec 20, 2023
1b69061
Merge branch 'develop' of https://github.com/e2nIEE/pandapower into f…
hzraja Dec 20, 2023
9848d90
Merge branch 'develop' into feature/additional_patches
hzraja Dec 20, 2023
dfb8d7c
Merge remote-tracking branch 'pp_fork/feature/additional_patches' int…
hzraja Dec 20, 2023
9a55153
removed main.py
hzraja Jan 8, 2024
354f822
align parameter order as in the other collection functions
SteffenMeinecke Apr 9, 2024
cb4ec60
Merge branch 'develop' into feature/additional_patches
SteffenMeinecke Apr 11, 2024
8dc50bd
* fix number of plotted elements (not at every node a sgen or gen...
SteffenMeinecke Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 45 additions & 59 deletions pandapower/plotting/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import numpy as np
from pandas import isnull

try:
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection, PatchCollection, Collection
Expand Down Expand Up @@ -225,6 +224,7 @@ def _create_line2d_collection(coords, indices, infos=None, picker=False, **kwarg
def _create_node_element_collection(node_coords, patch_maker, size=1., infos=None,
repeat_infos=(1, 1), orientation=np.pi, picker=False,
patch_facecolor="w", patch_edgecolor="k", line_color="k",
patch_type=None, unique_angles=None,draw_sgens_by_type=None,
**kwargs):
"""
Creates matplotlib collections of node elements. All node element collections usually consist of
Expand All @@ -238,6 +238,8 @@ def _create_node_element_collection(node_coords, patch_maker, size=1., infos=Non
:type patch_maker: function
:param size: patch size
:type size: float, default 1
:param unique_angles: angles for patches
:type size: dict
:param infos: list of infos belonging to each of the elements (can be displayed when hovering \
over them)
:type infos: iterable, default None
Expand Down Expand Up @@ -277,10 +279,10 @@ def _create_node_element_collection(node_coords, patch_maker, size=1., infos=Non
linewidths = kwargs.pop("linewidths", 2.)
linewidths = kwargs.pop("linewidth", linewidths)
linewidths = kwargs.pop("lw", linewidths)

lines, polys, popped_keywords = patch_maker(
node_coords, size, angles, patch_facecolor=patch_facecolor, patch_edgecolor=patch_edgecolor,
**kwargs)
node_coords, size, angles, patch_type = patch_type, unique_angles=unique_angles,
draw_sgens_by_type=draw_sgens_by_type, patch_facecolor=patch_facecolor,
patch_edgecolor=patch_edgecolor, **kwargs)
for kw in set(popped_keywords) & set(kwargs.keys()):
kwargs.pop(kw)
patch_coll = PatchCollection(polys, match_original=True, picker=picker, linewidth=linewidths,
Expand Down Expand Up @@ -391,7 +393,7 @@ def create_bus_collection(net, buses=None, size=5, patch_type="circle", color=No
If None, net["bus_geodata"] is used

**cbar_title** (str, "Bus Voltage [pu]") - colormap bar title in case of given cmap

**clim** (tuple of floats, None) - setting the norm limits for image scaling

**plot_colormap** (bool, True) - flag whether the colormap is actually drawn
Expand Down Expand Up @@ -966,8 +968,8 @@ def create_busbar_collection(net, buses=None, infofunc=None, cmap=None, norm=Non
return lc


def create_load_collection(net, loads=None, size=1., infofunc=None, orientation=np.pi, picker=False,
**kwargs):
def create_load_collection(net, loads=None, size=1., infofunc=None, orientation=None, picker=False,
unique_angles=None, **kwargs):
"""
Creates a matplotlib patch collection of pandapower loads.

Expand All @@ -979,6 +981,8 @@ def create_load_collection(net, loads=None, size=1., infofunc=None, orientation=

**size** (float, 1) - patch size

**unique_angles** {dict} angles for patches

**infofunc** (function, None) - infofunction for the patch element

**orientation** (float, np.pi) - orientation of load collection. pi is directed downwards,
Expand All @@ -993,20 +997,24 @@ def create_load_collection(net, loads=None, size=1., infofunc=None, orientation=

**load_lc** - line collection
"""
from pandapower.plotting.simple_plot import calculate_unique_angles

# if unique_angles == None:
# unique_angles = calculate_unique_angles(net)
loads = get_index_array(loads, net.load.index)
infos = [infofunc(i) for i in range(len(loads))] if infofunc is not None else []
node_coords = net.bus_geodata.loc[net.load.loc[loads, "bus"].values, ["x", "y"]].values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we allowed to remove this statement?


color = kwargs.pop("color", "k")

load_pc, load_lc = _create_node_element_collection(
node_coords, load_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color, **kwargs)
node_coords, load_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color, unique_angles=unique_angles, **kwargs)
return load_pc, load_lc


def create_gen_collection(net, gens=None, size=1., infofunc=None, orientation=np.pi, picker=False,
**kwargs):
def create_gen_collection(net, gens=None, size=1., infofunc=None, orientation=None, picker=False,
unique_angles=None, **kwargs):
"""
Creates a matplotlib patch collection of pandapower gens.

Expand All @@ -1018,6 +1026,8 @@ def create_gen_collection(net, gens=None, size=1., infofunc=None, orientation=np

**size** (float, 1) - patch size

**unique_angles** {dict} angles for patches

**infofunc** (function, None) - infofunction for the patch element

**orientation** (float or list of floats, np.pi) - orientation of gen collection. pi is\
Expand All @@ -1032,20 +1042,22 @@ def create_gen_collection(net, gens=None, size=1., infofunc=None, orientation=np

**gen_lc** - line collection
"""
from pandapower.plotting.simple_plot import calculate_unique_angles

# if unique_angles == None:
# unique_angles = calculate_unique_angles(net)
gens = get_index_array(gens, net.gen.index)
infos = [infofunc(i) for i in range(len(gens))] if infofunc is not None else []
node_coords = net.bus_geodata.loc[net.gen.loc[gens, "bus"].values, ["x", "y"]].values

color = kwargs.pop("color", "k")

gen_pc, gen_lc = _create_node_element_collection(
node_coords, gen_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color, **kwargs)
node_coords, gen_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color, unique_angles=unique_angles, **kwargs)
return gen_pc, gen_lc


def create_sgen_collection(net, sgens=None, size=1., infofunc=None, orientation=np.pi, picker=False,
**kwargs):
def create_sgen_collection(net, sgens=None, size=1., infofunc=None, orientation=None, picker=False,
patch_type=None, unique_angles=None,draw_sgens_by_type=None, **kwargs):
"""
Creates a matplotlib patch collection of pandapower sgen.

Expand All @@ -1057,6 +1069,8 @@ def create_sgen_collection(net, sgens=None, size=1., infofunc=None, orientation=

**size** (float, 1) - patch size

**unique_angles** {dict} angles for patches

**infofunc** (function, None) - infofunction for the patch elem

**picker** (bool, False) - picker argument passed to the patch collectionent
Expand All @@ -1071,15 +1085,17 @@ def create_sgen_collection(net, sgens=None, size=1., infofunc=None, orientation=

**sgen_lc** - line collection
"""
sgens = get_index_array(sgens, net.sgen.index)
from pandapower.plotting.simple_plot import calculate_unique_angles
# if draw_sgens_by_type == True:
# unique_angles = calculate_unique_angles(net)


infos = [infofunc(i) for i in range(len(sgens))] if infofunc is not None else []
node_coords = net.bus_geodata.loc[net.sgen.loc[sgens, "bus"].values, ["x", "y"]].values

color = kwargs.pop("color", "k")

sgen_pc, sgen_lc = _create_node_element_collection(
node_coords, sgen_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color, **kwargs)
node_coords, sgen_patches, size=size, infos=infos, orientation=orientation,
picker=picker, line_color=color,patch_type=patch_type,unique_angles=unique_angles,draw_sgens_by_type=draw_sgens_by_type, **kwargs)
return sgen_pc, sgen_lc


Expand Down Expand Up @@ -1122,8 +1138,8 @@ def create_storage_collection(net, storages=None, size=1., infofunc=None, orient
return storage_pc, storage_lc


def create_ext_grid_collection(net, size=1., infofunc=None, orientation=0, picker=False,
ext_grids=None, ext_grid_buses=None, **kwargs):
def create_ext_grid_collection(net, ext_grids=None, size=1., infofunc=None, orientation=0,
picker=False, ext_grid_buses=None, **kwargs):
"""
Creates a matplotlib patch collection of pandapower ext_grid. Parameters
ext_grids, ext_grid_buses can be used to specify, which ext_grids the collection should be
Expand Down Expand Up @@ -1160,7 +1176,6 @@ def create_ext_grid_collection(net, size=1., infofunc=None, orientation=0, picke
infos = [infofunc(ext_grid_idx) for ext_grid_idx in ext_grids] if infofunc is not None else []

node_coords = net.bus_geodata.loc[ext_grid_buses, ["x", "y"]].values

color = kwargs.pop("color", "k")

ext_grid_pc, ext_grid_lc = _create_node_element_collection(
Expand All @@ -1170,7 +1185,8 @@ def create_ext_grid_collection(net, size=1., infofunc=None, orientation=0, picke
return ext_grid_pc, ext_grid_lc


def create_line_switch_collection(net, switches=None, size=1, distance_to_bus=3, use_line_geodata=False, **kwargs):
def create_line_switch_collection(net, switches=None, size=1, distance_to_bus=3,
use_line_geodata=False, **kwargs):
"""
Creates a matplotlib patch collection of pandapower line-bus switches.

Expand Down Expand Up @@ -1335,8 +1351,8 @@ def create_bus_bus_switch_collection(net, size=1., helper_line_style=':', helper


def draw_collections(collections, figsize=(10, 8), ax=None, plot_colorbars=True, set_aspect=True,
axes_visible=(False, False), copy_collections=True, draw=True, aspect=('equal', 'datalim'),
autoscale=(True, True, True)):
axes_visible=(False, False), copy_collections=True, draw=True,
aspect=('equal', 'datalim'), autoscale=(True, True, True)):
"""
Draws matplotlib collections which can be created with the create collection functions.

Expand Down Expand Up @@ -1415,34 +1431,4 @@ def add_collections_to_axes(ax, collections, plot_colorbars=True, copy_collectio


if __name__ == "__main__":
# if 0:
# import pandapower as pp
#
# ntw = pp.create_empty_network()
# b1 = pp.create_bus(ntw, 10, geodata=(5, 10))
# b2 = pp.create_bus(ntw, 0.4, geodata=(5, 15))
# b3 = pp.create_bus(ntw, 0.4, geodata=(0, 22))
# b4 = pp.create_bus(ntw, 0.4, geodata=(8, 20))
# pp.create_gen(ntw, b1, p_mw=0.1)
# pp.create_load(ntw, b3, p_mw=0.1)
# pp.create_ext_grid(ntw, b4)
#
# pp.create_line(ntw, b2, b3, 2.0, std_type="NAYY 4x50 SE")
# pp.create_line(ntw, b2, b4, 2.0, std_type="NAYY 4x50 SE")
# pp.create_transformer(ntw, b1, b2, std_type="0.63 MVA 10/0.4 kV")
# pp.create_transformer(ntw, b3, b4, std_type="0.63 MVA 10/0.4 kV")
#
# bus_col = create_bus_collection(ntw, size=0.2, color="k")
# line_col = create_line_collection(ntw, use_line_geodata=False, color="k", linewidth=3.)
# lt, bt = create_trafo_collection(ntw, size=2, linewidth=3.)
# load_col1, load_col2 = create_load_collection(ntw, linewidth=2.,
# infofunc=lambda x: ("load", x))
# gen1, gen2 = create_gen_collection(ntw, linewidth=2.,
# infofunc=lambda x: ("gen", x))
# eg1, eg2 = create_ext_grid_collection(ntw, size=2.,
# infofunc=lambda x: ("ext_grid", x))
#
# draw_collections([bus_col, line_col, load_col1, load_col2, gen1, gen2, lt, bt, eg1, eg2])
# else:
# pass
pass
pass
Loading
Loading