Code Monkey home page Code Monkey logo

Comments (10)

jaidevd avatar jaidevd commented on August 18, 2024 2

Hi @hbake001 @WRAR891

I'm able to reproduce this and this is indeed a bug in the instantaneous frequency estimation. @WRAR891 in your example, the input is not an analytic signal, and those are required for instantaneous frequencies to be well defined. Converting your signal into an analytic one with the scipy.signal.hilbert function should produce a better, more meaningful results - but they would still not be perfect. Give me a couple of days and I'll get this fixed.

Thanks

from pyhht.

WRAR891 avatar WRAR891 commented on August 18, 2024

I, too, have questions about how to interpret the results of utils.inst_freq(). I tried

f, ts = utils.inst_freq(np.sin(2.0 * np.pi *10.0 * t))
plt.xlabel('Ts')
plt.ylabel('Freq')
plt.plot(ts, f)
plt.show()

and get an unexpected result. Clearly, the inst. freq should be a constant value for this. Is there some usage detail that is being overlooked?

figure_1

from pyhht.

hbake001 avatar hbake001 commented on August 18, 2024

@WRAR891 I think it's a major bug in this package. Waiting the confirmation from the author

from pyhht.

jaidevd avatar jaidevd commented on August 18, 2024

Thanks for pointing this out, @hbake001 and @WRAR891

This implementation of instantaneous frequency detection was adapted from the MATLAB toolbox for time frequency analysis - http://tftb.nongnu.org/

I don't think it is meant to work with IMFs at all, since the definition of the instantaneous frequency of an IMF is the derivative of the arctan of the Hilbert transform of the IMF. I'll dig deeper into this over the weekend.

from pyhht.

jaidevd avatar jaidevd commented on August 18, 2024

@WRAR891 As I said earlier, the problem was the analyticity of the signal. Converting the input to an analytical signal seems to be giving reasonable, almost identical results in both MATLAB and pyhht. Here are the instantaneous frequency plots for your specific example,

MATLAB:
matlab_inst_freq

pyhht
figure_1

@hbake001 Can you provide an example so I can debug your problem? Also please mention which MATLAB package you are using to generate instantaneous frequencies.

Thanks,

from pyhht.

WRAR891 avatar WRAR891 commented on August 18, 2024

@jaidevd, @hbake001

I agree, that for analytical or complex-valued signals, inst_freq() appears to give a reasonable result. One could compare it to:
1.0 / (2.0 * np.pi) * np.diff(np.unwrap(np.angle(m)))

where m is a mode expressed as the hilbert xform of a real-valued signal.
Note: if the mode itself is complex-valued, one does not need to hilbert-transform it.

from pyhht.

atilileri avatar atilileri commented on August 18, 2024

Hi everyone,
I am also trying to get instant frequencies from my signal, I tried using hilbert() to convert my signal to analytic one but, I believe I am missing something, somewhere. My result looks like below:
image
And below is my codepiece:
https://github.com/atilileri/Thesis01/blob/master/insFrqPyhht.py

Am I doing something wrong?
Thanks in advance.

from pyhht.

jaidevd avatar jaidevd commented on August 18, 2024

Hi @atilileri

I looked at your code, and it appears that you're reading an audio file and converting the waveforms into an analytic signal using scipy.signal.hilbert. However, please note that the analyticity of the signal alone does not guarantee well behaved instantaneous frequency. For that to happen, two conditions must be met:

  1. Signal must be an IMF
  2. Signal should be analytic.

In your script, it doesn't look like you have done anything to decompose the signal into purely amplitude/frequency modulated modes. Without that, there is no reason to expect the instantaneous frequency calculation to be meaningful.

Hope this helps.

from pyhht.

atilileri avatar atilileri commented on August 18, 2024

Hi again,

As you said; I extracted imfs from the original signal and then applied hilbert(), got better results. Adding a sample screenshot for reference. Hope it helps some more googlers like me :). Thanks for the help again @jaidevd
image
And below is my codepiece again:
https://github.com/atilileri/Thesis01/blob/master/insFrqPyhht.py

from pyhht.

DuanHaiyang525 avatar DuanHaiyang525 commented on August 18, 2024

Hi,
Why could not I find the method about instantaneous frequencies?

from pyhht.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.