Skip to content
Rafat Hussain edited this page May 28, 2016 · 1 revision

Continuous Wavelet Transform Class ( cwt )

cwt Initialization

cwt_object cwt_init(wave,param,N,dt,J);


// wave - Wavelet name. One of “morl”,”paul” or “dog”
// param – parameter associated with the wavelet. See below
// N - Length of Signal/Time Series
// dt – Sampling Rate
// J – Total Number of Scales

“morl” : Morlet Family of Wavelets accept real, positive parameter values(“param”). Value 6.0 is used in the example and values between 4.0-6.0 are typically used.

“paul” : Paul Wavelets accept positive integer values <= 20. Default Value is 4.

“dog” : Derivative of Gaussian Wavelets accepts positive even integer values. Param = 2 is the Mexican Hat Wavelet.

cwt Execution

cwt(wt, inp); // Continuous Wavelet Transform
// obj - cwt object
// inp – Input signal/ Time series of length N



icwt Execution

icwt(wt, cwtop); // Inverse Continuous Wavelet Transform
// obj - cwt object
// cwtop – ICWT output


cwt object parameters

wave_object wave; // wavelet object
char *wave; // Wavelet - “morl”/”morlet”,”paul” or “dog”/”dgauss”
int siglength;// Length of the original signal.
double s0;// Smallest scale. Typically s0 <= 2 * dt 
int J; // Total Number of Scales
double dt; // Sampling Rate
char type[10];// Scale Type - “pow” or “linear”
int pow; // Base of power if scale type = “pow”. Default pow = 2
double dj; // Separation between Scales. eg., scale = s0 * 2 ^ ( [0:N-1] *dj) or scale = s0 * [0:N-1] * dj
double m; // Wavelet parameter param
double smean; // Signal Mean
cplx_data *output; // CWT Output Vector of size J * siglength. The vector is complex. The ith real value can be accessed wt->output[i].re and imaginary value by wt->output[i].im
double *scale; // Scale vector of size J
double *period; // Period vector of size J
double *coi; // Cone of Influence vector of size siglength



Setting CWT Scale Vector

There are two ways of setting Scale Parameters. The first method is straightforward and should be used if the scales are linear or power-of-N.

void setCWTScales(cwt_object wt, double s0, double dj,char *type,int power)

The cwt_object needs to initialized first. s0 is the smallest scale, while dj is the separation between scales. Dj can also be seen as a measure of resolution which is calculated as dj = 1.0 / Number of subscales so smaller value of dj corresponds to higher resolution within a scale. type accepts “pow”/”power” or “lin”/”linear” as input values, power is the base of power if “pow”/”power' is selected and is ignored if the input is “lin”. Power of N scale calculation.

for (i = 0; i < wt->J; ++i) { wt->scale[i] = s0*pow((double) power, (double)(i)*dj); }

Linear Scale calculation

for (i = 0; i < wt->J; ++i) { wt->scale[i] = s0 + (double)i * dj; }

Custom Scale vector can be set using.

void setCWTScaleVector(cwt_object wt, double *scale, int J,double s0,double dj)

In this case the vector scale of size J is input by the user.

Inverse CWT and Approximate Reconstruction

The approximate reconstruction is achieved using the delta method suggested by Daubechies and used by Terrence and Compo in their CWT implementation (See the references). This implementation explicitly calculates Cdelta, instead of using interpolation tables, every time icwt is calculated. There is a higher computation cost associated with this method but it should give better approximation if proper s0 and J are selected. Anything under 0.01 is usually acceptable. Use a smaller s0 and larger J if the RMS reconstruction error is > 0.01.

References

Compo, G P and Torrence, C, 1998, A Practical Guide to Wavelet Analysis, Bulletin of The American Meteorological Society,79,1, 61-78

Bishop, M, Continuous Wavelet Transform Reconstruction Factors for Selected Wavelets.

Daubechies, I., 1992, Ten Lectures on Wavelets. Society for Industrial and Applied Mathematics.

Farge, M., 1992, Wavelet Transforms and Their Applications to Turbulence, Annual Review of Fluid Mechanics, 24, 395-457