Skip to content

Fix a bug with FrequencySeries analog zpk filters

Duncan Macleod requested to merge github/fork/asouthgate/dev-zpk-issue into main

Created by: asouthgate

Should fix one of the problems with https://github.com/gwpy/gwpy/issues/1544, where using an analog filter on a FrequencySeries gives an incorrect answer, since it is converted to digital with bilinear(), then analog scipy methods used, lti instead of dlti etc.

I added another arg to parse_filter, partly for compatibility. If an analog filter is parsed, but we don't want to convert it to digital (it is unnecessary and unexpected in this case) with bilinear_zpk, we can use analog_to_digital=False. The function doesn't do much else in this case. The other option was to check if analog=True in filter(), then call parse_filter(analog=False), but that seemed wrong.

Another option was to convert all filters to digital and use digital methods inside fdfilter. But I thought that might be unexpected (if an analog filter can be used directly and is passed to zpk(), it probably is expected to be used with equivalent of freqs, not silently converted). Also, I think the result can be non-identical in some cases.

I added another test, expanded one of the existing tests (test_zpk didn't actually test the result, and failed if that assertion was added). May need to chat about some of the existing tests which passed but maybe should not have.

May be worth yet more tests, too.

Merge request reports