uafgeotools / lts_array

Least trimmed squares array processing for infrasound and seismic data
MIT License
12 stars 6 forks source link

int() is used without rounding first #20

Closed liamtoney closed 1 year ago

liamtoney commented 2 years ago

The Python int() command truncates values. So, e.g., the following occurs:

>> int(1.9)
1

this is relevant to _ltsarray e.g. in this line: https://github.com/uafgeotools/lts_array/blob/4f85442a1d4e821fb5e6bcf45e5a649e8db8f56f/lts_array/ltsva.py#L55

For fs = 20 Hz, winlen = 10 s, and winover = 0.9, sampinc is calculated as 19 samples — but it should be 20. This then bleeds into the output time vector, t, for this example causing its sampling interval to be 0.95 s rather than 1 s as expected. This causes large timing errors for long array processing routines if users naively calculate a 1 s sampling rate (as I did!).

Changing to

sampinc = int(round((1 - winover) * winlensamp))

fixes the above issue. There may be other examples as well.

jwbishop commented 1 year ago

Fixed by #23