scipy.signal.

band_stop_obj#

scipy.signal.band_stop_obj(wp, ind, passb, stopb, gpass, gstop, type)[source]#

Band Stop Objective Function for order minimization.

Returns the non-integer order for an analog band stop filter.

Parameters:
wpscalar

Edge of passband passb.

indint, {0, 1}

Index specifying which passb edge to vary (0 or 1).

passbndarray

Two element sequence of fixed passband edges.

stopbndarray

Two element sequence of fixed stopband edges.

gstopfloat

Amount of attenuation in stopband in dB.

gpassfloat

Amount of ripple in the passband in dB.

type{‘butter’, ‘cheby’, ‘ellip’}

Type of filter.

Returns:
nscalar

Filter order (possibly non-integer).

Notes

Band-stop filters are used in applications where certain frequency components need to be blocked while others are allowed; for instance, removing noise at specific frequencies while allowing the desired signal to pass through. The order of a filter often determines its complexity and accuracy. Determining the right order can be a challenge. This function aims to provide an appropriate order for an analog band stop filter.

Array API Standard Support

band_stop_obj has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

See Support for the array API standard for more information.

Examples

>>> import numpy as np
>>> from scipy.signal import band_stop_obj
>>> wp = 2
>>> ind = 1
>>> passb = np.array([1, 3])
>>> stopb = np.array([0.5, 4])
>>> gstop = 30
>>> gpass = 3
>>> filter_type = 'butter'
>>> band_stop_obj(wp, ind, passb, stopb, gpass, gstop, filter_type)
np.float64(-2.758504160760643)