# Get Hilbert marginal spectrum with emd package in python

I want to get the Marginal Hilbert Spectrum in Python using the emd package.

You can estimate the Marginal Hilbert Spectrum as and A(ω,t) is the time-dependent amplitude modulation and ω the time-dependent instantaneous frequency.

The code I am using:

### create a random array of 3600 dates for MRE ###
np.random.seed(0)
rng = pd.date_range('2015-02-24', periods=3600, freq='s')
df  = pd.DataFrame({ 'DateTime': rng, 'B': np.random.randn(len(rng)) })
df  = df.set_index('DateTime')

### Get the IMF's ###

dt     = (df.index-df.index)/np.timedelta64(1,'s')   #
T      = 3600
start1 = 0

### By doing this you get the IMF's ###
imf = emd.sift.sift(df.B.values, max_imfs=50)

## This gives you the 1) instantaneous phase IP
##                    2) instantaneous frecuency IP
##                    3) instantaneous amplitude
IP, IF, IA = emd.spectra.frequency_transform(imf, dt, 'nht')

H = IA**2

spec = [ ]
for i in range(len(IF)):
spec.append((1/T)*np.nansum(H[i][:])*dt)

plt.plot(np.sort(IF[:, 0]),spec)


The result I am getting is totaly wrong, any help?

The paper I am reading to understand the Hilbert-Huang transform is this one:

https://www.mdpi.com/2218-1997/6/8/116/htm