7
7
Spectral functions
8
8
-------------------
9
9
10
- :func: `cohere`
10
+ `cohere`
11
11
Coherence (normalized cross spectral density)
12
12
13
- :func: `csd`
13
+ `csd`
14
14
Cross spectral density using Welch's average periodogram
15
15
16
- :func: `detrend`
16
+ `detrend`
17
17
Remove the mean or best fit line from an array
18
18
19
- :func: `psd`
19
+ `psd`
20
20
Power spectral density using Welch's average periodogram
21
21
22
- :func: `specgram`
22
+ `specgram`
23
23
Spectrogram (spectrum over segments of time)
24
24
25
- :func: `complex_spectrum`
25
+ `complex_spectrum`
26
26
Return the complex-valued frequency spectrum of a signal
27
27
28
- :func: `magnitude_spectrum`
28
+ `magnitude_spectrum`
29
29
Return the magnitude of the frequency spectrum of a signal
30
30
31
- :func: `angle_spectrum`
31
+ `angle_spectrum`
32
32
Return the angle (wrapped phase) of the frequency spectrum of a signal
33
33
34
- :func: `phase_spectrum`
34
+ `phase_spectrum`
35
35
Return the phase (unwrapped angle) of the frequency spectrum of a signal
36
36
37
- :func: `detrend_mean`
37
+ `detrend_mean`
38
38
Remove the mean from a line.
39
39
40
- :func: `detrend_linear`
40
+ `detrend_linear`
41
41
Remove the best fit line from a line.
42
42
43
- :func: `detrend_none`
43
+ `detrend_none`
44
44
Return the original line.
45
45
46
- :func: `stride_windows`
46
+ `stride_windows`
47
47
Get all windows in an array in a memory-efficient manner
48
48
49
- :func: `stride_repeat`
49
+ `stride_repeat`
50
50
Repeat an array in a memory-efficient manner
51
51
52
- :func: `apply_window`
52
+ `apply_window`
53
53
Apply a window along a given axis
54
54
"""
55
55
@@ -67,8 +67,7 @@ def window_hanning(x):
67
67
68
68
See Also
69
69
--------
70
- :func:`window_none`
71
- :func:`window_none` is another window algorithm.
70
+ window_none : Another window algorithm.
72
71
'''
73
72
return np .hanning (len (x ))* x
74
73
@@ -79,8 +78,7 @@ def window_none(x):
79
78
80
79
See Also
81
80
--------
82
- :func:`window_hanning`
83
- :func:`window_hanning` is another window algorithm.
81
+ window_hanning : Another window algorithm.
84
82
'''
85
83
return x
86
84
@@ -152,9 +150,9 @@ def detrend(x, key=None, axis=None):
152
150
153
151
key : [ 'default' | 'constant' | 'mean' | 'linear' | 'none'] or function
154
152
Specifies the detrend algorithm to use. 'default' is 'mean', which is
155
- the same as :func: `detrend_mean`. 'constant' is the same. 'linear' is
156
- the same as :func: `detrend_linear`. 'none' is the same as
157
- :func: `detrend_none`. The default is 'mean'. See the corresponding
153
+ the same as `detrend_mean`. 'constant' is the same. 'linear' is
154
+ the same as `detrend_linear`. 'none' is the same as
155
+ `detrend_none`. The default is 'mean'. See the corresponding
158
156
functions for more details regarding the algorithms. Can also be a
159
157
function that carries out the detrend operation.
160
158
@@ -163,14 +161,9 @@ def detrend(x, key=None, axis=None):
163
161
164
162
See Also
165
163
--------
166
- :func:`detrend_mean`
167
- :func:`detrend_mean` implements the 'mean' algorithm.
168
-
169
- :func:`detrend_linear`
170
- :func:`detrend_linear` implements the 'linear' algorithm.
171
-
172
- :func:`detrend_none`
173
- :func:`detrend_none` implements the 'none' algorithm.
164
+ detrend_mean : Implementation of the 'mean' algorithm.
165
+ detrend_linear : Implementation of the 'linear' algorithm.
166
+ detrend_none : Implementation of the 'none' algorithm.
174
167
'''
175
168
if key is None or key in ['constant' , 'mean' , 'default' ]:
176
169
return detrend (x , key = detrend_mean , axis = axis )
@@ -221,9 +214,7 @@ def demean(x, axis=0):
221
214
222
215
See Also
223
216
--------
224
- :func:`detrend_mean`
225
- This function is the same as :func:`detrend_mean` except for the
226
- default *axis*.
217
+ detrend_mean : Same as `demean` except for the default *axis*.
227
218
'''
228
219
return detrend_mean (x , axis = axis )
229
220
@@ -244,18 +235,9 @@ def detrend_mean(x, axis=None):
244
235
245
236
See Also
246
237
--------
247
- :func:`demean`
248
- This function is the same as :func:`demean` except for the default
249
- *axis*.
250
-
251
- :func:`detrend_linear`
252
-
253
- :func:`detrend_none`
254
- :func:`detrend_linear` and :func:`detrend_none` are other detrend
255
- algorithms.
256
-
257
- :func:`detrend`
258
- :func:`detrend` is a wrapper around all the detrend algorithms.
238
+ detrend_linear : Another detrend algorithm.
239
+ detrend_none : Another detrend algorithm.
240
+ detrend : A wrapper around all the detrend algorithms.
259
241
'''
260
242
x = np .asarray (x )
261
243
@@ -280,14 +262,9 @@ def detrend_none(x, axis=None):
280
262
281
263
See Also
282
264
--------
283
- :func:`detrend_mean`
284
-
285
- :func:`detrend_linear`
286
- :func:`detrend_mean` and :func:`detrend_linear` are other detrend
287
- algorithms.
288
-
289
- :func:`detrend`
290
- :func:`detrend` is a wrapper around all the detrend algorithms.
265
+ detrend_mean : Another detrend algorithm.
266
+ detrend_linear : Another detrend algorithm.
267
+ detrend : A wrapper around all the detrend algorithms.
291
268
'''
292
269
return x
293
270
@@ -307,14 +284,9 @@ def detrend_linear(y):
307
284
308
285
See Also
309
286
--------
310
- :func:`detrend_mean`
311
-
312
- :func:`detrend_none`
313
- :func:`detrend_mean` and :func:`detrend_none` are other detrend
314
- algorithms.
315
-
316
- :func:`detrend`
317
- :func:`detrend` is a wrapper around all the detrend algorithms.
287
+ detrend_mean : Another detrend algorithm.
288
+ detrend_none : Another detrend algorithm.
289
+ detrend : A wrapper around all the detrend algorithms.
318
290
'''
319
291
# This is faster than an algorithm based on linalg.lstsq.
320
292
y = np .asarray (y )
@@ -653,14 +625,12 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
653
625
unit. The default value is 2.
654
626
655
627
window : callable or ndarray
656
- A function or a vector of length *NFFT*. To create window
657
- vectors see :func:`window_hanning`, :func:`window_none`,
658
- :func:`numpy.blackman`, :func:`numpy.hamming`,
659
- :func:`numpy.bartlett`, :func:`scipy.signal`,
660
- :func:`scipy.signal.get_window`, etc. The default is
661
- :func:`window_hanning`. If a function is passed as the
662
- argument, it must take a data segment as an argument and
663
- return the windowed version of the segment.
628
+ A function or a vector of length *NFFT*. To create window vectors see
629
+ `window_hanning`, `window_none`, `numpy.blackman`, `numpy.hamming`,
630
+ `numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. The
631
+ default is `window_hanning`. If a function is passed as the argument,
632
+ it must take a data segment as an argument and return the windowed
633
+ version of the segment.
664
634
665
635
sides : {'default', 'onesided', 'twosided'}
666
636
Specifies which sides of the spectrum to return. Default gives the
@@ -700,18 +670,14 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
700
670
result will be incorrect. Use *pad_to* for this instead.
701
671
702
672
detrend : {'default', 'constant', 'mean', 'linear', 'none'} or callable
703
- The function applied to each segment before fft-ing,
704
- designed to remove the mean or linear trend. Unlike in
705
- MATLAB, where the *detrend* parameter is a vector, in
706
- matplotlib is it a function. The :mod:`~matplotlib.mlab`
707
- module defines :func:`~matplotlib.mlab.detrend_none`,
708
- :func:`~matplotlib.mlab.detrend_mean`, and
709
- :func:`~matplotlib.mlab.detrend_linear`, but you can use
710
- a custom function as well. You can also use a string to choose
711
- one of the functions. 'default', 'constant', and 'mean' call
712
- :func:`~matplotlib.mlab.detrend_mean`. 'linear' calls
713
- :func:`~matplotlib.mlab.detrend_linear`. 'none' calls
714
- :func:`~matplotlib.mlab.detrend_none`.
673
+ The function applied to each segment before fft-ing, designed to
674
+ remove the mean or linear trend. Unlike in MATLAB, where the
675
+ *detrend* parameter is a vector, in Matplotlib is it a function.
676
+ The :mod:`~matplotlib.mlab` module defines `.detrend_none`,
677
+ `.detrend_mean`, and `.detrend_linear`, but you can use a custom
678
+ function as well. You can also use a string to choose one of the
679
+ functions. 'default', 'constant', and 'mean' call `.detrend_mean`.
680
+ 'linear' calls `.detrend_linear`. 'none' calls `.detrend_none`.
715
681
716
682
scale_by_freq : bool, optional
717
683
Specifies whether the resulting density values should be scaled
@@ -770,16 +736,13 @@ def psd(x, NFFT=None, Fs=None, detrend=None, window=None,
770
736
771
737
See Also
772
738
--------
773
- :func:`specgram`
774
- :func:`specgram` differs in the default overlap; in not returning the
775
- mean of the segment periodograms; and in returning the times of the
776
- segments.
739
+ specgram
740
+ `specgram` differs in the default overlap; in not returning the mean of
741
+ the segment periodograms; and in returning the times of the segments.
777
742
778
- :func:`magnitude_spectrum`
779
- :func:`magnitude_spectrum` returns the magnitude spectrum.
743
+ magnitude_spectrum : returns the magnitude spectrum.
780
744
781
- :func:`csd`
782
- :func:`csd` returns the spectral density between two signals.
745
+ csd : returns the spectral density between two signals.
783
746
"""
784
747
Pxx , freqs = csd (x = x , y = None , NFFT = NFFT , Fs = Fs , detrend = detrend ,
785
748
window = window , noverlap = noverlap , pad_to = pad_to ,
@@ -839,8 +802,7 @@ def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None,
839
802
840
803
See Also
841
804
--------
842
- :func:`psd`
843
- :func:`psd` is the equivalent to setting y=x.
805
+ psd : equivalent to setting ``y = x``.
844
806
"""
845
807
if NFFT is None :
846
808
NFFT = 256
@@ -885,19 +847,14 @@ def complex_spectrum(x, Fs=None, window=None, pad_to=None,
885
847
886
848
See Also
887
849
--------
888
- :func:`magnitude_spectrum`
889
- :func:`magnitude_spectrum` returns the absolute value of this function.
890
-
891
- :func:`angle_spectrum`
892
- :func:`angle_spectrum` returns the angle of this function.
893
-
894
- :func:`phase_spectrum`
895
- :func:`phase_spectrum` returns the phase (unwrapped angle) of this
896
- function.
897
-
898
- :func:`specgram`
899
- :func:`specgram` can return the complex spectrum of segments within the
900
- signal.
850
+ magnitude_spectrum
851
+ Returns the absolute value of this function.
852
+ angle_spectrum
853
+ Returns the angle of this function.
854
+ phase_spectrum
855
+ Returns the phase (unwrapped angle) of this function.
856
+ specgram
857
+ Can return the complex spectrum of segments within the signal.
901
858
"""
902
859
return _single_spectrum_helper (x = x , Fs = Fs , window = window , pad_to = pad_to ,
903
860
sides = sides , mode = 'complex' )
@@ -930,23 +887,16 @@ def magnitude_spectrum(x, Fs=None, window=None, pad_to=None,
930
887
931
888
See Also
932
889
--------
933
- :func:`psd`
934
- :func:`psd` returns the power spectral density.
935
-
936
- :func:`complex_spectrum`
937
- This function returns the absolute value of :func:`complex_spectrum`.
938
-
939
- :func:`angle_spectrum`
940
- :func:`angle_spectrum` returns the angles of the corresponding
941
- frequencies.
942
-
943
- :func:`phase_spectrum`
944
- :func:`phase_spectrum` returns the phase (unwrapped angle) of the
945
- corresponding frequencies.
946
-
947
- :func:`specgram`
948
- :func:`specgram` can return the magnitude spectrum of segments within
949
- the signal.
890
+ psd
891
+ Returns the power spectral density.
892
+ complex_spectrum
893
+ This function returns the absolute value of `complex_spectrum`.
894
+ angle_spectrum
895
+ Returns the angles of the corresponding frequencies.
896
+ phase_spectrum
897
+ Returns the phase (unwrapped angle) of the corresponding frequencies.
898
+ specgram
899
+ Can return the complex spectrum of segments within the signal.
950
900
"""
951
901
return _single_spectrum_helper (x = x , Fs = Fs , window = window , pad_to = pad_to ,
952
902
sides = sides , mode = 'magnitude' )
@@ -979,19 +929,14 @@ def angle_spectrum(x, Fs=None, window=None, pad_to=None,
979
929
980
930
See Also
981
931
--------
982
- :func:`complex_spectrum`
983
- This function returns the angle value of :func:`complex_spectrum`.
984
-
985
- :func:`magnitude_spectrum`
986
- :func:`angle_spectrum` returns the magnitudes of the corresponding
987
- frequencies.
988
-
989
- :func:`phase_spectrum`
990
- :func:`phase_spectrum` returns the unwrapped version of this function.
991
-
992
- :func:`specgram`
993
- :func:`specgram` can return the angle spectrum of segments within the
994
- signal.
932
+ complex_spectrum
933
+ This function returns the angle value of `complex_spectrum`.
934
+ magnitude_spectrum
935
+ Returns the magnitudes of the corresponding frequencies.
936
+ phase_spectrum
937
+ Returns the phase (unwrapped angle) of the corresponding frequencies.
938
+ specgram
939
+ Can return the complex spectrum of segments within the signal.
995
940
"""
996
941
return _single_spectrum_helper (x = x , Fs = Fs , window = window , pad_to = pad_to ,
997
942
sides = sides , mode = 'angle' )
@@ -1024,19 +969,14 @@ def phase_spectrum(x, Fs=None, window=None, pad_to=None,
1024
969
1025
970
See Also
1026
971
--------
1027
- :func:`complex_spectrum`
1028
- This function returns the angle value of :func:`complex_spectrum`.
1029
-
1030
- :func:`magnitude_spectrum`
1031
- :func:`magnitude_spectrum` returns the magnitudes of the corresponding
1032
- frequencies.
1033
-
1034
- :func:`angle_spectrum`
1035
- :func:`angle_spectrum` returns the wrapped version of this function.
1036
-
1037
- :func:`specgram`
1038
- :func:`specgram` can return the phase spectrum of segments within the
1039
- signal.
972
+ complex_spectrum
973
+ This function returns the phase value of `complex_spectrum`.
974
+ magnitude_spectrum
975
+ Returns the magnitudes of the corresponding frequencies.
976
+ angle_spectrum
977
+ Returns the angle (wrapped phase) of the corresponding frequencies.
978
+ specgram
979
+ Can return the complex spectrum of segments within the signal.
1040
980
"""
1041
981
return _single_spectrum_helper (x = x , Fs = Fs , window = window , pad_to = pad_to ,
1042
982
sides = sides , mode = 'phase' )
0 commit comments