Improve filtering interface
Closed this issue · 0 comments
Currently we have to do things like:
ts.add_mirror_buffer(1)
# do stuff with ts
ts.remove_buffer(1)
This is a perfect use case for a context manager:
with ts.with_buffer(1):
# do stuff with ts
# now ts has been filtered and the buffer has been removed
The only slightly awkward thing about this compared to normal usage currently is that the assumption here is that we're doing everything in place (or at least overwriting ts
contents with the filtered versions).
Another approach is to modify filters to take a buffer
keyword argument. The problem here is that if we're applying more than one filter, we probably don't want to add/remove the buffer each time.
Yet another option is to introduce the notion of a filter pipeline. Here we could do something like:
ts.filter_pipeline((ButterworthFilter, *bwargs, **bwkwargs), (MorletWaveletFilter, ...), buffer_time=1)
The above syntax is a little awkward due to filters requiring a TimeSeries
as an input and could be simplified if we were to refactor this.