Skip to content

Commit

Permalink
short circuit gap filling if there are no actual gaps so resampling w…
Browse files Browse the repository at this point in the history
…ith fs that is slightly off doesnt break
  • Loading branch information
LukasAdamowicz committed Aug 29, 2024
1 parent aa17104 commit e88e00c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/skdh/utility/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit e88e00c

Please sign in to comment.