You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Shear.TimeSeries] Function has option of setting maximise_data as True but results are same as when this is set as False #494
Describe the bug
When I give as input to the Shear.TimeSeries function maximise_data=True, I get a coverage for the concurrent_period that is different than coverage I get when maximise_data=False BUT the overall length of the shear output is the same. The bug is that maximise_data=True doesn't seem to make any difference on shear results else than the concurrent_period coverage results.
To Reproduce
This result can be obtained running code below.
data = bw.load_csv(bw.demo_datasets.demo_data)
# add nan to one speed
df = data[['Spd80mN', 'Spd60mN', 'Spd40mN']]['2016-01-10 00:00':'2016-02-20 02:00'].copy()
df['Spd80mN']['2016-01-10 00:20': '2016-01-10 00:50'] = np.nan
heights_shear = [80, 60, 40]
df
# calculate concurrent period coverage if using all speeds (e.g maximise_data = False)
print(bw.coverage(df[df>3].dropna(), period='1AS'))
# calculate concurrent period coverage if using all data where two or more anemometers readings exist for a
# timestamp (e.g maximise_data = True)
count = df[df>3].count(axis=1)
# count
count = count[count >=2]
count.rename('count', inplace=True)
bw.coverage(count, period='1AS')
# results obtained with maximise_data = False
obj_shear1 = bw.Shear.TimeSeries(df, heights_shear,calc_method='power_law', maximise_data=False)
print(obj_shear1.info['output data']['concurrent_period'])
obj_shear1.alpha.dropna()
# results obtained with maximise_data = True
obj_shear2 = bw.Shear.TimeSeries(df, heights_shear,calc_method='power_law', maximise_data=True)
print(obj_shear2.info['output data']['concurrent_period'])
obj_shear2.alpha.dropna()
Expected behavior
I think that this is a bug because when I give as input to the function maximise_data=True, based on definition on docstring, I would expect that shear is derived on all data where two or more anemometers readings exist for a timestamp. So if I give as input speed for 3 heights and for few timestamps one of these speeds is nan then I assume that shear should be derived using speed for the other two heights. This doesn't seem to be the case when I use brightwind >= v.2.2.1.
Screenshots
Additional context
Add any other context about the problem here.
Confirmed while working on PR #635 (#408). The cause is valid_mask in Shear.TimeSeries.__init__: it only keeps timestamps where every height is above min_speed and not NaN, so maximise_data only affects the concurrent_period coverage. The new vectorised fit in #635 (Shear._calc_linear_fit) could be extended with a per-row mask to fit rows with at least two valid heights, as the docstring describes. That would change results, so it should be done here rather than in #635.
Activity
olivia-bentley commentedon Sep 29, 2026
Confirmed while working on PR #635 (#408). The cause is
valid_maskinShear.TimeSeries.__init__: it only keeps timestamps where every height is abovemin_speedand not NaN, somaximise_dataonly affects theconcurrent_periodcoverage. The new vectorised fit in #635 (Shear._calc_linear_fit) could be extended with a per-row mask to fit rows with at least two valid heights, as the docstring describes. That would change results, so it should be done here rather than in #635.iss #494 fix maximise_data issue