Skip to content
Snippets Groups Projects

Resolve "release v1.4.0"

Merged Ghost User requested to merge release_v1.4.0 into master
1 file
+ 29
4
Compare changes
  • Side-by-side
  • Inline
@@ -117,15 +117,40 @@ class DataHandlerFirFilterSingleStation(DataHandlerFilterSingleStation):
filter_add_unfiltered=DEFAULT_ADD_UNFILTERED, **kwargs):
# self._check_sampling(**kwargs)
# self.original_data = None # ToDo: implement here something to store unfiltered data
self.filter_cutoff_period = (lambda x: [x] if isinstance(x, tuple) else to_list(x))(filter_cutoff_period)
self.fs = self._get_fs(**kwargs)
self.filter_cutoff_period, removed_index = self._prepare_filter_cutoff_period(filter_cutoff_period, self.fs)
self.filter_cutoff_freq = self._period_to_freq(self.filter_cutoff_period)
assert len(self.filter_cutoff_period) == len(filter_order)
self.filter_order = filter_order
assert len(self.filter_cutoff_period) == (len(filter_order) - len(removed_index))
self.filter_order = self._prepare_filter_order(filter_order, removed_index, self.fs)
self.filter_window_type = filter_window_type
self._add_unfiltered = filter_add_unfiltered
self.fs = self._get_fs(**kwargs)
super().__init__(*args, **kwargs)
@staticmethod
def _prepare_filter_order(filter_order, removed_index, fs):
order = []
for i, o in enumerate(filter_order):
if i not in removed_index:
fo = int(o * fs)
fo = fo + 1 if fo % 2 == 0 else fo
order.append(fo)
return order
@staticmethod
def _prepare_filter_cutoff_period(filter_cutoff_period, fs):
"""Frequency must be smaller than the sampling frequency fs. Otherwise remove given cutoff period pair."""
cutoff_tmp = (lambda x: [x] if isinstance(x, tuple) else to_list(x))(filter_cutoff_period)
cutoff = []
removed = []
for i, (low, high) in enumerate(cutoff_tmp):
low = low if (low is None or low > 2. / fs) else None
high = high if (high is None or high > 2. / fs) else None
if any([low, high]):
cutoff.append((low, high))
else:
removed.append(i)
return cutoff, removed
@staticmethod
def _period_to_freq(cutoff_p):
return list(map(lambda x: (1. / x[0] if x[0] is not None else None, 1. / x[1] if x[1] is not None else None),
Loading