def load_series(self, subject, series):
min_freq = self.min_freq
max_freq = self.max_freq
key = (subject, series, min_freq, max_freq)
if key not in self._series_cache:
while len(self._series_cache) > self.MAX_CACHE_SIZE:
# Randomly throw away an item
self._series_cache.popitem()
print("Loading", subject, series)
data = read_csv(path(subject, series, "data"))
# Filter here since it's slow and we don't want to filter multiple
# times. `lfilter` is CAUSAL and thus doesn't violate the ban on future data.
if (self.min_freq is None) or (self.min_freq == 0):
print("Low pass filtering, f_h =", max_freq)
b, a = butter_lowpass(max_freq, SAMPLE_RATE, FILTER_N)
else:
print("Band pass filtering, f_l =", min_freq, "f_h =", max_freq)
b, a = butter_bandpass(min_freq, max_freq, SAMPLE_RATE, FILTER_N)
self._series_cache[key] = lfilter(b, a, data, axis=0)
return self._series_cache[key]
评论列表
文章目录