# How to calculate the instantaneous frequency for one specfic signal?

I have a signal which like this: I want to calculate this signal's instantaneous frequency.I have tried hht and so on which method I can find but can not get the result. So does somebody can give me some advice? If can proveide some python program which will be must useful for me.Thanks!

UPDATED: Thanks @OverLordGoldDragon I use this code in this answer:

import numpy as np
from ssqueezepy import ssq_cwt, extract_ridges
from ssqueezepy.visuals import plot, imshow

# z = see OP's code; used np.random.seed(1000)

beta = 24
Tx, Wx, ssq_freqs, scales, *_ = ssq_cwt(z, ('gmw', {'beta': beta}), padtype='zero', fs=6)
ridge_idxs = extract_ridges(Tx, scales, penalty=20)

plot(ridge_idxs, color='k', linestyle='--', xlims=(0, len(z) - 1))
imshow(Tx, abs=1, yticks=ssq_freqs[::-1], ylabel="Frequencies [Hz]",
title="abs(SSQ_CWT), wavelet=('gmw', {'beta': %s})" % beta)
amplitude = np.abs(Tx[ridge_idxs[:, 0], np.arange(len(z))])
frequencies = ssq_freqs[::-1][ridge_idxs[:, 0]]

plot(amplitude, ylims=(0, None), title="Amplitude vs time, SSQ ridge", show=1)
plot(frequencies, ylims=(0, None), ylabel="Frequencies [Hz]",
title="Frequency vs time, SSQ ridge", show=1)


But my result like this: Which seems disorder.

from ssqueezepy import TestSignals, ssq_cwt
from ssqueezepy.visuals import plot, imshow

x = TestSignals(N=2048).lchirp()[0]
Tx, _, ssq_freqs, *_ = ssq_cwt(x)
plot(x, title="linear chirp", show=1)
imshow(Tx, abs=1, title="abs(SSQ_CWT)", xlabel="time", ylabel="frequency",
yticks=ssq_freqs[::-1])

• Thanks for you help! Dose ssqueezepy has some docs? I'm a newer for signal processing. I want to know which is the result of signal's instantaneous frequency and how to use this. Thanks again! Jun 17, 2021 at 1:53
• @user57947 Every library function is documented, e.g. help(ssq_cwt). There's lots of reference material in the README, including this overview, and examples. For choosing wavelet parameters, see here. Jun 17, 2021 at 2:13
• @user57947 There's also learning resources ("DSP Fundamentals"), beginner friendly. Jun 17, 2021 at 2:18
• Thanks,I think what I need may be in Tx, But I found Tx is a multi dimension array. So what dimension is the instantaneous frequency? Jun 17, 2021 at 3:35
• @user57947 dim0 is frequency, dim1 is time. If you prefer a 1D array, can be done with ridge extraction - see this answer. Jun 17, 2021 at 3:59