Skip to content

Use scipy filter functions for creating and performing filtering

Matthew Pitkin requested to merge filter_change into master

Currently the filtering during the heterodyning procedure is performed by generating three third order Butterworth filters (actually three each for the real and imaginary components) using LAL routines and consecutively applying them forwards and backwards. The filter history is attempted to be stored to allow the filters to be used smoothly across consecutive chunks of data, however the implementation means that it actually still leaves impulse responses at the start of each chunk (see, e.g., this plot).

To attempt to get around this, this MR switches to using Scipy's filtering functions. In particular, we can create a single 9th order Butterworth filter output as "second-order sections", which are more numerically stable for high order filters. We use the butter function to generate the filters for the real and imaginary components. We can then use the sosfilt_zi to set up the initial conditions of the filter and filter using sosfilt. Each subsequent "chunk" can be initialised using the information from the output by sosfilt giving the final filter delay values.

Using this filtering, the example shown here, which currently produces the plot) with the many impulse responses now looks like:

testfig

It can be seen that this is nice and smooth!

Merge request reports