dnvgl / qats

Python library and GUI for efficient processing and visualization of time series.
MIT License
38 stars 10 forks source link

TimeSeries minima threshold sign error #95

Closed EBGlom closed 1 year ago

EBGlom commented 1 year ago

Describe the bug ts.minima() argument "threshold" does not work as intended for negative thresholds

To Reproduce Steps to reproduce the behavior:

from qats import TimeSeries
import numpy as np

t = np.array(range(2000))/2
x = np.cos(t/35*np.pi+0.1)*15 + np.cos(t/100*np.pi)*20 + np.cos(t/178*np.pi)*20 - 8

ts = TimeSeries('test', t, x)

print('Count all minima: ', len(ts.minima()))
print('Count all minima below -40: ', len(ts.minima(threshold=-40.)))
print('Count all minima below +40: ', len(ts.minima(threshold=40.)))

out:

Count all minima:  8
Count all minima below -40:  8
Count all minima below +40:  3

Expected behavior threshold=-40. should give 3, threshold=40. should give 8

tovop commented 1 year ago

It should work now. Check out the https://github.com/dnvgl/qats/tree/stats-improvements branch. I added this example showing tail fitting with the Weibull distribution.