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

Collect all layout visualization tools in FLORIS #805

Merged
merged 36 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5c06bc5
Delete redundant functions
paulf81 Feb 15, 2024
a720f9c
Add get_wake_direction
paulf81 Feb 15, 2024
7d0ef07
Add initial test
paulf81 Feb 15, 2024
480e85e
New example
paulf81 Feb 15, 2024
ec1d184
Update init
paulf81 Feb 15, 2024
03e15b6
Redo layout functions
paulf81 Feb 15, 2024
164066d
Update visualization
paulf81 Feb 15, 2024
2bc4d07
Clean up layout functions further
paulf81 Feb 19, 2024
f00af7d
Clean up example
paulf81 Feb 19, 2024
d9ea003
Make bbox dict work more like other dicts
paulf81 Feb 19, 2024
3dd3b0d
isort
paulf81 Feb 19, 2024
4d2f5d4
Linting
paulf81 Feb 19, 2024
21b7048
Merge branch 'v4' into feature/all_layout_vis_in_floris
paulf81 Feb 20, 2024
7d56241
Improve docstrings
paulf81 Feb 20, 2024
b158f63
Add tests of plots
paulf81 Feb 20, 2024
19f3dd3
remove ref to show_plots
paulf81 Feb 20, 2024
da9c263
Update example 3 to new layout tools
paulf81 Feb 20, 2024
a08259e
Remove old example 23
paulf81 Feb 20, 2024
20a78d4
Remove un-need import
paulf81 Feb 20, 2024
984b48a
Standardize on lf import
paulf81 Feb 23, 2024
839ab72
Merge branch 'v4' into pr/paulf81/805
rafmudaf Feb 23, 2024
f2504e8
Remove old Apache license
rafmudaf Feb 23, 2024
9ae45d1
Remove commented code
paulf81 Mar 1, 2024
57f874e
Respond to comments
paulf81 Mar 1, 2024
65c9aaa
Merge branch 'v4' into feature/all_layout_vis_in_floris
paulf81 Mar 1, 2024
4658a13
reinitialize -> set
misi9170 Mar 3, 2024
438c050
Bugfix: correct error raised when fi.reinitialize() called.
misi9170 Mar 3, 2024
2a18f20
Remove need for fig argument; demonstrate use of plot_farm_terrain.
misi9170 Mar 3, 2024
041f62c
rename vis and layout functions
paulf81 Mar 4, 2024
76f53eb
Fix spelling
paulf81 Mar 4, 2024
dfb319a
Add show function
paulf81 Mar 4, 2024
75ac7c1
Convert lf to layoutviz
paulf81 Mar 4, 2024
52bde15
wakeviz->flowviz
paulf81 Mar 4, 2024
8509d27
Rename function for consistency
rafmudaf Mar 5, 2024
e90bc5a
Give farm terrain function no axis option
paulf81 Mar 6, 2024
c5b3776
Add test of farm terrain
paulf81 Mar 6, 2024
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
4 changes: 2 additions & 2 deletions examples/02_visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt
import numpy as np

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as wakeviz
from floris.tools import FlorisInterface


Expand Down Expand Up @@ -141,4 +141,4 @@
)
fig.suptitle("Rotor Plane Visualization, 10x10 Resolution")

wakeviz.show_plots()
plt.show()
11 changes: 6 additions & 5 deletions examples/03_making_adjustments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import matplotlib.pyplot as plt
import numpy as np

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as wakeviz
import floris.tools.layout_visualization as lf
rafmudaf marked this conversation as resolved.
Show resolved Hide resolved
from floris.tools import FlorisInterface


Expand Down Expand Up @@ -70,8 +71,8 @@
min_speed=MIN_WS,
max_speed=MAX_WS
)
wakeviz.add_turbine_id_labels(fi, axarr[3], color="w", backgroundcolor="k")
wakeviz.plot_turbines_with_fi(fi, axarr[3])
lf.plot_turbine_labels(fi, axarr[3],plotting_dict={'color':"w"})#, backgroundcolor="k")
lf.plot_turbines_rotors(fi, axarr[3])

