diff --git a/examples/03_making_adjustments.py b/examples/03_making_adjustments.py index 54941ede6..c93011fa5 100644 --- a/examples/03_making_adjustments.py +++ b/examples/03_making_adjustments.py @@ -57,11 +57,11 @@ 5.0 * fi.floris.farm.rotor_diameters[0][0][0] * np.arange(0, N, 1), 5.0 * fi.floris.farm.rotor_diameters[0][0][0] * np.arange(0, N, 1), ) -fi.reinitialize(layout_x=X.flatten(), layout_y=Y.flatten()) +fi.reinitialize(layout_x=X.flatten(), layout_y=Y.flatten(), wind_directions=[360.0]) horizontal_plane = fi.calculate_horizontal_plane(height=90.0) wakeviz.visualize_cut_plane(horizontal_plane, ax=axarr[3], title="3x3 Farm", min_speed=MIN_WS, max_speed=MAX_WS) wakeviz.add_turbine_id_labels(fi, axarr[3], color="w", backgroundcolor="k") - +wakeviz.plot_turbines_with_fi(fi, axarr[3]) # Change the yaw angles and configure the plot differently yaw_angles = np.zeros((1, 1, N * N)) diff --git a/floris/tools/visualization.py b/floris/tools/visualization.py index 608fb5944..ed47e2cf4 100644 --- a/floris/tools/visualization.py +++ b/floris/tools/visualization.py @@ -22,11 +22,20 @@ from matplotlib import rcParams from floris.tools.floris_interface import FlorisInterface +from floris.utilities import rotate_coordinates_rel_west def show_plots(): plt.show() -def plot_turbines(ax, layout_x, layout_y, yaw_angles, rotor_diameters, color=None, wind_direction=270.0): +def plot_turbines( + ax, + layout_x, + layout_y, + yaw_angles, + rotor_diameters, + color: str | None = None, + wind_direction: float = 270.0 +): """ Plot wind plant layout from turbine locations. @@ -39,13 +48,13 @@ def plot_turbines(ax, layout_x, layout_y, yaw_angles, rotor_diameters, color=Non color (str): Pyplot color option to plot the turbines. wind_direction (float): Wind direction (rotates farm) """ - - # Correct for the wind direction - yaw_angles = np.array(yaw_angles) # - wind_direction - 270 - if color is None: color = "k" - for x, y, yaw, d in zip(layout_x, layout_y, yaw_angles, rotor_diameters): + + coordinates_array = np.array([[x, y, 0.0] for x, y in list(zip(layout_x, layout_y))]) + layout_x, layout_y, _ = rotate_coordinates_rel_west(np.array([wind_direction]), coordinates_array) + + for x, y, yaw, d in zip(layout_x[0,0], layout_y[0,0], yaw_angles, rotor_diameters): R = d / 2.0 x_0 = x + np.sin(np.deg2rad(yaw)) * R x_1 = x - np.sin(np.deg2rad(yaw)) * R @@ -90,9 +99,12 @@ def add_turbine_id_labels(fi: FlorisInterface, ax: plt.Axes, **kwargs): fi (FlorisInterface): Simulation object to get the layout and index information. ax (plt.Axes): Axes object to add the labels. """ + coordinates_array = np.array([[x, y, 0.0] for x, y in list(zip(fi.layout_x, fi.layout_y))]) + wind_direction = fi.floris.flow_field.wind_directions[0] + layout_x, layout_y, _ = rotate_coordinates_rel_west(np.array([wind_direction]), coordinates_array) for i in range(fi.floris.farm.n_turbines): - ax.annotate(i, (fi.layout_x[i], fi.layout_y[i]), xytext=(0,10), textcoords="offset points", **kwargs) + ax.annotate(i, (layout_x[0,0,i], layout_y[0,0,i]), xytext=(0,10), textcoords="offset points", **kwargs) def line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, **kwargs):