Open ashayk opened 6 years ago
Hi Alex,
You'll have to use Continuous Wavelet Transform to perform time frequency analysis. Here is the wavelib example code using El Nino data.
https://github.com/rafat/wavelib/wiki/CWT-Example-Code
You can run the code in your browser here.
https://rafat.github.io/wavelib/index.html
Choose CWT -> Test Signals (El Nino Data) and then use the values from CWT example code to plot the time-scale , time-period and time-frequency plots.
Matlab also has a very good tutorial comparing STFT and CWT time-frequency analysis.
Hope this helps. Let me know if there are any issues with running the code.
Rafat
On 6/18/18, ashayk notifications@github.com wrote:
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
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rafat/wavelib/issues/10
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.
cwt output w is a complex number . abs(w)^2 is the square of the absolute value.
On Wed, Oct 13, 2021 at 11:32 PM chromafunk @.***> wrote:
Hi @rafat https://github.com/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
j are the sample bins, scale is the scale result, period is the sampled period ... but what is ABS(w)^2 ?
Also, in the online test app we can get scale, frequency and period, but how do you get these separated outputs ? I have read the documentation pdf but I can't find how, any guidance would help ! Thank you very much
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rafat/wavelib/issues/10#issuecomment-942577631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3RO3VPHHLKSKJ5QVDE4LUGXCULANCNFSM4FFOWAIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
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 !
This seems correct but it is better if you check the code to see if the numerators and denominators are accurate.
https://github.com/rafat/wavelib/blob/master/src/cwt.c
wave-function calculates period.
On Thu, Oct 14, 2021 at 5:42 AM chromafunk @.***> wrote:
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 !
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rafat/wavelib/issues/10#issuecomment-942813116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3ROZ23UHMOFK4VNOHZL3UGYN5VANCNFSM4FFOWAIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
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
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