Preprocessing

A few functions (i.e. wavelet transforms) are provided for data preprocessing purposes.

Discrete Wavelet Transform

Discrete Wavelet Transform based on the GSL DWT [Gsldwt].

mlpy.dwt(x, wf, k)

Discrete Wavelet Tranform

Input

  • x - [1D numpy array float] data
  • wf - [string] wavelet type (‘d’: daubechies, ‘h’: haar, ‘b’: bspline)
  • k - [integer] member of the wavelet family
    • daubechies: k = 4, 6, ..., 20 with k even
    • haar: the only valid choice of k is k = 2
    • bspline: k = 103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309

Output

  • X - [1D numpy array float] discrete wavelet transform
mlpy.idwt(X, wf, k)

Inverse Discrete Wavelet Tranform

Input

  • X - [1D numpy array float] data
  • wf - [string] wavelet type (‘d’: daubechies, ‘h’: haar, ‘b’: bspline)
  • k - [integer] member of the wavelet family
    • daubechies: k = 4, 6, ..., 20 with k even
    • haar: the only valid choice of k is k = 2
    • bspline: k = 103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309

Output

  • x - [1D numpy array float]

Continuous Wavelet Transform

Continuous Wavelet Transform based on [Torrence98].

mlpy.cwt(x, dt, dj, wf='dog', p=2, pad=0.0)

Continuous Wavelet Tranform.

Input

  • x - [1D numpy array float] data
  • dt - [float] time step
  • dj - [float] scale resolution (smaller values of dt give finer resolution)
  • wf - [string] wavelet function (‘morlet’, ‘paul’, ‘dog’)
  • p - [float] wavelet function parameter
  • pad - [float] minimum fraction of added zeros (zero padding)

Output

  • X, scales - (scales x angularfreq) [2D numpy array complex], scales [1D numpy array float]
mlpy.icwt(X, dt, dj, wf='dog', p=2, recf=True)

Inverse Continuous Wavelet Tranform.

Input

  • X - (scales x angularfreq) [2D numpy array complex]

  • dt - [float] time step

  • dj - [float] scale resolution (smaller values of dt give finer resolution)

  • wf - [string] wavelet function (‘morlet’, ‘paul’, ‘dog’)

  • p - [int] wavelet function parameter

    • morlet: 2, 4, 6
    • paul: 2, 4, 6
    • dog: 2, 6, 10
  • recf - [bool] use the reconstruction factor (Cdelta*psi_0(0))

Output

  • x - [1D numpy array float]

Other functions

See [Torrence98].

mlpy.angularfreq(N, dt)

Compute angular frequencies.

Input

  • N - [integer] number of data samples
  • dt - [float] time step

Output

  • angular frequencies - [1D numpy array float]
mlpy.scales(N, dj, dt, s0)

Compute scales.

Input

  • N - [integer] number of data samples
  • dj - [float] scale resolution
  • dt - [float] time step

Output

  • scales - [1D numpy array float]
mlpy.compute_s0(dt, p, wf)

Compute s0.

Input

  • dt - [float] time step
  • p - [float] omega0 (‘morlet’) or order (‘paul’, ‘dog’)
  • wf - [string] wavelet function (‘morlet’, ‘paul’, ‘dog’)

Output

  • s0 - [float]
[Torrence98](1, 2) C Torrence and G P Compo. Practical Guide to Wavelet Analysis
[Gsldwt]Gnu Scientific Library, http://www.gnu.org/software/gsl/

Table Of Contents

Previous topic

Tutorial

Next topic

Clustering

This Page