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
|
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import csv
from scipy.signal import argrelextrema
data_laser = pd.read_csv("C:\\Users\\Utilisateur général\\Desktop\\SCOPE_1.csv")
col_names = ['time','amp']
data_laser.columns = col_names
t = data_laser.time
y = data_laser.amp
L1=[]
L2=[]
Ly=[]
Lt=[]
x=np.zeros(len(y))
for i in range(len(y)):
x[i]=y[i]
c_max_index = argrelextrema(x, np.greater, order=10)
for i in range(np.size(c_max_index[0])):
if y[c_max_index[0][i]]>0.001:
L1.append(y[c_max_index[0][i]])
L2.append(t[c_max_index[0][i]])
for i in range(len(L1)):
if i<40:
Ly.append(L1[i])
Lt.append(L2[i])
else:
if L1[i]>0.002: # La valeur du seuil est relative aux données, à modifier selon le cas
Ly.append(L1[i])
Lt.append(L2[i])
# visualiser les points sélectionnés
plt.scatter(Lt,Ly,c='r')
plt.plot(t,y)
plt.grid()
plt.ylim(0,0.1)
plt.show()
with open("C:\\Users\\Utilisateur général\\Desktop\\SCOPE_1n.csv", 'w',newline='') as csvfile:
filewriter = csv.writer(csvfile, delimiter=',',quotechar='|', quoting=csv.QUOTE_MINIMAL)
filewriter.writerow(['time' , 'ampl'])
for i in range(len(Ly)):
filewriter.writerow([Lt[i],Ly[i]]) |
Partager