Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/scipy/signal/__init__.py : 95%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2=======================================
3Signal processing (:mod:`scipy.signal`)
4=======================================
6Convolution
7===========
9.. autosummary::
10 :toctree: generated/
12 convolve -- N-D convolution.
13 correlate -- N-D correlation.
14 fftconvolve -- N-D convolution using the FFT.
15 oaconvolve -- N-D convolution using the overlap-add method.
16 convolve2d -- 2-D convolution (more options).
17 correlate2d -- 2-D correlation (more options).
18 sepfir2d -- Convolve with a 2-D separable FIR filter.
19 choose_conv_method -- Chooses faster of FFT and direct convolution methods.
21B-splines
22=========
24.. autosummary::
25 :toctree: generated/
27 bspline -- B-spline basis function of order n.
28 cubic -- B-spline basis function of order 3.
29 quadratic -- B-spline basis function of order 2.
30 gauss_spline -- Gaussian approximation to the B-spline basis function.
31 cspline1d -- Coefficients for 1-D cubic (3rd order) B-spline.
32 qspline1d -- Coefficients for 1-D quadratic (2nd order) B-spline.
33 cspline2d -- Coefficients for 2-D cubic (3rd order) B-spline.
34 qspline2d -- Coefficients for 2-D quadratic (2nd order) B-spline.
35 cspline1d_eval -- Evaluate a cubic spline at the given points.
36 qspline1d_eval -- Evaluate a quadratic spline at the given points.
37 spline_filter -- Smoothing spline (cubic) filtering of a rank-2 array.
39Filtering
40=========
42.. autosummary::
43 :toctree: generated/
45 order_filter -- N-D order filter.
46 medfilt -- N-D median filter.
47 medfilt2d -- 2-D median filter (faster).
48 wiener -- N-D Wiener filter.
50 symiirorder1 -- 2nd-order IIR filter (cascade of first-order systems).
51 symiirorder2 -- 4th-order IIR filter (cascade of second-order systems).
52 lfilter -- 1-D FIR and IIR digital linear filtering.
53 lfiltic -- Construct initial conditions for `lfilter`.
54 lfilter_zi -- Compute an initial state zi for the lfilter function that
55 -- corresponds to the steady state of the step response.
56 filtfilt -- A forward-backward filter.
57 savgol_filter -- Filter a signal using the Savitzky-Golay filter.
59 deconvolve -- 1-D deconvolution using lfilter.
61 sosfilt -- 1-D IIR digital linear filtering using
62 -- a second-order sections filter representation.
63 sosfilt_zi -- Compute an initial state zi for the sosfilt function that
64 -- corresponds to the steady state of the step response.
65 sosfiltfilt -- A forward-backward filter for second-order sections.
66 hilbert -- Compute 1-D analytic signal, using the Hilbert transform.
67 hilbert2 -- Compute 2-D analytic signal, using the Hilbert transform.
69 decimate -- Downsample a signal.
70 detrend -- Remove linear and/or constant trends from data.
71 resample -- Resample using Fourier method.
72 resample_poly -- Resample using polyphase filtering method.
73 upfirdn -- Upsample, apply FIR filter, downsample.
75Filter design
76=============
78.. autosummary::
79 :toctree: generated/
81 bilinear -- Digital filter from an analog filter using
82 -- the bilinear transform.
83 bilinear_zpk -- Digital filter from an analog filter using
84 -- the bilinear transform.
85 findfreqs -- Find array of frequencies for computing filter response.
86 firls -- FIR filter design using least-squares error minimization.
87 firwin -- Windowed FIR filter design, with frequency response
88 -- defined as pass and stop bands.
89 firwin2 -- Windowed FIR filter design, with arbitrary frequency
90 -- response.
91 freqs -- Analog filter frequency response from TF coefficients.
92 freqs_zpk -- Analog filter frequency response from ZPK coefficients.
93 freqz -- Digital filter frequency response from TF coefficients.
94 freqz_zpk -- Digital filter frequency response from ZPK coefficients.
95 sosfreqz -- Digital filter frequency response for SOS format filter.
96 group_delay -- Digital filter group delay.
97 iirdesign -- IIR filter design given bands and gains.
98 iirfilter -- IIR filter design given order and critical frequencies.
99 kaiser_atten -- Compute the attenuation of a Kaiser FIR filter, given
100 -- the number of taps and the transition width at
101 -- discontinuities in the frequency response.
102 kaiser_beta -- Compute the Kaiser parameter beta, given the desired
103 -- FIR filter attenuation.
104 kaiserord -- Design a Kaiser window to limit ripple and width of
105 -- transition region.
106 minimum_phase -- Convert a linear phase FIR filter to minimum phase.
107 savgol_coeffs -- Compute the FIR filter coefficients for a Savitzky-Golay
108 -- filter.
109 remez -- Optimal FIR filter design.
111 unique_roots -- Unique roots and their multiplicities.
112 residue -- Partial fraction expansion of b(s) / a(s).
113 residuez -- Partial fraction expansion of b(z) / a(z).
114 invres -- Inverse partial fraction expansion for analog filter.
115 invresz -- Inverse partial fraction expansion for digital filter.
116 BadCoefficients -- Warning on badly conditioned filter coefficients.
118Lower-level filter design functions:
120.. autosummary::
121 :toctree: generated/
123 abcd_normalize -- Check state-space matrices and ensure they are rank-2.
124 band_stop_obj -- Band Stop Objective Function for order minimization.
125 besselap -- Return (z,p,k) for analog prototype of Bessel filter.
126 buttap -- Return (z,p,k) for analog prototype of Butterworth filter.
127 cheb1ap -- Return (z,p,k) for type I Chebyshev filter.
128 cheb2ap -- Return (z,p,k) for type II Chebyshev filter.
129 cmplx_sort -- Sort roots based on magnitude.
130 ellipap -- Return (z,p,k) for analog prototype of elliptic filter.
131 lp2bp -- Transform a lowpass filter prototype to a bandpass filter.
132 lp2bp_zpk -- Transform a lowpass filter prototype to a bandpass filter.
133 lp2bs -- Transform a lowpass filter prototype to a bandstop filter.
134 lp2bs_zpk -- Transform a lowpass filter prototype to a bandstop filter.
135 lp2hp -- Transform a lowpass filter prototype to a highpass filter.
136 lp2hp_zpk -- Transform a lowpass filter prototype to a highpass filter.
137 lp2lp -- Transform a lowpass filter prototype to a lowpass filter.
138 lp2lp_zpk -- Transform a lowpass filter prototype to a lowpass filter.
139 normalize -- Normalize polynomial representation of a transfer function.
143Matlab-style IIR filter design
144==============================
146.. autosummary::
147 :toctree: generated/
149 butter -- Butterworth
150 buttord
151 cheby1 -- Chebyshev Type I
152 cheb1ord
153 cheby2 -- Chebyshev Type II
154 cheb2ord
155 ellip -- Elliptic (Cauer)
156 ellipord
157 bessel -- Bessel (no order selection available -- try butterod)
158 iirnotch -- Design second-order IIR notch digital filter.
159 iirpeak -- Design second-order IIR peak (resonant) digital filter.
161Continuous-time linear systems
162==============================
164.. autosummary::
165 :toctree: generated/
167 lti -- Continuous-time linear time invariant system base class.
168 StateSpace -- Linear time invariant system in state space form.
169 TransferFunction -- Linear time invariant system in transfer function form.
170 ZerosPolesGain -- Linear time invariant system in zeros, poles, gain form.
171 lsim -- Continuous-time simulation of output to linear system.
172 lsim2 -- Like lsim, but `scipy.integrate.odeint` is used.
173 impulse -- Impulse response of linear, time-invariant (LTI) system.
174 impulse2 -- Like impulse, but `scipy.integrate.odeint` is used.
175 step -- Step response of continuous-time LTI system.
176 step2 -- Like step, but `scipy.integrate.odeint` is used.
177 freqresp -- Frequency response of a continuous-time LTI system.
178 bode -- Bode magnitude and phase data (continuous-time LTI).
180Discrete-time linear systems
181============================
183.. autosummary::
184 :toctree: generated/
186 dlti -- Discrete-time linear time invariant system base class.
187 StateSpace -- Linear time invariant system in state space form.
188 TransferFunction -- Linear time invariant system in transfer function form.
189 ZerosPolesGain -- Linear time invariant system in zeros, poles, gain form.
190 dlsim -- Simulation of output to a discrete-time linear system.
191 dimpulse -- Impulse response of a discrete-time LTI system.
192 dstep -- Step response of a discrete-time LTI system.
193 dfreqresp -- Frequency response of a discrete-time LTI system.
194 dbode -- Bode magnitude and phase data (discrete-time LTI).
196LTI representations
197===================
199.. autosummary::
200 :toctree: generated/
202 tf2zpk -- Transfer function to zero-pole-gain.
203 tf2sos -- Transfer function to second-order sections.
204 tf2ss -- Transfer function to state-space.
205 zpk2tf -- Zero-pole-gain to transfer function.
206 zpk2sos -- Zero-pole-gain to second-order sections.
207 zpk2ss -- Zero-pole-gain to state-space.
208 ss2tf -- State-pace to transfer function.
209 ss2zpk -- State-space to pole-zero-gain.
210 sos2zpk -- Second-order sections to zero-pole-gain.
211 sos2tf -- Second-order sections to transfer function.
212 cont2discrete -- Continuous-time to discrete-time LTI conversion.
213 place_poles -- Pole placement.
215Waveforms
216=========
218.. autosummary::
219 :toctree: generated/
221 chirp -- Frequency swept cosine signal, with several freq functions.
222 gausspulse -- Gaussian modulated sinusoid.
223 max_len_seq -- Maximum length sequence.
224 sawtooth -- Periodic sawtooth.
225 square -- Square wave.
226 sweep_poly -- Frequency swept cosine signal; freq is arbitrary polynomial.
227 unit_impulse -- Discrete unit impulse.
229Window functions
230================
232For window functions, see the `scipy.signal.windows` namespace.
234In the `scipy.signal` namespace, there is a convenience function to
235obtain these windows by name:
237.. autosummary::
238 :toctree: generated/
240 get_window -- Return a window of a given length and type.
242Wavelets
243========
245.. autosummary::
246 :toctree: generated/
248 cascade -- Compute scaling function and wavelet from coefficients.
249 daub -- Return low-pass.
250 morlet -- Complex Morlet wavelet.
251 qmf -- Return quadrature mirror filter from low-pass.
252 ricker -- Return ricker wavelet.
253 morlet2 -- Return Morlet wavelet, compatible with cwt.
254 cwt -- Perform continuous wavelet transform.
256Peak finding
257============
259.. autosummary::
260 :toctree: generated/
262 argrelmin -- Calculate the relative minima of data.
263 argrelmax -- Calculate the relative maxima of data.
264 argrelextrema -- Calculate the relative extrema of data.
265 find_peaks -- Find a subset of peaks inside a signal.
266 find_peaks_cwt -- Find peaks in a 1-D array with wavelet transformation.
267 peak_prominences -- Calculate the prominence of each peak in a signal.
268 peak_widths -- Calculate the width of each peak in a signal.
270Spectral analysis
271=================
273.. autosummary::
274 :toctree: generated/
276 periodogram -- Compute a (modified) periodogram.
277 welch -- Compute a periodogram using Welch's method.
278 csd -- Compute the cross spectral density, using Welch's method.
279 coherence -- Compute the magnitude squared coherence, using Welch's method.
280 spectrogram -- Compute the spectrogram.
281 lombscargle -- Computes the Lomb-Scargle periodogram.
282 vectorstrength -- Computes the vector strength.
283 stft -- Compute the Short Time Fourier Transform.
284 istft -- Compute the Inverse Short Time Fourier Transform.
285 check_COLA -- Check the COLA constraint for iSTFT reconstruction.
286 check_NOLA -- Check the NOLA constraint for iSTFT reconstruction.
288"""
289from . import sigtools, windows
290from .waveforms import *
291from ._max_len_seq import max_len_seq
292from ._upfirdn import upfirdn
294# The spline module (a C extension) provides:
295# cspline2d, qspline2d, sepfir2d, symiirord1, symiirord2
296from .spline import *
298from .bsplines import *
299from .filter_design import *
300from .fir_filter_design import *
301from .ltisys import *
302from .lti_conversion import *
303from .signaltools import *
304from ._savitzky_golay import savgol_coeffs, savgol_filter
305from .spectral import *
306from .wavelets import *
307from ._peak_finding import *
308from .windows import get_window # keep this one in signal namespace
311# deal with * -> windows.* doc-only soft-deprecation
312deprecated_windows = ('boxcar', 'triang', 'parzen', 'bohman', 'blackman',
313 'nuttall', 'blackmanharris', 'flattop', 'bartlett',
314 'barthann', 'hamming', 'kaiser', 'gaussian',
315 'general_gaussian', 'chebwin', 'slepian', 'cosine',
316 'hann', 'exponential', 'tukey')
318# backward compatibility imports for actually deprecated windows not
319# in the above list
320from .windows import hanning
323def deco(name):
324 f = getattr(windows, name)
325 # Add deprecation to docstring
327 def wrapped(*args, **kwargs):
328 return f(*args, **kwargs)
330 wrapped.__name__ = name
331 wrapped.__module__ = 'scipy.signal'
332 if hasattr(f, '__qualname__'):
333 wrapped.__qualname__ = f.__qualname__
335 if f.__doc__:
336 lines = f.__doc__.splitlines()
337 for li, line in enumerate(lines):
338 if line.strip() == 'Parameters':
339 break
340 else:
341 raise RuntimeError('dev error: badly formatted doc')
342 spacing = ' ' * line.find('P')
343 lines.insert(li, ('{0}.. warning:: scipy.signal.{1} is deprecated,\n'
344 '{0} use scipy.signal.windows.{1} '
345 'instead.\n'.format(spacing, name)))
346 wrapped.__doc__ = '\n'.join(lines)
348 return wrapped
351for name in deprecated_windows:
352 locals()[name] = deco(name)
354del deprecated_windows, name, deco
357__all__ = [s for s in dir() if not s.startswith('_')]
359from scipy._lib._testutils import PytestTester
360test = PytestTester(__name__)
361del PytestTester