-
Notifications
You must be signed in to change notification settings - Fork 157
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
Changes from 36 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
5b6abad
move files around to get started
paulf81 b515274
move files around to get started
paulf81 f595720
ignore unused in __init__ files
paulf81 2096d9c
Consolidate wind rose and time series into one module
paulf81 9f94b01
Update init
paulf81 a9bb92c
Update tests
paulf81 f70c411
Add unpack functions
paulf81 1fbb6b5
Add grid and unpack tests
paulf81 1c54853
Small refactor
paulf81 96b477b
Add resample function
paulf81 d9be4ac
Test resample
paulf81 bd0e7f3
Add plot wind rose function
paulf81 c76f479
Add new wind rose usage example
paulf81 18a4884
Delete old code
paulf81 cb3a7e1
add super class to import
paulf81 8685b5f
Add a super class and inheritance
paulf81 d087abd
Add wind_data to reinitialize (also ruffing)
paulf81 c75c23c
Show example of reinit off wind_data objects
paulf81 d419e0d
Update how compute 0 freq works
paulf81 f6df165
Test computing all cases
paulf81 c819fe4
add n_findex calculation and test
paulf81 09bf38c
Add unpack_freq function
paulf81 feb0163
Get aep using wind data
paulf81 dc8bc80
Move unpack_for functions to super class
paulf81 48730a9
simplify get_farm_AEP_with_wind_data
paulf81 4bcea14
Add docstrings
paulf81 793d50a
bugfix
paulf81 b56a096
Finalize example
paulf81 6f236f4
Merge branch 'v4' into wind_rose_refactor
paulf81 81e00ee
Rename module file and base class
paulf81 6469362
Add description to example explaining plan for updates.
misi9170 ccdf2c5
providing unpack() on base class; renaming example.
misi9170 df86945
Inheritance clarified; some cleanup.
misi9170 2f2b15d
Remove copy()s (can point to same memory).
misi9170 19b647e
Small fixes throughout.
misi9170 efd3a95
Python back compatibility type-hinting issue.
misi9170 0445472
Maintain consistent formatting
rafmudaf 8493b59
Spell check
rafmudaf 27a131c
Remove outdated comments
rafmudaf a6dc079
Expand docs for wind data unit tests
rafmudaf 2e765b1
Add dimensions to doc string
paulf81 41af717
Add context to to_wind_rose test comments
paulf81 1d07c57
Add error to reinitialize
paulf81 2053c63
Explain what happens in default cases for WindRose
paulf81 126f4ad
Rename price to value
paulf81 4dba98d
Add check on ti and value
paulf81 6049894
Fix bin minimum
paulf81 04d4862
remove wind data import
paulf81 caa8d42
Import WindDataBase correctly
paulf81 b7dd720
Spell check and formatting
rafmudaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!