From 4636eef61f374410b9e8c4287326550d0ad82373 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Sun, 27 Feb 2022 13:14:11 -0600 Subject: [PATCH] Add normal vector to CutPlane to invert plot axis --- floris/tools/cut_plane.py | 3 ++- floris/tools/floris_interface.py | 6 +++--- floris/tools/visualization.py | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/floris/tools/cut_plane.py b/floris/tools/cut_plane.py index 557b4e299..633066630 100644 --- a/floris/tools/cut_plane.py +++ b/floris/tools/cut_plane.py @@ -105,7 +105,7 @@ class CutPlane: FLORIS simulation, or other such as SOWFA result. """ - def __init__(self, df, x1_resolution, x2_resolution): + def __init__(self, df, x1_resolution, x2_resolution, normal_vector): """ Initialize CutPlane object, storing the DataFrame and resolution. @@ -114,6 +114,7 @@ def __init__(self, df, x1_resolution, x2_resolution): columns x1, x2, u, v, w. """ self.df = df + self.normal_vector = normal_vector self.resolution = (x1_resolution, x2_resolution) diff --git a/floris/tools/floris_interface.py b/floris/tools/floris_interface.py index 649e10252..75dd76434 100644 --- a/floris/tools/floris_interface.py +++ b/floris/tools/floris_interface.py @@ -329,7 +329,7 @@ def calculate_horizontal_plane( ) # Compute the cutplane - horizontal_plane = CutPlane(df, self.floris.grid.grid_resolution[0], self.floris.grid.grid_resolution[1]) + horizontal_plane = CutPlane(df, self.floris.grid.grid_resolution[0], self.floris.grid.grid_resolution[1], "z") # Reset the fi object back to the turbine grid configuration self.floris = Floris.from_dict(floris_dict) @@ -409,7 +409,7 @@ def calculate_cross_plane( ) # Compute the cutplane - cross_plane = CutPlane(df, y_resolution, z_resolution) + cross_plane = CutPlane(df, y_resolution, z_resolution, "x") # Reset the fi object back to the turbine grid configuration self.floris = Floris.from_dict(floris_dict) @@ -488,7 +488,7 @@ def calculate_y_plane( ) # Compute the cutplane - y_plane = CutPlane(df, x_resolution, z_resolution) + y_plane = CutPlane(df, x_resolution, z_resolution, "y") # Reset the fi object back to the turbine grid configuration self.floris = Floris.from_dict(floris_dict) diff --git a/floris/tools/visualization.py b/floris/tools/visualization.py index 90406f8df..06c3a9259 100644 --- a/floris/tools/visualization.py +++ b/floris/tools/visualization.py @@ -169,6 +169,9 @@ def visualize_cut_plane( # Add line contour line_contour_cut_plane(cut_plane, ax=ax, levels=levels, colors="w", linewidths=0.8, alpha=0.3) + if cut_plane.normal_vector == "x": + ax.invert_xaxis() + if color_bar: cbar = plt.colorbar(im, ax=ax) cbar.set_label('m/s') @@ -249,7 +252,7 @@ def plot_rotor_values( return_fig_objects: bool = False, save_path: Union[str, None] = None, show: bool = False -) -> Union[None, tuple[plt.figure, plt.axes]]: +) -> Union[None, tuple[plt.figure, plt.axes, plt.axis, plt.colorbar]]: """Plots the gridded turbine rotor values. This is intended to be used for understanding the differences between two sets of values, so each subplot can be used for inspection of what values are differing, and under what conditions. @@ -294,6 +297,7 @@ def plot_rotor_values( norm = mplcolors.Normalize(vmin, vmax) ax.imshow(values[wd_index, ws_index, i].T, cmap=cmap, norm=norm, origin="lower") + ax.invert_xaxis() ax.set_xticks([]) ax.set_yticks([])