ezmsg.sigproc.util.minphase#

Minimum-phase conversion of FIR kernels, real or complex.

Functions

is_linear_phase(h)[source]#

Whether a 1-D FIR kernel is (generalized) linear phase.

True for symmetric and antisymmetric real kernels and for conjugate-symmetric or conjugate-antisymmetric complex ones, i.e. h == ±conj(h[::-1]).

Parameters:

h (NDArray)

Return type:

bool

kernel_delay(h)[source]#

Delay of a 1-D FIR kernel, in samples.

Exactly (len(h) - 1) / 2 for a linear-phase kernel (see is_linear_phase()). Otherwise the group delay at the frequency where |H| peaks – the envelope delay at band centre, which is an approximation because the delay varies with frequency.

Parameters:

h (NDArray)

Return type:

float

min_phase_kernel(h, mode)[source]#

Convert a linear-phase FIR kernel to its minimum-phase equivalent.

Real kernels go to scipy.signal.minimum_phase(). Complex kernels (e.g. analytic wavelets) use an equivalent homomorphic routine; the Hilbert method has no complex counterpart and raises.

Parameters:
  • h (NDArray) – 1-D FIR kernel.

  • mode (MinPhaseMode) – HILBERT and HOMOMORPHIC return (len(h) + 1) // 2 taps with approximately the square root of the original magnitude response; HOMOMORPHICFULL returns len(h) taps with approximately the original magnitude response; NONE returns h unchanged.

Returns:

The converted kernel.

Return type:

NDArray

Classes

class MinPhaseMode(*values)[source]#

Bases: OptionsEnum

How to convert a linear-phase FIR kernel to minimum phase.

NONE = 'No kernel modification'#
HILBERT = 'Hilbert Method; designed to be used with equiripple filters (e.g., from remez) with unity or zero gain regions'#
HOMOMORPHIC = 'Works best with filters with an odd number of taps, and the resulting minimum phase filter will have a magnitude response that approximates the square root of the original filter’s magnitude response using half the number of taps'#
HOMOMORPHICFULL = 'Like HOMOMORPHIC, but uses the full number of taps and same magnitude'#