# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
from pyhht.visualization import plot_imfs
import numpy as np
from pyhht.emd import EMD
import matplotlib.pyplot as plt
from tftb.generators import fmconst
from scipy import angle, unwrap
from scipy.signal import hilbert

t = np.linspace(0, 10, 100)
modes = np.cos(2 * 3.14 * 50 * t) + np.cos(2 * 3.14 * 100 * t)
x = modes + t
decomposer = EMD(x)
imfs = decomposer.decompose()
plot_imfs(x, imfs, t);
print('%.3f' % decomposer.io())

hs4 = hilbert(imfs[0])
plt.plot(t, imfs[0], 'b')
#plt.plot( np.imag(hs4),np.real(hs4), 'b')
omega_imfs_zero = unwrap(angle(hs4)) # unwrapped instantaneous phase
f_inst_imfs_zero = np.diff(omega_imfs_zero) # instantaneous frequency
#plt.plot(t[1:], f_inst_imfs_zero, "b")

hs5 = hilbert(imfs[1])
plt.plot(t, imfs[1], 'g')
#plt.plot( np.imag(hs5),np.real(hs5), 'g')
omega_imfs_one = unwrap(angle(hs5)) # unwrapped instantaneous phase
f_inst_imfs_one = np.diff(omega_imfs_one) # instantaneous frequency
#plt.plot(t[1:], f_inst_imfs_one, "g")
plt.show()

# +

x = np.linspace(0, 2 * np.pi, 1000)

s1=np.sin(x)
s2=np.sin(2*x)

hs1 = hilbert(s1)
hs2 = hilbert(s2)

plt.plot(x, s1, 'b')
plt.plot(x, s2, 'g')

plt.plot( np.imag(hs1),np.real(hs1), 'b')
plt.plot( np.imag(hs2),np.real(hs2), 'g')

omega_s1 = unwrap(angle(hs1)) # unwrapped instantaneous phase
omega_s2 = unwrap(angle(hs2)) # unwrapped instantaneous phase

f_inst_s1 = np.diff(omega_s1) # instantaneous frequency
f_inst_s2 = np.diff(omega_s2) # instantaneous frequency

plt.plot(x[1:], f_inst_s1, "b")
plt.plot(x[1:], f_inst_s2, "g")

plt.show()
# -



plt.plot(t, imfs[0], 'b')

plt.plot(t, imfs[1], 'g')

plt.plot(t, imfs[2], 'r')

# +
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
import numpy

x=numpy.array([1,2,3,4,5])
y=numpy.array([5,4,7,1,7])
r=numpy.array([0.1,0.6,0.4,1.0,0.3])

fig = plt.figure(figsize=(7,5))
ax = Axes3D(fig)

# plot data
line1 = ax.plot(x,y,r,'ok')

#modify axes
ax.set_xlim(0,6)
ax.set_ylim(0,8)
ax.minorticks_on()
ax.tick_params(axis='both',which='minor')
ax.tick_params(axis='both',which='major')

#display 
plt.show()


# +
from mpl_toolkits import mplot3d
# %matplotlib inline
import numpy as np
import matplotlib.pyplot as plt


def f(x, y):
    return np.sin(np.sqrt(x ** 2 + y ** 2))

x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)

X, Y = np.meshgrid(x, y)
Z = f(X, Y)

fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(X, Y, Z, 50, cmap='binary')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z');
# -

Axes3D.plot_surface(X, Y, Z, *args, **kwargs)

# +

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

X = np.array(abs(f_inst_imf_one[1:1140]))

Y = np.array(a1[1:1140])

Z = np.array(10000000*pxx_den[1:1140])

x = np.reshape(X, (9, 12))
y = np.reshape(Y, (9, 12))
z = np.reshape(Z, (9, 12))


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.plot_surface(x, y, z)

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()
# -

import numpy as np
import pylab as pl
rate = 30.0
t = a1
x = IMF[0],
p = 20*np.log10(np.abs(np.fft.rfft(x)))
f = np.linspace(0, rate/2, len(p))
plt.plot(f, p)






















StarcoderdataJupyterScriptsDedupFiltered