floris.flow_visualization#

Functions

calculate_horizontal_plane_with_turbines(fmodel)

This function creates a CutPlane by adding an additional turbine to the farm and moving it through every a regular grid throughout the flow field.

line_contour_cut_plane(cut_plane[, ax, ...])

Visualize a cut_plane as a line contour plot.

plot_rotor_values(values, findex, n_rows, n_cols)

Plots the gridded turbine rotor values.

reverse_cut_plane_x_axis_in_plot(ax)

Shortcut method to reverse direction of x-axis.

show()

Display all open figures.

visualize_cut_plane(cut_plane[, ax, ...])

Generate pseudocolor mesh plot of the cut_plane.

visualize_heterogeneous_cut_plane(cut_plane, ...)

Generate pseudocolor mesh plot of the heterogeneous cut_plane.

visualize_quiver(cut_plane[, ax, min_speed, ...])

Visualize the in-plane flows in a cut_plane using quiver.

Classes

VelocityProfilesFigure(downstream_dists_D[, ...])

Create a figure which displays velocity deficit profiles at several downstream locations of a turbine.

floris.flow_visualization.show()[source]#

Display all open figures. This is a wrapper for plt.show(). This function is useful if the user doesn't wish to import matplotlib.pyplot

floris.flow_visualization.line_contour_cut_plane(cut_plane, ax=None, levels=None, colors=None, label_contours=False, **kwargs)[source]#

Visualize a cut_plane as a line contour plot.

Args:
cut_plane (CutPlane):

CutPlane Object.

ax (matplotlib.pyplot.axes): Figure axes. Defaults

to None.

levels (np.array, optional): Contour levels for plot.

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.

floris.flow_visualization.visualize_cut_plane(cut_plane, ax=None, vel_component='u', min_speed=None, max_speed=None, cmap='coolwarm', levels=None, clevels=None, color_bar=False, label_contours=False, title='', **kwargs)[source]#

Generate pseudocolor mesh plot of the cut_plane.

Args:
cut_plane (CutPlane): 2D

plane through wind plant.

ax (matplotlib.pyplot.axes, optional): Figure axes. Defaults

to None.

vel_component (str, optional): The velocity component that the cut plane is

perpendicular to.

min_speed (float, optional): Minimum value of wind speed for

contours. Defaults to None.

max_speed (float, optional): Maximum value of wind speed for

contours. Defaults to None.

cmap (str, optional): Colormap specifier. Defaults to

'coolwarm'.

levels (np.array, optional): Contour levels for line contour plot.

Defaults to None.

clevels (np.array, optional): Contour levels for tricontourf plot.

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.

Returns:

im (matplotlib.plt.pcolormesh): Image handle.

floris.flow_visualization.visualize_heterogeneous_cut_plane(cut_plane, fmodel, ax=None, vel_component='u', min_speed=None, max_speed=None, cmap='coolwarm', levels=None, clevels=None, color_bar=False, label_contours=False, title='', plot_het_bounds=True, **kwargs)[source]#

Generate pseudocolor mesh plot of the heterogeneous cut_plane.

Args:
cut_plane (CutPlane): 2D

plane through wind plant.

fmodel (FlorisModel): FlorisModel object. ax (matplotlib.pyplot.axes): Figure axes. Defaults

to None.

vel_component (str, optional): The velocity component that the cut plane is

perpendicular to.

min_speed (float, optional): Minimum value of wind speed for

contours. Defaults to None.

max_speed (float, optional): Maximum value of wind speed for

contours. Defaults to None.

cmap (str, optional): Colormap specifier. Defaults to

'coolwarm'.

levels (np.array, optional): Contour levels for line contour plot.

Defaults to None.

clevels (np.array, optional): Contour levels for tricontourf plot.

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.

**kwargs: Additional parameters to pass to line contour plot.

Returns:

im (matplotlib.plt.pcolormesh): Image handle.

floris.flow_visualization.visualize_quiver(cut_plane, ax=None, min_speed=None, max_speed=None, downSamp=1, **kwargs)[source]#

Visualize the in-plane flows in a cut_plane using quiver.

Args:
cut_plane (CutPlane): 2D

plane through wind plant.

ax (matplotlib.pyplot.axes): Figure axes. Defaults

to None.

min_speed (float, optional): Minimum value of wind speed for

contours. Defaults to None.

max_speed (float, optional): Maximum value of wind speed for

contours. Defaults to None.

downSamp (int, optional): Down sample the number of quiver arrows

from underlying grid.

**kwargs: Additional parameters to pass to ax.streamplot.

Returns:

im (matplotlib.plt.pcolormesh): Image handle.

floris.flow_visualization.reverse_cut_plane_x_axis_in_plot(ax)[source]#

Shortcut method to reverse direction of x-axis.

Args:

ax (matplotlib.pyplot.axes): Figure axes.

floris.flow_visualization.plot_rotor_values(values, findex, n_rows, n_cols, t_range=None, cmap='coolwarm', return_fig_objects=False, save_path=None, show=False)[source]#

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.

Return type:

Optional[tuple[figure, axes, axis, colorbar]]

Parameters:
  • values (ndarray) --

  • findex (int) --

  • n_rows (int) --

  • n_cols (int) --

  • t_range (range | None) --

  • cmap (str) --

  • return_fig_objects (bool) --

  • save_path (str | None) --

  • show (bool) --

Parameters:
values (np.ndarray): The 4-dimensional array of values to plot. Should be:

(N findex, N turbines, N rotor points, N rotor points).

findex (int): The index for the sample point to plot. n_rows (int): The number of rows to include for subplots. With ncols, this should

generally add up to the number of turbines in the farm.

