Commit 81a89683 authored by MigAP's avatar MigAP

first functional FFT analysis of the data

parent e4636c23
...@@ -145,18 +145,22 @@ On possède des données toutes les semaines. ...@@ -145,18 +145,22 @@ On possède des données toutes les semaines.
# Conversion of the data to numpy array # Conversion of the data to numpy array
co2 = np.array(concentration) co2 = np.array(concentration)
#Remove mean value
co2 = co2 - np.mean(co2)
# Concentration FFT # Concentration FFT
concentrationFFT = np.fft.fft(co2) concentrationFFT = np.fft.fft(co2)
# We take the norm of the FFT # We take the norm of the FFT
concentrationFFTNorm = np.absolute(concentrationFFT) concentrationFFTNorm = np.absolute(concentrationFFT)
concentrationFFTAngle = np.angle(concentrationFFT)
# Frequency axis # Frequency axis
N = co2.shape[0] # Number of samples N = co2.shape[0] # Number of samples
Te = 1 # Sampling interval Te = 1 # Sampling interval
t = np.arange(N) # time reference t = np.arange(N) # time reference
freq = np.arange(N)/(N*Te) #freq = np.arange(N)/(N*Te)
#freq = np.fft.fftfreq(N) freq = np.fft.fftfreq(N)*N*(1/N*Te)
plt.figure(figsize=(10,5)) plt.figure(figsize=(10,5))
...@@ -169,3 +173,106 @@ On possède des données toutes les semaines. ...@@ -169,3 +173,106 @@ On possède des données toutes les semaines.
#+RESULTS: #+RESULTS:
[[file:dataFFT.png]] [[file:dataFFT.png]]
** FFT zoom
On effectue un zoom sur la partie positive du graphique pour tenter de
caractériser les différérentes fréquences d'oscillations du signal.
#+begin_src python :results file :session :var matplot_lib_filename="fftZoom.png" :exports both
startIndx = 10
fftzoomIndx = int(N/6)
plt.figure(figsize=(10,5))
plt.plot(freq[startIndx:fftzoomIndx],concentrationFFTNorm[startIndx:fftzoomIndx])
plt.tight_layout()
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:fftZoom.png]]
On remarque que les "petites" oscillations ont une amplitude
d'environ 1400. On tentera de filtrer donc le signal au dessus de ce
seuil.
** Filtrage des grandes oscillations
On élimine toutes les valeurs au dessus du seuil établit précédemment.
#+begin_src python :results file :session :var matplot_lib_filename="smallOsillations.png" :exports both
# Extraction of the small oscillations
smallAmplitude = 1400
smallNorm = np.copy(concentrationFFTNorm)
smallNorm[smallNorm > smallAmplitude] = 0
plt.figure(figsize=(10,5))
plt.plot(freq,smallNorm)
#plt.plot(freq[startIndx:fftzoomIndx],small[startIndx:fftzoomIndx])
plt.tight_layout()
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:smallOsillations.png]]
** Reconstruction du signal : petites oscillations
#+begin_src python :results file :session :var matplot_lib_filename="smallOsillationsTime.png" :exports both
smallFreqSignal = smallNorm*np.exp(1j*concentrationFFTAngle)
smallSignal = np.fft.ifft(smallFreqSignal)
smallSignal = np.real(smallSignal)
plt.figure(figsize=(10,5))
plt.plot(t,smallSignal)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:smallOsillationsTime.png]]
** Filtrage des petites oscillations
On élimine toutes les valeurs au dessus du seuil établit précédemment.
#+begin_src python :results file :session :var matplot_lib_filename="bigOsillations.png" :exports both
# Extraction of the big oscillations
bigAmplitude = 1400
bigNorm = np.copy(concentrationFFTNorm)
bigNorm[bigNorm < bigAmplitude] = 0
plt.figure(figsize=(10,5))
plt.plot(freq,bigNorm)
#plt.plot(freq[startIndx:fftzoomIndx],big[startIndx:fftzoomIndx])
plt.tight_layout()
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:bigOsillations.png]]
** Reconstruction du signal : grandes oscillations
#+begin_src python :results file :session :var matplot_lib_filename="bigOsillationsTime.png" :exports both
bigFreqSignal = bigNorm*np.exp(1j*concentrationFFTAngle)
bigSignal = np.fft.ifft(bigFreqSignal)
bigSignal = np.real(bigSignal)
plt.figure(figsize=(10,5))
plt.plot(t,bigSignal)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:bigOsillationsTime.png]]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment