1
+ import warnings
2
+
1
3
import numpy as np
2
4
from scipy .linalg import eig
3
5
from scipy .special import comb
6
8
__all__ = ['daub' , 'qmf' , 'cascade' , 'morlet' , 'ricker' , 'morlet2' , 'cwt' ]
7
9
8
10
11
+ _msg = """scipy.signal.%s is deprecated in SciPy 1.12 and will be removed
12
+ in SciPy 1.14. We recommend using PyWavelets instead.
13
+ """
14
+
15
+
9
16
def daub (p ):
10
17
"""
18
+ .. deprecated:: 1.12.0
19
+
20
+ scipy.signal.daub is deprecated in SciPy 1.12 and will be removed
21
+ in SciPy 1.14. We recommend using PyWavelets instead.
22
+
11
23
The coefficients for the FIR low-pass filter producing Daubechies wavelets.
12
24
13
25
p>=1 gives the order of the zero at f=1/2.
@@ -24,6 +36,8 @@ def daub(p):
24
36
Return
25
37
26
38
"""
39
+ warnings .warn (_msg % 'daub' , DeprecationWarning , stacklevel = 2 )
40
+
27
41
sqrt = np .sqrt
28
42
if p < 1 :
29
43
raise ValueError ("p must be at least 1." )
@@ -77,6 +91,12 @@ def daub(p):
77
91
78
92
def qmf (hk ):
79
93
"""
94
+ .. deprecated:: 1.12.0
95
+
96
+ scipy.signal.qmf is deprecated in SciPy 1.12 and will be removed
97
+ in SciPy 1.14. We recommend using PyWavelets instead.
98
+
99
+
80
100
Return high-pass qmf filter from low-pass
81
101
82
102
Parameters
@@ -90,13 +110,21 @@ def qmf(hk):
90
110
High-pass filter coefficients.
91
111
92
112
"""
113
+ warnings .warn (_msg % 'qmf' , DeprecationWarning , stacklevel = 2 )
114
+
93
115
N = len (hk ) - 1
94
116
asgn = [{0 : 1 , 1 : - 1 }[k % 2 ] for k in range (N + 1 )]
95
117
return hk [::- 1 ] * np .array (asgn )
96
118
97
119
98
120
def cascade (hk , J = 7 ):
99
121
"""
122
+ .. deprecated:: 1.12.0
123
+
124
+ scipy.signal.cascade is deprecated in SciPy 1.12 and will be removed
125
+ in SciPy 1.14. We recommend using PyWavelets instead.
126
+
127
+
100
128
Return (x, phi, psi) at dyadic points ``K/2**J`` from filter coefficients.
101
129
102
130
Parameters
@@ -127,6 +155,8 @@ def cascade(hk, J=7):
127
155
end.
128
156
129
157
"""
158
+ warnings .warn (_msg % 'cascade' , DeprecationWarning , stacklevel = 2 )
159
+
130
160
N = len (hk ) - 1
131
161
132
162
if (J > 30 - np .log2 (N + 1 )):
@@ -203,6 +233,11 @@ def cascade(hk, J=7):
203
233
204
234
def morlet (M , w = 5.0 , s = 1.0 , complete = True ):
205
235
"""
236
+ .. deprecated:: 1.12.0
237
+
238
+ scipy.signal.morlet is deprecated in SciPy 1.12 and will be removed
239
+ in SciPy 1.14. We recommend using PyWavelets instead.
240
+
206
241
Complex Morlet wavelet.
207
242
208
243
Parameters
@@ -267,6 +302,8 @@ def morlet(M, w=5.0, s=1.0, complete=True):
267
302
>>> plt.show()
268
303
269
304
"""
305
+ warnings .warn (_msg % 'morlet' , DeprecationWarning , stacklevel = 2 )
306
+
270
307
x = np .linspace (- s * 2 * np .pi , s * 2 * np .pi , M )
271
308
output = np .exp (1j * w * x )
272
309
@@ -280,6 +317,12 @@ def morlet(M, w=5.0, s=1.0, complete=True):
280
317
281
318
def ricker (points , a ):
282
319
"""
320
+ .. deprecated:: 1.12.0
321
+
322
+ scipy.signal.ricker is deprecated in SciPy 1.12 and will be removed
323
+ in SciPy 1.14. We recommend using PyWavelets instead.
324
+
325
+
283
326
Return a Ricker wavelet, also known as the "Mexican hat wavelet".
284
327
285
328
It models the function:
@@ -315,6 +358,11 @@ def ricker(points, a):
315
358
>>> plt.show()
316
359
317
360
"""
361
+ warnings .warn (_msg % 'ricker' , DeprecationWarning , stacklevel = 2 )
362
+ return _ricker (points , a )
363
+
364
+
365
+ def _ricker (points , a ):
318
366
A = 2 / (np .sqrt (3 * a ) * (np .pi ** 0.25 ))
319
367
wsq = a ** 2
320
368
vec = np .arange (0 , points ) - (points - 1.0 ) / 2
@@ -327,6 +375,12 @@ def ricker(points, a):
327
375
328
376
def morlet2 (M , s , w = 5 ):
329
377
"""
378
+ .. deprecated:: 1.12.0
379
+
380
+ scipy.signal.morlet2 is deprecated in SciPy 1.12 and will be removed
381
+ in SciPy 1.14. We recommend using PyWavelets instead.
382
+
383
+
330
384
Complex Morlet wavelet, designed to work with `cwt`.
331
385
332
386
Returns the complete version of morlet wavelet, normalised
@@ -397,6 +451,8 @@ def morlet2(M, s, w=5):
397
451
>>> plt.show()
398
452
399
453
"""
454
+ warnings .warn (_msg % 'morlet2' , DeprecationWarning , stacklevel = 2 )
455
+
400
456
x = np .arange (0 , M ) - (M - 1.0 ) / 2
401
457
x = x / s
402
458
wavelet = np .exp (1j * w * x ) * np .exp (- 0.5 * x ** 2 ) * np .pi ** (- 0.25 )
@@ -406,6 +462,12 @@ def morlet2(M, s, w=5):
406
462
407
463
def cwt (data , wavelet , widths , dtype = None , ** kwargs ):
408
464
"""
465
+ .. deprecated:: 1.12.0
466
+
467
+ scipy.signal.cwt is deprecated in SciPy 1.12 and will be removed
468
+ in SciPy 1.14. We recommend using PyWavelets instead.
469
+
470
+
409
471
Continuous wavelet transform.
410
472
411
473
Performs a continuous wavelet transform on `data`,
@@ -479,6 +541,11 @@ def cwt(data, wavelet, widths, dtype=None, **kwargs):
479
541
... vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
480
542
>>> plt.show()
481
543
"""
544
+ warnings .warn (_msg % 'cwt' , DeprecationWarning , stacklevel = 2 )
545
+ return _cwt (data , wavelet , widths , dtype , ** kwargs )
546
+
547
+
548
+ def _cwt (data , wavelet , widths , dtype = None , ** kwargs ):
482
549
# Determine output type
483
550
if dtype is None :
484
551
if np .asarray (wavelet (1 , widths [0 ], ** kwargs )).dtype .char in 'FDG' :
0 commit comments