1
1
"""
2
-
3
2
Numerical python functions written for compatibility with MATLAB
4
3
commands with the same names.
5
4
15
14
:func:`detrend`
16
15
Remove the mean or best fit line from an array
17
16
18
- :func:`find`
19
- Return the indices where some condition is true;
20
- numpy.nonzero is similar but more general.
21
-
22
- :func:`griddata`
23
- Interpolate irregularly distributed data to a
24
- regular grid.
25
-
26
- :func:`prctile`
27
- Find the percentiles of a sequence
28
-
29
- :func:`prepca`
30
- Principal Component Analysis
31
-
32
17
:func:`psd`
33
18
Power spectral density using Welch's average periodogram
34
19
35
- :func:`rk4`
36
- A 4th order runge kutta integrator for 1D or ND systems
37
-
38
20
:func:`specgram`
39
21
Spectrogram (spectrum over segments of time)
40
22
43
25
44
26
Functions that don't exist in MATLAB, but are useful anyway:
45
27
46
- :func:`cohere_pairs`
47
- Coherence over all pairs. This is not a MATLAB function, but we
48
- compute coherence a lot in my lab, and we compute it for a lot of
49
- pairs. This function is optimized to do this efficiently by
50
- caching the direct FFTs.
51
-
52
- :func:`rk4`
53
- A 4th order Runge-Kutta ODE integrator in case you ever find
54
- yourself stranded without scipy (and the far superior
55
- scipy.integrate tools)
56
-
57
- :func:`contiguous_regions`
58
- Return the indices of the regions spanned by some logical mask
59
-
60
- :func:`cross_from_below`
61
- Return the indices where a 1D array crosses a threshold from below
62
-
63
- :func:`cross_from_above`
64
- Return the indices where a 1D array crosses a threshold from above
65
-
66
28
:func:`complex_spectrum`
67
29
Return the complex-valued frequency spectrum of a signal
68
30
78
40
:func:`detrend_mean`
79
41
Remove the mean from a line.
80
42
81
- :func:`demean`
82
- Remove the mean from a line. This function is the same as
83
- :func:`detrend_mean` except for the default *axis*.
84
-
85
43
:func:`detrend_linear`
86
44
Remove the best fit line from a line.
87
45
96
54
97
55
:func:`apply_window`
98
56
Apply a window along a given axis
99
-
100
-
101
- record array helper functions
102
- -----------------------------
103
-
104
- A collection of helper methods for numpyrecord arrays
105
-
106
- .. _htmlonly:
107
-
108
- See :ref:`misc-examples-index`
109
-
110
- :func:`rec2txt`
111
- Pretty print a record array
112
-
113
- :func:`rec2csv`
114
- Store record array in CSV file
115
-
116
- :func:`csv2rec`
117
- Import record array from CSV file with type inspection
118
-
119
- :func:`rec_append_fields`
120
- Adds field(s)/array(s) to record array
121
-
122
- :func:`rec_drop_fields`
123
- Drop fields from record array
124
-
125
- :func:`rec_join`
126
- Join two record arrays on sequence of fields
127
-
128
- :func:`recs_join`
129
- A simple join of multiple recarrays using a single column as a key
130
-
131
- :func:`rec_groupby`
132
- Summarize data by groups (similar to SQL GROUP BY)
133
-
134
- :func:`rec_summarize`
135
- Helper code to filter rec array fields into new fields
136
-
137
- For the rec viewer functions(e rec2csv), there are a bunch of Format
138
- objects you can pass into the functions that will do things like color
139
- negative values red, set percent formatting and scaling, etc.
140
-
141
- Example usage::
142
-
143
- r = csv2rec('somefile.csv', checkrows=0)
144
-
145
- formatd = dict(
146
- weight = FormatFloat(2),
147
- change = FormatPercent(2),
148
- cost = FormatThousands(2),
149
- )
150
-
151
-
152
- rec2excel(r, 'test.xls', formatd=formatd)
153
- rec2csv(r, 'test.csv', formatd=formatd)
154
-
155
57
"""
156
58
157
59
import copy
@@ -320,6 +222,7 @@ def detrend(x, key=None, axis=None):
320
222
return np .apply_along_axis (key , axis = axis , arr = x )
321
223
322
224
225
+ @cbook .deprecated ("3.1" , alternative = "detrend_mean" )
323
226
def demean (x , axis = 0 ):
324
227
'''
325
228
Return x minus its mean along the specified axis.
@@ -336,11 +239,6 @@ def demean(x, axis=0):
336
239
337
240
See Also
338
241
--------
339
- :func:`delinear`
340
-
341
- :func:`denone`
342
- :func:`delinear` and :func:`denone` are other detrend algorithms.
343
-
344
242
:func:`detrend_mean`
345
243
This function is the same as :func:`detrend_mean` except for the
346
244
default *axis*.
@@ -410,10 +308,6 @@ def detrend_none(x, axis=None):
410
308
411
309
See Also
412
310
--------
413
- :func:`denone`
414
- This function is the same as :func:`denone` except for the default
415
- *axis*, which has no effect.
416
-
417
311
:func:`detrend_mean`
418
312
419
313
:func:`detrend_linear`
@@ -441,10 +335,6 @@ def detrend_linear(y):
441
335
442
336
See Also
443
337
--------
444
- :func:`delinear`
445
- This function is the same as :func:`delinear` except for the default
446
- *axis*.
447
-
448
338
:func:`detrend_mean`
449
339
450
340
:func:`detrend_none`
0 commit comments