# Change the yaw angles and configure the plot differently
yaw_angles = np.zeros((1, N * N))
Expand All @@ -95,7 +96,7 @@
min_speed=MIN_WS,
max_speed=MAX_WS
)
wakeviz.plot_turbines_with_fi(fi, axarr[4], yaw_angles=yaw_angles, color="c")
lf.plot_turbines_rotors(fi, axarr[4], yaw_angles=yaw_angles, color="c")


# Plot the cross-plane of the 3x3 configuration
Expand All @@ -110,4 +111,4 @@
axarr[5].invert_xaxis()


wakeviz.show_plots()
plt.show()
2 changes: 1 addition & 1 deletion examples/16_heterogeneous_inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/16b_heterogeneity_multiple_ws_wd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
4 changes: 2 additions & 2 deletions examples/17_multiple_turbine_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import matplotlib.pyplot as plt

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as wakeviz
from floris.tools import FlorisInterface


Expand All @@ -28,4 +28,4 @@
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.show_plots()
plt.show()
93 changes: 93 additions & 0 deletions examples/23_layout_visualizations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

import matplotlib.pyplot as plt
import numpy as np

import floris.tools.layout_visualization as lf
from floris.tools import FlorisInterface
from floris.tools.flow_visualization import visualize_cut_plane


"""
This example shows a number of different ways to visualize a farm layout using FLORIS
"""

# Create the plotting objects using matplotlib
fig, axarr = plt.subplots(3, 3, figsize=(16, 10), sharex=False)
axarr = axarr.flatten()

MIN_WS = 1.0
MAX_WS = 8.0

# Initialize FLORIS with the given input file via FlorisInterface
fi = FlorisInterface("inputs/gch.yaml")

# Change to 5-turbine layout with a wind direction from northwest
fi.set(
layout_x=[0, 0, 1000, 1000, 1000], layout_y=[0, 500, 0, 500, 1000], wind_directions=[300]
)

# Plot 1: Visualize the flow
ax = axarr[0]
# Plot a horizatonal slice of the initial configuration
horizontal_plane = fi.calculate_horizontal_plane(height=90.0)
visualize_cut_plane(
horizontal_plane,
ax=ax,
min_speed=MIN_WS,
max_speed=MAX_WS,
)
# Plot the turbine points, setting the color to white
lf.plot_turbine_points(fi, ax=ax, plotting_dict={"color": "w"})
ax.set_title('Flow visualization and turbine points')

# Plot 2: Show a particular flow case
ax = axarr[1]
turbine_names = [f"T{i}" for i in [10, 11, 12, 13, 22]]
lf.plot_turbine_points(fi, ax=ax)
lf.plot_turbine_labels(fi,
ax=ax,
turbine_names=turbine_names,
show_bbox=True,
bbox_dict={'facecolor':'r'})
ax.set_title("Show turbine names with a red bounding box")


# Plot 2: Show turbine rotors on flow
ax = axarr[2]
horizontal_plane = fi.calculate_horizontal_plane(height=90.0,
yaw_angles=np.array([[0., 30., 0., 0., 0.]]))
visualize_cut_plane(
horizontal_plane,
ax=ax,
min_speed=MIN_WS,
max_speed=MAX_WS
)
lf.plot_turbines_rotors(fi,ax=ax,yaw_angles=np.array([[0., 30., 0., 0., 0.]]))
ax.set_title("Flow visualization with yawed turbine")

# Plot 3: Show the layout, including wake directions
ax = axarr[3]
lf.plot_turbine_points(fi, ax=ax)
lf.plot_turbine_labels(fi, ax=ax, turbine_names=turbine_names)
lf.plot_waking_directions(fi, ax=ax)
ax.set_title("Show turbine names and wake direction")

