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

Adds classes to structure wind energy data for FLORIS #775

Merged
merged 50 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5b6abad
move files around to get started
paulf81 Jan 11, 2024
b515274
move files around to get started
paulf81 Jan 11, 2024
f595720
ignore unused in __init__ files
paulf81 Jan 11, 2024
2096d9c
Consolidate wind rose and time series into one module
paulf81 Jan 12, 2024
9f94b01
Update init
paulf81 Jan 12, 2024
a9bb92c
Update tests
paulf81 Jan 12, 2024
f70c411
Add unpack functions
paulf81 Jan 12, 2024
1fbb6b5
Add grid and unpack tests
paulf81 Jan 12, 2024
1c54853
Small refactor
paulf81 Jan 12, 2024
96b477b
Add resample function
paulf81 Jan 12, 2024
d9be4ac
Test resample
paulf81 Jan 12, 2024
bd0e7f3
Add plot wind rose function
paulf81 Jan 13, 2024
c76f479
Add new wind rose usage example
paulf81 Jan 13, 2024
18a4884
Delete old code
paulf81 Jan 13, 2024
cb3a7e1
add super class to import
paulf81 Jan 13, 2024
8685b5f
Add a super class and inheritance
paulf81 Jan 13, 2024
d087abd
Add wind_data to reinitialize (also ruffing)
paulf81 Jan 13, 2024
c75c23c
Show example of reinit off wind_data objects
paulf81 Jan 13, 2024
d419e0d
Update how compute 0 freq works
paulf81 Jan 16, 2024
f6df165
Test computing all cases
paulf81 Jan 16, 2024
c819fe4
add n_findex calculation and test
paulf81 Jan 16, 2024
09bf38c
Add unpack_freq function
paulf81 Jan 16, 2024
feb0163
Get aep using wind data
paulf81 Jan 16, 2024
dc8bc80
Move unpack_for functions to super class
paulf81 Jan 16, 2024
48730a9
simplify get_farm_AEP_with_wind_data
paulf81 Jan 16, 2024
4bcea14
Add docstrings
paulf81 Jan 17, 2024
793d50a
bugfix
paulf81 Jan 17, 2024
b56a096
Finalize example
paulf81 Jan 17, 2024
6f236f4
Merge branch 'v4' into wind_rose_refactor
paulf81 Jan 17, 2024
81e00ee
Rename module file and base class
paulf81 Jan 17, 2024
6469362
Add description to example explaining plan for updates.
misi9170 Jan 17, 2024
ccdf2c5
providing unpack() on base class; renaming example.
misi9170 Jan 18, 2024
df86945
Inheritance clarified; some cleanup.
misi9170 Jan 18, 2024
2f2b15d
Remove copy()s (can point to same memory).
misi9170 Jan 18, 2024
19b647e
Small fixes throughout.
misi9170 Jan 18, 2024
efd3a95
Python back compatibility type-hinting issue.
misi9170 Jan 18, 2024
0445472
Maintain consistent formatting
rafmudaf Jan 18, 2024
8493b59
Spell check
rafmudaf Jan 18, 2024
27a131c
Remove outdated comments
rafmudaf Jan 18, 2024
a6dc079
Expand docs for wind data unit tests
rafmudaf Jan 18, 2024
2e765b1
Add dimensions to doc string
paulf81 Jan 18, 2024
41af717
Add context to to_wind_rose test comments
paulf81 Jan 18, 2024
1d07c57
Add error to reinitialize
paulf81 Jan 18, 2024
2053c63
Explain what happens in default cases for WindRose
paulf81 Jan 20, 2024
126f4ad
Rename price to value
paulf81 Jan 20, 2024
4dba98d
Add check on ti and value
paulf81 Jan 20, 2024
6049894
Fix bin minimum
paulf81 Jan 20, 2024
04d4862
remove wind data import
paulf81 Jan 24, 2024
caa8d42
Import WindDataBase correctly
paulf81 Jan 24, 2024
b7dd720
Spell check and formatting
rafmudaf Jan 25, 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
84 changes: 84 additions & 0 deletions examples/34_wind_data_temporary.py
rafmudaf marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2024 NREL

# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# See https://floris.readthedocs.io for documentation

import matplotlib.pyplot as plt
import numpy as np

from floris.tools import (
FlorisInterface,
TimeSeries,
WindRose,
)
from floris.utilities import wrap_360


"""
This example is meant to be temporary and may be updated by a later pull request. Before we
release v4, we intend to propagate the TimeSeries and WindRose objects through the other relevant
examples, and change this example to demonstrate more advanced (as yet, not implemented)
functionality of the WindData objects (such as electricity pricing etc).
"""


# Generate a random time series of wind speeds, wind directions and turbulence intensities
N = 500
wd_array = wrap_360(270 * np.ones(N) + np.random.randn(N) * 20)
ws_array = np.clip(8 * np.ones(N) + np.random.randn(N) * 8, 3, 50)
ti_array = np.clip(0.1 * np.ones(N) + np.random.randn(N) * 0.05, 0, 0.25)

fig, axarr = plt.subplots(3, 1, sharex=True, figsize=(7, 4))
ax = axarr[0]
ax.plot(wd_array, marker=".", ls="None")
ax.set_ylabel("Wind Direction")
ax = axarr[1]
ax.plot(ws_array, marker=".", ls="None")
ax.set_ylabel("Wind Speed")
ax = axarr[2]
ax.plot(ti_array, marker=".", ls="None")
ax.set_ylabel("Turbulence Intensity")


# Build the time series
time_series = TimeSeries(wd_array, ws_array) # , turbulence_intensity=ti_array)

# Now build the wind rose
wind_rose = time_series.to_wind_rose()

# Plot the wind rose
fig, ax = plt.subplots(subplot_kw={"polar": True})
wind_rose.plot_wind_rose(ax=ax)

# Now set up a FLORIS model and initialize it using the time series and wind rose
fi = FlorisInterface("inputs/gch.yaml")
fi.reinitialize(layout_x=[0, 500.0], layout_y=[0.0, 0.0])

fi_time_series = fi.copy()
fi_wind_rose = fi.copy()

fi_time_series.reinitialize(wind_data=time_series)
fi_wind_rose.reinitialize(wind_data=wind_rose)

fi_time_series.calculate_wake()
fi_wind_rose.calculate_wake()

time_series_power = fi_time_series.get_farm_power()
wind_rose_power = fi_wind_rose.get_farm_power()

time_series_aep = fi_time_series.get_farm_AEP_with_wind_data(time_series)
wind_rose_aep = fi_wind_rose.get_farm_AEP_with_wind_data(wind_rose)

print(f"AEP from TimeSeries {time_series_aep / 1e9:.2f} GWh")
print(f"AEP from WindRose {wind_rose_aep / 1e9:.2f} GWh")

plt.show()
26 changes: 15 additions & 11 deletions floris/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,22 @@
visualize_cut_plane,
visualize_quiver,
)
from .wind_rose import WindRose
from .wind_data import (
TimeSeries,
WindDataBase,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think users will be using this base-class, they'll probably only use the derived classes. So we can remove WindDataBase from the user-facing imports.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

WindRose,
)


# from floris.tools import (
# cut_plane,
# floris_interface,
# interface_utilities,
# layout_functions,
# optimization,
# plotting,
# power_rose,
# rews,
# visualization,
# wind_rose,
# cut_plane,
# floris_interface,
# interface_utilities,
# layout_functions,
# optimization,
# plotting,
# power_rose,
# rews,
# visualization,
# wind_rose,
# )
Loading