import numpy as np
import matplotlib.pyplot as plt
import math
import os
import bim as USTk
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import hilbert, chirp
DATFile = "NP4"
DATA = np.load(DATFile+".npz")
Image, rawSignal = DATA['arr_1'], DATA['arr_0']
np.shape(rawSignal)
(5000000,)
N = 450
line = rawSignal[N*5000:(N+1)*5000]
plt.plot(line)
plt.show()
lol = np.fft.fft(line)
plt.plot(np.real(lol),"g")
plt.plot(np.imag(lol),"r")
plt.show()
line2 = lol
for i in range(len(line2)/2+3):
if i < 350 or i > 1300:
line2[i] = 0
line2[-i] = 10
plt.plot(np.real(line2),"g")
plt.plot(np.imag(line2),"r")
plt.show()
line3 = np.fft.ifft(line2)
plt.plot(np.real(line3[2350:2550]),"g")
plt.plot(np.real(line[2350:2550]),"r")
plt.show()
lineU = np.real(line3)
analytic_signal = hilbert(lineU)
amplitude_envelope = np.abs(analytic_signal)
plt.plot((analytic_signal[2350:2550]),"g")
plt.plot((amplitude_envelope[2350:2550]),"b")
plt.plot(np.real(line[2350:2550]),"r")
plt.show()
plt.plot(np.real(line),"y")
plt.plot((analytic_signal),"g")
plt.plot((amplitude_envelope),"b")
plt.show()