# Plot 4: Plot a subset of the layout, and limit directions less than 7D
ax = axarr[4]
lf.plot_turbine_points(fi, ax=ax, turbine_indices=[0,1,2,3])
lf.plot_turbine_labels(fi, ax=ax, turbine_names=turbine_names, turbine_indices=[0,1,2,3])
lf.plot_waking_directions(fi, ax=ax, turbine_indices=[0,1,2,3], limit_dist_D=7)
ax.set_title("Plot a subset and limit wake line distance")

# Plot with a shaded region
ax = axarr[5]
lf.plot_turbine_points(fi, ax=ax)
lf.shade_region(np.array([[0,0],[300,0],[300,1000],[0,700]]),ax=ax)
ax.set_title("Plot with a shaded region")

# Change hub heights and plot as a proxy for terrain
ax = axarr[6]
fi.floris.farm.hub_heights = np.array([110, 90, 100, 100, 95])
lf.plot_farm_terrain(fi, ax=ax)

plt.show()
62 changes: 0 additions & 62 deletions examples/23_visualize_layout.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/24_floating_turbine_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.layout_functions import visualize_layout


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/25_tilt_driven_vertical_wake_deflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import visualize_cut_plane
from floris.tools.flow_visualization import visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/26_empirical_gauss_velocity_deficit_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import plot_rotor_values, visualize_cut_plane
from floris.tools.flow_visualization import plot_rotor_values, visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/27_empirical_gauss_deflection_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from floris.tools import FlorisInterface
from floris.tools.visualization import plot_rotor_values, visualize_cut_plane
from floris.tools.flow_visualization import plot_rotor_values, visualize_cut_plane


"""
Expand Down
2 changes: 1 addition & 1 deletion examples/29_floating_vs_fixedbottom_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from scipy.interpolate import NearestNDInterpolator

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as wakeviz
from floris.tools import FlorisInterface


Expand Down
4 changes: 2 additions & 2 deletions examples/32_plot_velocity_deficit_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import numpy as np
from matplotlib import ticker

import floris.tools.visualization as wakeviz
import floris.tools.flow_visualization as wakeviz
from floris.tools import cut_plane, FlorisInterface
from floris.tools.visualization import VelocityProfilesFigure
from floris.tools.flow_visualization import VelocityProfilesFigure
from floris.utilities import reverse_rotate_coordinates_rel_west


Expand Down
11 changes: 5 additions & 6 deletions floris/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__', 'cut_plane',
'floris_interface',
'layout_functions', 'optimization', 'plotting', 'power_rose',
'layout_visualization', 'optimization', 'plotting', 'power_rose',
'visualization']
"""

from .floris_interface import FlorisInterface
from .parallel_computing_interface import ParallelComputingInterface
from .uncertainty_interface import UncertaintyInterface
from .visualization import (
from .flow_visualization import (
plot_rotor_values,
plot_turbines_with_fi,
visualize_cut_plane,
visualize_quiver,
)
from .parallel_computing_interface import ParallelComputingInterface
from .uncertainty_interface import UncertaintyInterface
from .wind_data import (
TimeSeries,
WindRose,
Expand All @@ -42,7 +41,7 @@
# cut_plane,
# floris_interface,
# interface_utilities,
# layout_functions,
# layout_visualization,
# optimization,
# plotting,
# power_rose,
Expand Down
4 changes: 2 additions & 2 deletions floris/tools/floris_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,13 +1279,13 @@ def get_turbine_layout(self, z=False):

### v3 functions that are removed - raise an error if used

def calculate_wake(self):
def calculate_wake(self, **_):
raise NotImplementedError(
"The calculate_wake method has been removed. Please use the run method. "
"See https://nrel.github.io/floris/upgrade_guides/v3_to_v4.html for more information."
)

def reinitialize(self):
def reinitialize(self, **_):
raise NotImplementedError(
"The reinitialize method has been removed. Please use the set method. "
"See https://nrel.github.io/floris/upgrade_guides/v3_to_v4.html for more information."
Expand Down
Loading
Loading