-
Notifications
You must be signed in to change notification settings - Fork 156
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
Improvements to WindRose resampling #857
Improvements to WindRose resampling #857
Conversation
@misi9170 and @Bartdoekemeijer (and @ejsimley if you time?) could you check quick what you think of the commit I just pushed up to address the point above on enhanced resampling for upsampling? You'll see I made the following changes:
I'll need to next follow-through on the code if you like it in principle, or can change things. But next steps will be:
|
floris/wind_data.py
Outdated
if ws_step is not None: | ||
if len(self.wind_speeds) >= 2: | ||
if ws_step < self.wind_speeds[1] - self.wind_speeds[0]: | ||
raise ValueError("ws_step must be at least as large as the current step") |
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.
@paulf81 maybe here, we should print what the current step is, which might help them set it correctly?
something like:
current_ws_step = self.wind_speeds[1] - self.wind_speeds[0]
if ws_step < current_ws_step:
raise ValueError("ws_step provided must be at least as large as the current ws_step ({0:.2f} m/s)".format(current_ws_step)
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.
Sounds good, making the change...
floris/wind_data.py
Outdated
elif method == "nearest": | ||
interpolator = NearestNDInterpolator | ||
else: | ||
UserWarning("Unknown interpolation method: '{:s}'".format(method)) |
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.
UserWarning("Unknown interpolation method: '{:s}'. Available methods are 'linear' and 'nearest'".format(method))
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.
fixed as well
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.
Actually what is a "UserWarning"? does it cause an error? If not, what happens next?
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.
Oof, this should be a ValueError, switching
@paulf81 I like your suggestion above! |
…com/misi9170/floris into feature/enhance-windrose-resampling
@paulf81, I reviewed the WindData |
Ok @misi9170 , assuming all green checks above I think this is all good to go. The one hedge is I did update the TiRose resample -> aggregate (mostly a name change but added checking that we aren't upsampling) but didn't add an interpolate method here, fearing the 3D interpolation and being short on time, can come back later for this? |
@Bartdoekemeijer noted a few place for improvement in the
WindRose
class, in particular:resample_wind_rose()
method, which returns a new instantiation rather than modifying the current objectplot_wind_rose()
, which resamples the data provided by default so makes it ambiguous which bins were specified (also, it turns out that providingwd_step=None
to avoid resampling causesplot_wind_rose()
to fail).This PR addresses those issues.
inplace
option provided forresample_wind_rose()
to modify the current object (defaults toFalse
at the moment to retain former operation, but we could consider changing the default toTrue
, which may be more intuitive. However, defaulting toFalse
is more pandas-like).plot_wind_rose()
is now not to resampleplot_wind_rose()
andresample_wind_rose()
toplot()
andresample()
for consistency acrossWindRose
andWindTIRose()
(and for simplicity)TimeSeries
and callingto_WindRose
---any ideas here?)*WindTIRose
@paulf81* We may need to be careful here, as there are several ways we could interpolate the data, so we should take a conservative/simple approach (but less conservative than the current approach, which is simply to assign extra 0 frequency bins)