Skip to content

[Shear.TimeSeries] Function has option of setting maximise_data as True but results are same as when this is set as False #494

Open

Description

@BiancaMorandi

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

Image

Image

Image

Additional context
Add any other context about the problem here.

Activity

  1. added this to the v2.8.0 milestone on Sep 10, 2026
  2. olivia-bentley commented on Sep 29, 2026

    @olivia-bentley
    Contributor

    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.

  3. linked a pull request that will close this issueIss494 timeseries maximise data #641on Sep 30, 2026
  4. added a commit that references this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions