e2nIEE / pandapower

Convenient Power System Modelling and Analysis based on PYPOWER and pandas
https://www.pandapower.org
Other
847 stars 478 forks source link

Plotting bug: switches at lines connecting busbars #1400

Open agoymann opened 2 years ago

agoymann commented 2 years ago

Hi,

I would like to plot two switches at the beginning and the end of a line connecting to busbars, which are illustrated as expanded bars (not dots).

The first switch is plotted at the correct position. The second one is not plotted correctly.

My guess is that my problem is connect to the fact that the create_line_switch_collection function is using the line geodata to plot the correct position of the switch.

With the first switch it works, but the position of the second switch somehow gets messed up, if the connection point of the line is not identical with the geodata-coordinates of the busbar.

The problem does not occur if both busbars are at different heights.

There was a similar problem in issue number 302.

I am not sure how to fix it. If there's any help, I would really appreciate it!

Kind Regards



import pandapower as pp
import pandapower.plotting as plot
import matplotlib.pyplot as plt

net = pp.create_empty_network()

'''Busbars '''

coords = [(0,0), (3, 0)]
bus1 = pp.create_bus(
    net=net, vn_kv=20, geodata=coords[1], coords=[coords], type="b")

coords = [(8,0), (14, 0)]
bus2 = pp.create_bus(
    net=net, vn_kv=20, geodata=(9.5, 0), coords=[coords], type="b")

coords = [(19,0), (22, 0)]
bus3 = pp.create_bus(
    net=net, vn_kv=20, geodata=coords[1], coords=[coords], type="b")

coords = [(27,1), (33, 1)]
bus4 = pp.create_bus(
    net=net, vn_kv=20, geodata=(29, 0), coords=[coords], type="b")

''' Lines '''
coords = [(2.5, 0), (2.5, -1.5), (8.5, -1.5), (8.5, 0)]
line1 = pp.create_line(net=net, from_bus=bus1, to_bus=bus2, geodata=coords,
                      length_km=0.1, std_type="NA2XS2Y 1x240 RM/25 12/20 kV")

coords = [(20, 0), (20, -1.5), (28, -1.5), (28, 1)]
line2 = pp.create_line(net=net, from_bus=bus3, to_bus=bus4, geodata=coords,
                      length_km=0.1, std_type="NA2XS2Y 1x240 RM/25 12/20 kV")

'''Switches'''
switch1 = pp.create_switch(net, bus1, line1, et="l", type="LBS", 
                            closed=True)

switch2 = pp.create_switch(net, bus2, line1, et="l", type="LBS", 
                            closed=True)

switch3 = pp.create_switch(net, bus3, line2, et="l", type="LBS", 
                            closed=True)

switch4 = pp.create_switch(net, bus4, line2, et="l", type="LBS", 
                            closed=True,)

'''Plot'''
lic = plot.create_line_collection(net,  use_bus_geodata=False, color="k")
lsc = plot.create_line_switch_collection(
    net, size=0.4, distance_to_bus=0.75, use_line_geodata=True)
bbc = plot.create_busbar_collection(net, buses=[0,1,2,3,4,5,6,7], color="k")

plot.draw_collections([lic, bbc, lsc], figsize=(20, 10))
plt.show()
``
![Busbar_Bug](https://user-images.githubusercontent.com/91837807/142386566-296a4816-0143-4d84-8931-d08bc2778b46.PNG)
`
agoymann commented 2 years ago

Busbar_Bug