rafat / wavelib

C Implementation of 1D and 2D Wavelet Transforms (DWT,SWT and MODWT) along with 1D Wavelet packet Transform and 1D Continuous Wavelet Transform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

time frequency analysis

ashayk opened this issue · comments

Hi,

Apologies, I sent the email below already, but just thought I'd repost here for others. I'm hoping you might be able to provide an example of time-frequency analysis using wavelib. Thanks.

I've come across your wavelib project and it looks really cool. I'm not terribly familiar with wavelets outside of what I've used with Matlab for time-frequency analysis. I typically do this with STFT in C, but would like to see if I can use wavelib for that as well. I've looked through the demos, but didn't see anything immediately obvious with which I could do a spectral decomposition. Would you be able to provide me with some guidance on doing time-frequency analysis with wavelib? I'd very much appreciate the help.

Thanks,

--Alex

Hi @rafat , thank you for this library ! I am also interested on doing some experiments with real time data, and trying to use the library. My problem is that I am not sure of the total of the outputs that the CWT gives.

when I run the demo I get this :

j              Scale          Period         ABS(w)^2        
0              0.250000       0.258261       0.044181        
1              0.297302       0.307126       1.140611        
2              0.353553       0.365236       22.612155       
3              0.420448       0.434341       236.000960      
4              0.500000       0.516522       750.555613      
5              0.594604       0.614251       272.558792      
6              0.707107       0.730472       65.406557       
7              0.840896       0.868683       661.907029      
8              1.000000       1.033044       1590.717326     
9              1.189207       1.228503       623.593524      
10             1.414214       1.460944       156.254372      
11             1.681793       1.737365       317.761119      
12             2.000000       2.066087       401.100893      
13             2.378414       2.457006       318.397824      
14             2.828427       2.921889       269.638035      
15             3.363586       3.474731       2.999744        
16             4.000000       4.132175       1579.680775     
17             4.756828       4.914011       4318.945007     
18             5.656854       5.843777       2501.997548     
19             6.727171       6.949462       566.284186      
20             8.000000       8.264349       636.197879      
21             9.513657       9.828023       603.262260      
22             11.313708      11.687555      201.174291      
23             13.454343      13.898923      257.993096      
24             16.000000      16.528698      301.898877      
25             19.027314      19.656046      349.147914      
26             22.627417      23.375109      321.394832      
27             26.908685      27.797846      514.251514      
28             32.000000      33.057397      638.538828      
29             38.054628      39.312091      322.292455      
30             45.254834      46.750219      157.413156      
31             53.817371      55.595693      311.426801      
32             64.000000      66.114793      392.982432      
33             76.109255      78.624183      148.883971      
34             90.509668      93.500438      203.412015      
35             107.634741     111.191386     435.336832      
36             128.000000     132.229587     469.408336      
37             152.218511     157.248366     343.498364      
38             181.019336     187.000875     180.679727      
39             215.269482     222.382771     65.307551       
40             256.000000     264.459174     69.525971       
41             304.437021     314.496731     78.369819       
42             362.038672     374.001750     92.867511       
43             430.538965     444.765542     124.686172      

Another edit, I see now that frequency is not included in the calculations.

Thanks ! Just another couple of questions :
can you confirm that to get frequency as in your online app, we do it like this :

        double Fb;
        double Fc = 0.8125;
        vector<double> frequency;

        for (int v = 0; v < N; ++v)
        {
            Fb = dt * Fc / wt->scale[v];
            frequency.push_back(Fb);
        }

Also, do you think I can thread the computation on C++ without much problems ? Thank you again !

Hi @rafat, as far as I understand, following and comparing the test against the online app with "el nino" dataset, the results at
wt->scale and wt->period are the Y / scale or period values. But how do you access the Z binned values present on your online app ? Sorry but I don't understand how are you getting the output, can't see it anywhere in the docs either. Then probably the frequency result is not correctly calculated either, since I am iterating over the entire N / X range ? Thank you very much