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

Selectively invert plot axis via normal vector in CutPlane #384

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion floris/tools/cut_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions floris/tools/floris_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion floris/tools/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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([])
Expand Down