Skip to content

Error when plotting flow map with many turbine types

Hi @mmpe, I made a wind farm model that contains lots of turbine types. Then, I plot the flow map and PyWake crashed with

File ...\site-packages\py_wake\wind_turbines\_wind_turbines.py:175, in WindTurbines.plot_xy(self, x, y, types, wd, yaw, tilt, normalize_with, ax)
    172 else:
    173     for wd_ in np.atleast_1d(wd):
    174         circle = Ellipse((x_, y_), 2 * r * np.sin(np.deg2rad(tilt_)), 2 * r,
--> 175                          angle=90 - wd_ + yaw_, ec=colors[t], fc="None")
    176         ax.add_artist(circle)
    177         ax.plot(x_, y_, '.', color=colors[t])

IndexError: list index out of range

This is because the colors array is defined as colors = ['k', 'gray', 'r', 'g'] * 5 and it simply ran out. One solution is to use cycle. While we are there, we might also add some more colors from a color map (obviously, black must be the first).

If you like, I can fix it 🙂