1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
import numpy as np
import matplotlib.pyplot as plt
amp = 18e-3
a = 1/.61e3
b = 5.5
fs=5e6
f0 = fs/2/102
t_min = 0
dt = 1./fs
t_max = (10772) * dt
t = np.arange(t_min,t_max,dt)
x_min = -amp/b
x_max = amp/b
dx = dt*(x_min-x_max)/(t_min-t_max)
x = np.arange(x_min,x_max,dx)
def Lorentzian(xx):
if not hasattr(xx, '__iter__'):
xx = [ xx ]
res = np.zeros(len(xx))
for i in range(len(xx)):
x = xx[i]
if np.fabs(x) < 0.1:
res[i] = 1./3. - x**2/15. + 2.* x**4 / 189. - x**6/675. + 2.* x**8 / 10395. - 1382. * x**10 / 58046625. + 4. * x**12 / 1403325.
else:
res[i] = (1./x**2 - 1./np.sinh(x)**2)
return res
def distrib(x):
res = np.zeros(np.size(x))
res[int(3*np.floor(np.size(x)/5))] = 6
res[int(3*np.floor(np.size(x)/5)+20)] = 6
return res
def mirror(seq):
output = list(seq[::-1])
return output
func1 = lambda x : Lorentzian(b*(x/a))
x_s = lambda t : amp * np.cos(2*np.pi*f0*t)/b
signal = lambda x : np.convolve(distrib(x), func1(x)-func1(x)[0], 'same')
###### Partie importante ######
s_pos = signal(x_s(t[0:102]))
s_neg = mirror(-s_pos)
S_pos = np.fft.fft(s_pos)
S_neg_expected = -np.conjugate(S_pos)
S_neg = np.fft.fft(s_neg)
plt.figure()
plt.plot(S_neg_expected,'r')
plt.plot(S_neg,'b') |
Partager