From e88e00cad18ee9e6539a0d4a853fa2bdbc7a5b37 Mon Sep 17 00:00:00 2001 From: Lukas Adamowicz Date: Thu, 29 Aug 2024 14:45:55 -0400 Subject: [PATCH] short circuit gap filling if there are no actual gaps so resampling with fs that is slightly off doesnt break --- src/skdh/utility/internal.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/skdh/utility/internal.py b/src/skdh/utility/internal.py index 27d78b36..c86cf4aa 100644 --- a/src/skdh/utility/internal.py +++ b/src/skdh/utility/internal.py @@ -399,18 +399,21 @@ def fill_data_gaps(time, fs, fill_info, **kwargs): >>> print(data_rs.keys()) dict_keys(['accel', 'temp']) """ - # round-about way, but need to prevent start>>>>>>>>>step - time_rs = arange(0, (time[-1] - time[0]) + 0.5 / fs, 1 / fs) + time[0] - # get the first location of gaps in the data - add 1 so that the index reflects # the first value AFTER the gap gaps = nonzero(diff(time) > (1.5 / fs))[0] + 1 + if gaps.size == 0: + return time, kwargs + # create sequences of data with no gaps seqs = zeros((gaps.size + 1, 2), dtype=int_) seqs[1:, 0] = gaps seqs[:-1, 1] = gaps seqs[-1, 1] = time.size + # round-about way, but need to prevent start>>>>>>>>>step + time_rs = arange(0, (time[-1] - time[0]) + 0.5 / fs, 1 / fs) + time[0] + # iterate over the datastreams ret = {} for name, data in kwargs.items():