import numpy as np
import matplotlib.pyplot  as plt
f1=2000
#f1=2005
Ne=1000
fe=10000.
Te=1/fe
Ta=Te*Ne

def s(t):
    return 3*np.cos(2*np.pi*f1*t+np.pi/2)

    
t_ech=np.linspace(0,Ta-Te,Ne)
s_ech=s(t_ech)
C=np.array([1/Ne]+[2/Ne for k in range(Ne//2)])# écrit ainsi, le signe + fait une concaténation
spec=abs(np.fft.rfft(s_ech)*C)

f=np.fft.rfftfreq(Ne,Te)

plt.figure(1)
plt.plot (t_ech,s_ech)

plt.figure(2)
plt.plot(f,spec)

plt.show()
