-
Notifications
You must be signed in to change notification settings - Fork 181
Add test of nans in inputs to wind data objects #1007
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
base: develop
Are you sure you want to change the base?
Conversation
|
Small test script: import numpy as np
from floris import WindRose
wind_directions = np.array([0.0, 90.0, 180.0, 270.0])
wind_speeds = np.array([5.0, 10.0, 15.0])
print("Instantiating without NaNs")
WindRose(wind_directions, wind_speeds, ti_table=0.06)
# Introduce NaN values
wind_directions[1] = np.nan
print("Instantiating with NaNs")
WindRose(wind_directions, wind_speeds, ti_table=0.06)On the develop branch, the following printout is generated With the change, this is updated to |
|
Playing around with this a bit more, I notice that passing wind condition inputs to For example, import numpy as np
from floris import WindRose, FlorisModel
wind_directions = np.array([0.0, 90.0, 180.0, 270.0])
wind_speeds = np.array([8.0, 8.0, 8.0, 8.0])
# Introduce NaN values
wind_directions[1] = np.nan
print("Setting FlorisModel with NaNs")
fmodel = FlorisModel(configuration="defaults")
fmodel.set(layout_x=[0,500], layout_y=[0,0])
fmodel.set(
wind_directions=wind_directions,
wind_speeds=wind_speeds,
turbulence_intensities=0.06*np.ones_like(wind_directions)
)
print(fmodel.core.flow_field.wind_directions)
fmodel.run()
print("Powers:", fmodel.get_farm_power())
print("AEP:", fmodel.get_farm_AEP())
print("AEP from powers:", np.nansum(fmodel.get_farm_power())*365*24 / fmodel.n_findex)produces In particular, note that
All of this is to respond to a previous discussion about whether |
tests/wind_data_integration_test.py
Outdated
| np.testing.assert_allclose(wind_ti_rose.turbulence_intensities, expected_result) | ||
|
|
||
|
|
||
| def test_wind_rose_nan_values(): |
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.
These tests don't seem to actually test the desired behavior. They pass on both the develop branch (without the new NaN check) and with the new code, because in both cases, a ValueError is raised.
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've now fixed this by adding a match kwarg to pytest.raises()
|
@paulf81 I've cleaned this up a bit. However, there are some tests now failing because there is not a NaN check in the Note that the test for |
|
Conversation on this topic moved to #1076, and (although I let it drop for a while), hopefully we are close to a resolution there. |
Add tests of nans in inputs to wind data objects
Working with flasc, it's possible to generate data series where wind_directions or wind_speeds contain NaN values, in flasc this typically signifies missing or faulty data. However within the WindData objects in FLORIS, the presense of NaNs in certain inputs can yield ambiguous errors. Further, since inputs like wind_directions and wind_speeds within WindData objects will be used to drive
FlorisModelsimulations, containing NaN values will further generate additional errors at that point.This pull request adds a check at inputs to of WindData objects that input arrays
wind_directions,wind_speeds,turbulence_intensitiesandvaluesdo not contain NaN values. Some additional tests are added to confirm correct behavior.