English: Graph showing how envelope (in red) and phase (black dots, for zero crossings) of a signal can be simply derived with the Hilbert Transform.
The corresponding python code is:
importnumpyasnpimportscipy.signalimportmatplotlib.pyplotasmpimportmatplotlib.mlabasmm# Create a function for the instantaneous frequency ...dt=0.01t=np.arange(0,20,dt)f=(0.2+1.3*np.exp(-((t-10)/4)**2))# ... and envelopeenv=2-f/2# Plot the corresponding function valuesdf=2*np.pi*f*dtfsum=np.cumsum(df)x=np.sin(fsum)*env# Using the Hilbert transform, find the envelope and zero crossingsenvelope=abs(scipy.signal.hilbert(x))phase=np.angle(scipy.signal.hilbert(x))zeroCrossing=mm.find(np.diff(np.sign(np.cos(phase)))==2)# Plot the resultsmp.plot(x)mp.hold('on')mp.plot(envelope,'r')mp.plot((0,2000),(0,0),'k--')mp.plot(zeroCrossing,np.zeros(zeroCrossing.size),'ko')mp.ylim((-2,2.2))mp.savefig('hilbert.eps')mp.show()
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.