ceedub package

Submodules

ceedub.wavelet module

Continuous wavelet transform and support functions based on Torrence and Compo 1998 (T&C)

(http://paos.colorado.edu/research/wavelets/bams_79_01_0061.pdf)

class ceedub.wavelet.MorletWave(w0=6)[source]

Bases: object

Morlet-Gabor wavelet: a Gaussian windowed sinusoid w0 is the nondimensional frequency constant. This defines the base frequency and width of the mother wavelet. For small w0 the wavelets have non-zero mean. T&C set this to 6 by default. If w0 is set to less than 5, the modified Morlet wavelet with better low w0 behavior is used instead.

e_fold(s)[source]

The e-folding time for the Morlet wavelet.

fourier_period(s)[source]

The Fourier period of the Morlet wavelet with scale, s, given by: P = 4*pi*s / (w0 + sqrt(2 + w0**2))

freq(w, s=1.0)[source]

Frequency domain representation of Morlet wavelet Note that the complex Morlet wavelet is real in the frequency domain. :param w: frequency :param s: scale factor :return psi: value of morlet wavelet at frequency, w

Note there is no support for modified Morlet wavelets. The wavelets are defined by dimensionless frequency: y = w*s

The standard Morlet wavelet is computed as:
psi(y) = pi**-.25 * H(y) * exp((-(y-w0)**2) / 2)
where H(y) is the Heaviside step function:
H(y) = (y > 0) ? 1:0
nyquist_scale(dt=1)[source]
s0 corresponding to the Nyquist period of wavelet
s0 = 2*dt * (w0 + sqrt(2 + w0**2)) / (4*pi)

for large w0 this is approximately dt*w0/pi

time(t, s=1.0)[source]

Time domain complex Morlet wavelet, centered at zero.

Parameters:
  • t – time
  • s – scale factor
Return psi:

value of complex morlet wavelet at time, t

The wavelets are defined by dimensionless time: x = t/s

For w0 >= 5, computes the standard Morlet wavelet:
psi(x) = pi**-0.25 * exp(1j*w0*x) * exp(-0.5*(x**2))
For w0 < 5, computes the modified Morlet wavelet:
psi(x) = pi**-0.25 *
(exp(1j*w0*x) - exp(-0.5*(x**2))) * exp(-0.5*(x**2))
class ceedub.wavelet.PaulWave(m=4)[source]

Bases: object

Paul wavelet of order m. By definition m is an integer, however in this implementation gamma functions are used in place of factorials, so non-integer values of m won’t cause errors.

e_fold(s)[source]

The e-folding time for the Morlet wavelet.

fourier_period(s)[source]

The Fourier period of the Paul wavelet given by: P = 4*pi*s / (2*m + 1)

freq(w, s=1.0)[source]

Frequency domain representation of Paul wavelet Note that the complex Paul wavelet is real in the frequency domain. :param w: frequency :param s: scale factor :returns psi: value of morlet wavelet at frequency, w

wavelets are defined by dimensionless frequency: y = w*s

The Paul wavelet is computed as:
psi(y) = 2**m / np.sqrt(m * (2*m-1)!) * H(y) * (y)**m * exp(-y)
where H(y) is the Heaviside step function:
H(y) = (y > 0) ? 1:0
nyquist_scale(dt=1)[source]

s0 corresponding to the Nyquist period of wavelet s0 = 2*dt (2*m + 1)/(4*pi)

time(t, s=1.0)[source]

Time domain complex Paul wavelet, centered at zero. :param t: time :param s: scale factor :returns psi: value of complex Paul wavelet at time, t

The wavelets are defined by dimensionless time: x = t/s

psi(x) = (2*1j)**m * m! / (pi*(2m)!) * (1 - 1j*x)**-(m+1)
class ceedub.wavelet.WaveletBasis(wavelet=None, N=None, dt=1, dj=0.0625)[source]

Bases: object

An object setting up a CWT basis for forward and inverse transforms of data using the same sample rate and frequency scales. At initialization given N, dt, and dj, the scales will be computed from the _get_scales function based on the Nyquist period of the wavelet and the length of the data. See T&C section 3.f for more information about how scales are choosen.

M
N
cwt(tdat)[source]

Computes the continuous wavelet transform of tdat, using the wavelet function and scales of the WaveletBasis, using FFT convolution as in T&C. The FFT convolution is performed once at each wavelet scale, determining the frequecny resolution of the output.

Parameters:tdat – shape (N,) array of real, time domain data
Returns:wdat shape (M,N) array of complex, wavelet domain data. M is the number of scales used in the transform, and N is the length of the input time domain data.
dj
dt
freqs
icwt(wdat)[source]

Coputes the inverse continuous wavelet transform of wdat, following T&C section 3.i. Uses the wavelet function and scales of the parent WaveletBasis.

Parameters:wdat – shape (M,N) array of complex, wavelet domain data. M is the number of frequency scales, and N is the number of time samples.
Returns:tdat shape (N,) array of real, time domain data
s0
scales
times

sample times of data

wavelet

basis wavelet function

ceedub.wavelet.cwt(tdat, dt=1)[source]

Compute the continuous wavelet transform, using the default WaveletBasis. If you plan on doing several CWTs in the same basis you should consider initializing a WaveletBasis object and using: WaveletBasis.cwt. :param tdat: shape (N,) array of real, time domain data :param dt: sample cadence of data, needed for normalization

of transforms
Returns:wdat shape (M,N) array of complex, wavelet domain data. M is the number of scales used in the transform, and N is the length of the input time domain data.
ceedub.wavelet.cwtfreq(N, dt=1)[source]

Output the Fourier frequencies of the scales used in the default WaveletBasis.

Parameters:
  • N – number of time samples in the time domain data.
  • dt – sample cadence of data

returns: shape (M,) array of frequencies

ceedub.wavelet.icwt(wdat, dt=1)[source]

Compute the inverse continuous wavelet transform, using the default WaveletBasis. If the forward transform was performed in a different basis, then this function will give incorrect output! If you plan on doing several ICWTs in the same basis you should seriously consider initializing a WaveletBasis object and using: WaveletBasis.cwt and WaveletBasis.icwt. :param wdat: shape (M,N) array of complex, wavelet domain data.

M is the number of frequency scales, and N is the number of time samples.
Returns:tdat shape (N,) array of real, time domain data

Module contents