### Navigation

- index
- modules |
- modules |
- next |
- previous |
- SciPy v0.9 Reference Guide (DRAFT) »
- Signal processing (`scipy.signal`) »

# scipy.signal.firwin2

`scipy.signal.``firwin2`(numtaps, freq, gain, nfreqs=None, window='hamming', nyq=1.0)

  FIR filter design using the window method.

  From the given frequencies freq and corresponding gains gain, this function constructs an FIR filter with linear phase and (approximately) the given frequency response.

  Parameters : | numtaps : int The number of taps in the FIR filter. numtaps must be less than nfreqs. If the gain at the Nyquist rate, gain[-1], is not 0, then numtaps must be odd. freq : array-like, 1D The frequency sampling points. Typically 0.0 to 1.0 with 1.0 being Nyquist. The Nyquist frequency can be redefined with the argument nyq. The values in freq must be nondecreasing. A value can be repeated once to implement a discontinuity. The first value in freq must be 0, and the last value must be nyq. gain : array-like The filter gains at the frequency sampling points. nfreqs : int, optional The size of the interpolation mesh used to construct the filter. For most efficient behavior, this should be a power of 2 plus 1 (e.g, 129, 257, etc). The default is one more than the smallest power of 2 that is not less than numtaps. nfreqs must be greater than numtaps. window : string or (string, float) or float, or None, optional Window function to use. Default is “hamming”. See `scipy.signal.get_window` for the complete list of possible values. If None, no window function is applied. nyq : float Nyquist frequency. Each frequency in freq must be between 0 and nyq (inclusive).
  Returns : | taps : numpy 1D array of length numtaps The filter coefficients of the FIR filter.

  See also

  `scipy.signal.firwin`

  Notes

  From the given set of frequencies and gains, the desired response is constructed in the frequency domain. The inverse FFT is applied to the desired response to create the associated convolution kernel, and the first numtaps coefficients of this kernel, scaled by window, are returned.

  The FIR filter will have linear phase. The filter is Type I if numtaps is odd and Type II if numtaps is even. Because Type II filters always have a zero at the Nyquist frequency, numtaps must be odd if gain[-1] is not zero.

  New in version 0.9.0.

  References

  [R55] | Oppenheim, A. V. and Schafer, R. W., “Discrete-Time Signal Processing”, Prentice-Hall, Englewood Cliffs, New Jersey (1989). (See, for example, Section 7.4.)

  [R56] | Smith, Steven W., “The Scientist and Engineer’s Guide to Digital Signal Processing”, Ch. 17. http://www.dspguide.com/ch17/1.htm

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- SciPy v0.9 Reference Guide (DRAFT) »
- Signal processing (`scipy.signal`) »