USGS-CMG / stglib

Routines used by the USGS Coastal/Marine Hazards & Resources Program to process oceanographic time-series data
Other
17 stars 14 forks source link

Fix selection of values that pass the K_p criterion #255

Closed dnowacki-usgs closed 1 month ago

dnowacki-usgs commented 1 month ago

The old way would not properly handle a situation where K_p values were all greater than 0.1. For example, if Kp = np.array([1, .5, .11]), then the old way of computing the index, Kpcutind = np.argmax(Kp <= 0.1) will return 0. In this case we want to have the "cutoff" be the entire array, not none of the array. To fix this, we change to np.nonzero(Kp > 0.1)[0][-1] + 1 which is the index of the last value in the array, plus 1.

If Kp = np.array([1, .5, .11, .1, .09, .01]), then the old and new approach both yield 3.