Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/multidimen…
Browse files Browse the repository at this point in the history
…sional_cp_ct
  • Loading branch information
bayc committed Oct 24, 2023
2 parents bc36ed0 + 2dccbbd commit ed3d30f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 17 deletions.
30 changes: 21 additions & 9 deletions examples/02_visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

import floris.tools.visualization as wakeviz
from floris.tools import FlorisInterface
from floris.tools.visualization import (
calculate_horizontal_plane_with_turbines,
visualize_cut_plane,
)


"""
Expand Down Expand Up @@ -78,23 +74,39 @@
# Create the plots
fig, ax_list = plt.subplots(3, 1, figsize=(10, 8))
ax_list = ax_list.flatten()
wakeviz.visualize_cut_plane(horizontal_plane, ax=ax_list[0], title="Horizontal")
wakeviz.visualize_cut_plane(y_plane, ax=ax_list[1], title="Streamwise profile")
wakeviz.visualize_cut_plane(cross_plane, ax=ax_list[2], title="Spanwise profile")
wakeviz.visualize_cut_plane(
horizontal_plane,
ax=ax_list[0],
label_contours=True,
title="Horizontal"
)
wakeviz.visualize_cut_plane(
y_plane,
ax=ax_list[1],
label_contours=True,
title="Streamwise profile"
)
wakeviz.visualize_cut_plane(
cross_plane,
ax=ax_list[2],
label_contours=True,
title="Spanwise profile"
)

# Some wake models may not yet have a visualization method included, for these cases can use
# a slower version which scans a turbine model to produce the horizontal flow
horizontal_plane_scan_turbine = calculate_horizontal_plane_with_turbines(
horizontal_plane_scan_turbine = wakeviz.calculate_horizontal_plane_with_turbines(
fi,
x_resolution=20,
y_resolution=10,
yaw_angles=np.array([[[25.,0.,0.]]]),
)

fig, ax = plt.subplots()
visualize_cut_plane(
wakeviz.visualize_cut_plane(
horizontal_plane_scan_turbine,
ax=ax,
label_contours=True,
title="Horizontal (coarse turbine scan method)",
)

Expand Down
28 changes: 22 additions & 6 deletions examples/16_heterogeneous_inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,30 @@
# Create the plots
fig, ax_list = plt.subplots(3, 1, figsize=(10, 8))
ax_list = ax_list.flatten()
visualize_cut_plane(horizontal_plane_2d, ax=ax_list[0], title="Horizontal", color_bar=True)
visualize_cut_plane(
horizontal_plane_2d,
ax=ax_list[0],
title="Horizontal",
color_bar=True,
label_contours=True
)
ax_list[0].set_xlabel('x')
ax_list[0].set_ylabel('y')
visualize_cut_plane(y_plane_2d, ax=ax_list[1], title="Streamwise profile", color_bar=True)
visualize_cut_plane(
y_plane_2d,
ax=ax_list[1],
title="Streamwise profile",
color_bar=True,
label_contours=True
)
ax_list[1].set_xlabel('x')
ax_list[1].set_ylabel('z')
visualize_cut_plane(
cross_plane_2d,
ax=ax_list[2],
title="Spanwise profile at 500m downstream",
color_bar=True
color_bar=True,
label_contours=True
)
ax_list[2].set_xlabel('y')
ax_list[2].set_ylabel('z')
Expand Down Expand Up @@ -136,23 +149,26 @@
horizontal_plane_3d,
ax=ax_list[0],
title="Horizontal",
color_bar=True
color_bar=True,
label_contours=True
)
ax_list[0].set_xlabel('x')
ax_list[0].set_ylabel('y')
visualize_cut_plane(
y_plane_3d,
ax=ax_list[1],
title="Streamwise profile",
color_bar=True
color_bar=True,
label_contours=True
)
ax_list[1].set_xlabel('x')
ax_list[1].set_ylabel('z')
visualize_cut_plane(
cross_plane_3d,
ax=ax_list[2],
title="Spanwise profile at 500m downstream",
color_bar=True
color_bar=True,
label_contours=True
)
ax_list[2].set_xlabel('y')
ax_list[2].set_ylabel('z')
Expand Down
21 changes: 19 additions & 2 deletions floris/tools/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ def add_turbine_id_labels(fi: FlorisInterface, ax: plt.Axes, **kwargs):
)


def line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, **kwargs):
def line_contour_cut_plane(
cut_plane,
ax=None,
levels=None,
colors=None,
label_contours=False,
**kwargs):
"""
Visualize a cut_plane as a line contour plot.
Expand All @@ -164,6 +170,8 @@ def line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, **kwarg
Defaults to None.
colors (list, optional): Strings of color specification info.
Defaults to None.
label_contours (Boolean, optional): Flag to include a numerical contour labels
on the plot. Defaults to False.
**kwargs: Additional parameters to pass to `ax.contour`.
"""

Expand All @@ -183,7 +191,8 @@ def line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, **kwarg
**kwargs,
)

ax.clabel(contours, contours.levels, inline=True, fontsize=10, colors="black")
if label_contours:
ax.clabel(contours, contours.levels, inline=True, fontsize=10, colors="black")

# Make equal axis
ax.set_aspect("equal")
Expand All @@ -199,6 +208,7 @@ def visualize_cut_plane(
levels=None,
clevels=None,
color_bar=False,
label_contours=False,
title="",
**kwargs
):
Expand All @@ -224,6 +234,8 @@ def visualize_cut_plane(
Defaults to None.
color_bar (Boolean, optional): Flag to include a color bar on the plot.
Defaults to False.
label_contours (Boolean, optional): Flag to include a numerical contour labels
on the plot. Defaults to False.
title (str, optional): User-supplied title for the plot. Defaults to "".
**kwargs: Additional parameters to pass to line contour plot.
Expand Down Expand Up @@ -275,6 +287,7 @@ def visualize_cut_plane(
ax=ax,
levels=levels,
colors="b",
label_contours=label_contours,
linewidths=0.8,
alpha=0.3,
**kwargs
Expand Down Expand Up @@ -307,6 +320,7 @@ def visualize_heterogeneous_cut_plane(
levels=None,
clevels=None,
color_bar=False,
label_contours=False,
title="",
plot_het_bounds=True,
**kwargs
Expand Down Expand Up @@ -334,6 +348,8 @@ def visualize_heterogeneous_cut_plane(
Defaults to None.
color_bar (Boolean, optional): Flag to include a color bar on the plot.
Defaults to False.
label_contours (Boolean, optional): Flag to include a numerical contour labels
on the plot. Defaults to False.
title (str, optional): User-supplied title for the plot. Defaults to "".
plot_het_bonds (boolean, optional): Flag to include the user-defined bounds of the
heterogeneous wind speed area. Defaults to True.
Expand Down Expand Up @@ -386,6 +402,7 @@ def visualize_heterogeneous_cut_plane(
ax=ax,
levels=levels,
colors="b",
label_contours=label_contours,
linewidths=0.8,
alpha=0.3,
**kwargs
Expand Down

0 comments on commit ed3d30f

Please sign in to comment.