From 89543b5830767b9ce4a14f2c09d4dd4d8e402a86 Mon Sep 17 00:00:00 2001 From: misi9170 Date: Fri, 20 Oct 2023 11:11:13 -0600 Subject: [PATCH] Infrastructure added for optional contours. Defaults to not plotting. --- floris/tools/visualization.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/floris/tools/visualization.py b/floris/tools/visualization.py index 18efebdc6..aa4d83734 100644 --- a/floris/tools/visualization.py +++ b/floris/tools/visualization.py @@ -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. @@ -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`. """ @@ -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") @@ -199,6 +208,7 @@ def visualize_cut_plane( levels=None, clevels=None, color_bar=False, + label_contours=False, title="", **kwargs ): @@ -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. @@ -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 @@ -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 @@ -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. @@ -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