n_cols (int): The number of columns to include for subplots. With ncols, this should

generally add up to the number of turbines in the farm.

t_range (range | None): Optional. The turbine count used to create the title for each

subplot. If not provided, the size of the 2-th dimension of values is used.

cmap (str): Optional. The matplotlib colormap to be used, default "coolwarm". return_fig_objects (bool): Optional. Flag to return the primary figure objects for

further editing, default False.

save_path (str | None): Optional. Where to save the figure, if a value is provided. show (bool): Optional. Flag to run plt.show() to present all the plots

currently created with matplotlib.

Returns:

None | tuple[plt.figure, plt.axes, plt.axis, plt.colorbar]: If return_fig_objects is False, then `None is returned`, otherwise the primary figure objects are returned for custom editing.

Example:

from floris.visualization import plot_rotor_values plot_rotor_values(floris.flow_field.u, findex=0, n_rows=1, ncols=4) plot_rotor_values(floris.flow_field.v, findex=0, n_rows=1, ncols=4) plot_rotor_values(floris.flow_field.w, findex=0, n_rows=1, ncols=4, show=True)

floris.flow_visualization.calculate_horizontal_plane_with_turbines(fmodel, x_resolution=200, y_resolution=200, x_bounds=None, y_bounds=None, findex_for_viz=None)[source]#

This function creates a CutPlane by adding an additional turbine to the farm and moving it through every a regular grid throughout the flow field. This method allows for visualizing wake models that do not support the FullFlowGrid and its associated solver. As the new turbine is moved around the flow field, the velocities at its rotor are stored in local variables, and the flow field is reset to its initial state for every new location. Then, the local velocities are put into a DataFrame and then into a CutPlane. This method is much slower than FlorisModel.calculate_horizontal_plane, but it is helpful for models where the visualization capability is not yet available.

Return type:

CutPlane

Args:
fmodel (floris.floris_model.FlorisModel):

Preinitialized FlorisModel object.

x_resolution (float, optional): Output array resolution. Defaults to 200 points. y_resolution (float, optional): Output array resolution. Defaults to 200 points. x_bounds (tuple, optional): Limits of output array (in m). Defaults to None. y_bounds (tuple, optional): Limits of output array (in m). Defaults to None. findex_for_viz (int, optional): Index of the condition to visualize.

Returns:

CutPlane: containing values of x, y, u, v, w

class floris.flow_visualization.VelocityProfilesFigure(downstream_dists_D, layout=['cross-stream'], ax_width=2.07, ax_height=3.0, coordinate_labels=['x_1/D', 'x_2/D', 'x_3/D'])[source]#

Create a figure which displays velocity deficit profiles at several downstream locations of a turbine.

Args:
downstream_dists_D: A list/array of streamwise locations at which the velocity deficit

profiles have been sampled. The locations should be normalized by the turbine diameter D.

layout: A one- or two-element list defining the direction of the profiles and in which

order the directions are plotted. For example, ['cross-stream', 'vertical'] initializes a figure where cross-stream profiles are expected on the top row of Axes in the figure, and vertical profiles are expected on the bottom row.

ax_width: Roughly the width of each Axes. ax_height: Roughly the height of each Axes. coordinate_labels: A list of labels for the normalized coordinates.

Parameters:
  • downstream_dists_D (ndarray[Any, dtype[float64]]) --

  • layout (list[str]) --

  • ax_width (float) --

  • ax_height (float) --

  • coordinate_labels (list[str]) --

downstream_dists_D: ndarray[Any, dtype[float64]]#
layout: list[str]#
ax_width: float#
ax_height: float#
coordinate_labels: list[str]#
n_rows: int#
n_cols: int#
fig: Figure#
axs: ndarray#
deficit_max: float#
layout_validator(instance, value)[source]#
Return type:

None

Parameters:
  • instance (Attribute) --

  • value (list[str]) --

add_profiles(velocity_deficit_profiles, **kwargs)[source]#

Add a list of velocity deficit profiles to the figure. Each profile is represented as a pandas DataFrame. kwargs are passed to ax.plot.

Return type:

None

Parameters:

velocity_deficit_profiles (list[DataFrame]) --

match_profile_to_axes(df)[source]#
Return type:

tuple[Axes, str]

Parameters:

df (DataFrame) --

set_xlim(xlim)[source]#
Return type:

None

Parameters:

xlim (list[float] | ndarray[Any, dtype[float64]]) --

add_ref_lines_x2(ref_lines_x2_D, **kwargs)[source]#

Add reference lines to the VelocityProfilesFigure which go along the XAxis. :rtype: None

Commonly used to show the extent of the turbine. Args:

ref_lines_x2_D: A list of x2-coordinates normalized by the turbine diameter D.

One coordinate per reference line.

**kwargs: Additional parameters to pass to ax.plot.

Parameters:

ref_lines_x2_D (list[float] | ndarray[Any, dtype[float64]]) --

Return type:

None

add_ref_lines_x3(ref_lines_x3_D, **kwargs)[source]#

Add reference lines to the VelocityProfilesFigure which go along the XAxis. :rtype: None

Commonly used to show the extent of the turbine. Args:

ref_lines_x3_D: A list of x3-coordinates normalized by the turbine diameter D.

One coordinate per reference line.

**kwargs: Additional parameters to pass to ax.plot.

Parameters:

ref_lines_x3_D (list[float] | ndarray[Any, dtype[float64]]) --

Return type:

None

add_ref_lines(ref_lines_D, row, **kwargs)[source]#
Return type:

None

Parameters:
  • ref_lines_D (list[float] | ndarray[Any, dtype[float64]]) --

  • row (int) --