Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
d682078cda52034c5c9de3f5af638a6f
mooc-rr
Commits
81a89683
Commit
81a89683
authored
Nov 25, 2020
by
MigAP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first functional FFT analysis of the data
parent
e4636c23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
3 deletions
+110
-3
exercice_python_fr.org
module3/exo3/exercice_python_fr.org
+110
-3
No files found.
module3/exo3/exercice_python_fr.org
View file @
81a89683
...
@@ -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]]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment