0
$\begingroup$

scipy butterworth filter has sos output option. Please help understand what it is and what the benefit in layman's term.

output{‘ba’, ‘zpk’, ‘sos’}, optional

Type of output: numerator/denominator (‘ba’), pole-zero (‘zpk’), or second-order sections (‘sos’). Default is ‘ba’ for backwards compatibility, but ‘sos’ should be used for general-purpose filtering.

Googled second order sections. Most articles lists math formulas and electric circuits and unable to find simple explanation.

According to ChatGPT, it looks a way to build N order filter as a cascade of multiple 2nd order filters, but not sure this ChatGPT answer is correct or relevant to scipy output option.

Higher-order filters can be constructed by cascading multiple second-order sections. This cascade structure simplifies the design and implementation process, as well as the optimization of filter performance.

Imagine you're building a really sophisticated filter for sound or data signals. Instead of making it all in one big complicated piece, you split it into smaller parts that are easier to handle. Each of these smaller parts is called a "second-order section."

In summary, "second-order sections" refer to the subdivision of a higher-order filter into smaller, more manageable second-order building blocks. This approach enhances flexibility, stability, efficiency, and ease of implementation in both analog and digital filter designs.

How to implement band-pass Butterworth filter with Scipy.signal.butter indicated stability but not sure it is specific to scipy implementation and not sos in general.

SciPy bandpass filters designed with b, a are unstable and may result in erroneous filters at higher filter orders. Instead, use sos (second-order sections) output of filter design.

$\endgroup$
2
  • 1
    $\begingroup$ SOS is definitely the way to go. However, the reasons behind this are deeply mathematical. What is you mathematical background? Are you familiar with Z-transform, linear difference equations, poles & zeros of filters, finding the roots of a polynomial ? "Layman's terms" really depend on the background of the lay person. And yes: ChatGPT is correct: $\endgroup$
    – Hilmar
    Commented Jul 24 at 3:15
  • $\begingroup$ @Hilmar, thanks for the follow up. I am not at that level (yet), so for now, having a confirmation of chatgpt is correct is a starting point. Thanks agian. $\endgroup$
    – mon
    Commented Jul 24 at 10:57

1 Answer 1

0
$\begingroup$

If you consider a first-order filter (with a single pole or zero), the pole or zero must be on the real axis to have a filter with real coefficients.

For a second-order filter (with two poles or zeros), the poles or zeros must be paired with their conjugates to ensure coefficients are real. Each of these pair form a second order section. So, basically, there is no other way to get an arbitrary filter with real coefficients.

The important question is how to pair zero pairs with pole pairs (as numerator and denumerator of second order section transfer function) and the order which SOS are cascaded. Usually nearest zero and pole paired together and SOS with highest Q factor comes first, which reduces computational noise and improves stability.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.