Repository navigation
Iss494 timeseries maximise data - #641
olivia-bentley wants to merge 2 commits into
Conversation
|
@olivia-bentley I have reviewed this PR and the bug is solved. I see however some other issues below linked to Gaps
Suggested next steps
@stephenholleran when point 1 and 2 on 'suggested next steps' are addressed then I am happy for you to approve. |
Thanks @BiancaMorandi. Addressed suggested next steps 1 and 2:
Tests added in test_shear.py for both. One caveat: TimeSeries(..., maximise_data=True) will still raise "no valid data" on a dataset where the heights never all overlap. This is because the profile plot is built with Shear.Average, which only uses timestamps where all heights are valid (your gap 2). The validation itself is fixed, but the full call only works on such data once the plot follows maximise_data. I propose handling this in #341 |
|
Thanks @olivia-bentley . I have added comment about point 3 on #341. I leave you discuss whit @stephenholleran what is the option he prefers for my point 4 below and add the relevant issue. @stephenholleran this PR is ready for your approval. |
Summary
Fixes #494.
maximise_data=Truehad no effect inShear.TimeSeries. Shear is now calculated for every timestamp that has at least two valid wind speeds (abovemin_speedand not NaN), as the docstring says. At each timestamp it uses only the heights that are valid.Problem
When
Shear.TimeSerieswas initialised, a timestamp was only used if every height was valid ((wspds > min_speed).all(axis=1)), whatevermaximise_datawas set to. Somaximise_data=Truegave the same result asFalse. Timestamps where one anemometer was missing or belowmin_speedwere thrown away, even when two or more good heights were left to fit the shear profile to.Changes
brightwind/analyse/shear.pyShear.TimeSeries.__init__:valid_heightsmask.maximise_data=True: uses every timestamp with ≥ 2 valid heights and fits only the valid heights in each row.maximise_data=False: unchanged, still needs all heights to be valid.Shear._calc_linear_fit:maskargument, so a vectorised least squares fit can use a different set of heights in each row.CHANGELOG.md: added a Bug Fixes entry under 2.8.0.tests/test_shear.pytest_calc_linear_fit:np.polyfiton the valid values of each rowtest_time_series_maximise_data, run forpower_lawandlog_lawwith NaNs and below-min_speedvalues injected:info['output data']['concurrent_period']goes up (0.941 → 1.455)test_time_series: themaximise_data=Trueobjects were being overwritten and never checked. They now get their own variables and assertions.Behaviour change
maximise_data=False(the default), results are unchanged.maximise_data=True, results are unchanged for timestamps where every height is valid. Timestamps that were NaN before now get a shear value if at least two heights are valid.maximise_data=Truewill get more non-NaN values and a different mean or distribution of alpha or roughness, because two-height fits are now included.Notes
iss408_speed_up_wind_shear_calculation, which adds the vectorised_calc_linear_fit.