Changeset 780 in ETALON
- Timestamp:
- Jun 18, 2018, 5:32:04 PM (6 years ago)
- Location:
- BPM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
BPM/motor_control.py
r779 r780 37 37 #horizontal_acquisition(4000,0,-4000,"test") 38 38 39 acquisition(-1 5000,15000,10000,-50000,50000,25000,"test")39 acquisition(-100000,100000,20000,-50000,50000,10000,"test") 40 40 41 41 #acquisition(-10000,10000,1000,-50000,0,5000,"test") … … 55 55 56 56 #fichier = open("24-05-2018_acquisition_from_0_to_400000_step_of_1000.txt", "r") 57 """58 A = fichier.read()59 60 X = []61 Y1 = []62 Y2 = []63 Y3 = []64 Y4 = []65 a = ""66 l = 067 68 69 for i in A:70 if (i == "\n") :71 if l == 0:72 X.append(a)73 74 l += 175 elif l == 1:76 Y1.append(a)77 #print(a)78 l += 179 elif l == 2:80 Y2.append(a)81 l += 182 elif l == 3:83 Y3.append(a)84 l += 185 else:86 Y4.append(a)87 l = 088 a = ""89 else:90 a += i91 92 def float_list(l):93 L = []94 for i in l:95 L.append(float(i))96 return(L)97 98 X = float_list(X)99 Y1 = float_list(Y1)100 Y2 = float_list(Y2)101 Y3 = float_list(Y3)102 Y4 = float_list(Y4)103 104 plt.plot(X,Y1)105 plt.plot(X,Y2)106 plt.plot(X,Y3)107 plt.plot(X,Y4)108 plt.show()109 """110 57 111 58 #fichier.close() -
BPM/print_datas.py
r779 r780 9 9 return(L) 10 10 11 def product_list(L,x): 12 Lx = [] 13 for i in L: 14 Lx.append(i*x) 15 return(Lx) 11 def product_list(L,x, b = None): 12 if b is None: 13 Lx = [] 14 for i in L: 15 Lx.append(i*x) 16 return(Lx) 17 else: 18 Lx = [] 19 for i in L: 20 Lx.append(i*x +b) 21 return(Lx) 16 22 17 23 … … 46 52 a += i 47 53 fichier.close() 48 49 54 for i in range(5): 50 55 L[i] = float_list(L[i]) … … 62 67 lr1 = stats.linregress(L[0],L[1]) # return tuple (pente,ordonnee a l'origine, coef de correlation, p-value, erreur standard de l'estimation) 63 68 plt.plot(L[0],L[1], "r", label = "BMP_ref") 64 plt.plot(L[0],[lr1.slope*i + lr1.intercept for i in L[0]], "r--", label = "BMP_ref regression line, \nerror = "+str( lr1.stderr)+",\ncorrelation coefficient = "+str(lr1.rvalue))69 plt.plot(L[0],[lr1.slope*i + lr1.intercept for i in L[0]], "r--", label = "BMP_ref regression line, \nerror = "+str(round(lr1.stderr,3))+",\ncorrelation coefficient = "+str(round(lr1.rvalue,3))) 65 70 66 71 lr2 = stats.linregress(L[0],L[2]) 67 72 plt.plot(L[0],L[2], "b", label = "BMP_impr") 68 plt.plot(L[0],[lr2.slope*i + lr2.intercept for i in L[0]], "b--", label = "BMP_impr regression line, \nerror = "+str( lr2.stderr)+",\ncorrelation coefficient = "+str(lr2.rvalue))73 plt.plot(L[0],[lr2.slope*i + lr2.intercept for i in L[0]], "b--", label = "BMP_impr regression line, \nerror = "+str(round(lr2.stderr,3))+",\ncorrelation coefficient = "+str(round(lr2.rvalue,3))) 69 74 70 75 lr3 = stats.linregress(L[0],L[3]) 71 76 plt.plot(L[0],L[3], "g", label = "BMP_ref") 72 plt.plot(L[0],[lr3.slope*i + lr3.intercept for i in L[0]], "g--", label = "BMP_ref regression line, \nerror = "+str( lr3.stderr)+",\ncorrelation coefficient = "+str(lr3.rvalue))77 plt.plot(L[0],[lr3.slope*i + lr3.intercept for i in L[0]], "g--", label = "BMP_ref regression line, \nerror = "+str(round(lr3.stderr,3))+",\ncorrelation coefficient = "+str(round(lr3.rvalue,3))) 73 78 74 79 lr4 = stats.linregress(L[0],L[4]) 75 80 plt.plot(L[0],L[4], "m", label = "BMP_impr") 76 plt.plot(L[0],[lr4.slope*i + lr4.intercept for i in L[0]], "m--", label = "BMP_impr regression line, \nerror = "+str( lr4.stderr)+",\ncorrelation coefficient = "+str(lr4.rvalue))81 plt.plot(L[0],[lr4.slope*i + lr4.intercept for i in L[0]], "m--", label = "BMP_impr regression line, \nerror = "+str(round(lr4.stderr,2))+",\ncorrelation coefficient = "+str(round(lr4.rvalue,3))) 77 82 78 83 plt.legend() … … 92 97 lr2 = stats.linregress(L[0],L[2]) 93 98 for i in range(len(L[2])): 94 L[2][i] = L[2][i] - lr 1.slope*L[0][i] - lr1.intercept99 L[2][i] = L[2][i] - lr2.slope*L[0][i] - lr2.intercept 95 100 plt.plot(L[0],L[2], "b", label = "BMP_impr") 96 101 97 102 lr3 = stats.linregress(L[0],L[3]) 98 103 for i in range(len(L[3])): 99 L[3][i] = L[3][i] - lr 1.slope*L[0][i] - lr1.intercept104 L[3][i] = L[3][i] - lr3.slope*L[0][i] - lr3.intercept 100 105 plt.plot(L[0],L[3], "g", label = "BMP_ref") 101 106 102 107 lr4 = stats.linregress(L[0],L[4]) 103 108 for i in range(len(L[4])): 104 L[4][i] = L[4][i] - lr 1.slope*L[0][i] - lr1.intercept109 L[4][i] = L[4][i] - lr4.slope*L[0][i] - lr4.intercept 105 110 plt.plot(L[0],L[4], "m", label = "BMP_impr") 106 111 plt.legend() … … 116 121 plt.show() 117 122 """ 118 def print_data(fichier): 119 L = read_data(fichier) 123 124 def min_max(L,mini = None ,maxi = None): 125 if mini is None : 126 mini = -1 127 if maxi is None : 128 maxi = len(L[0]) 129 i_min = 0 130 i_max = 0 131 for i in range(len(L[0])): 132 if L[0][i] <= mini : 133 i_min = i 134 if L[0][i] <= maxi : 135 i_max = i 136 if i_max < len(L[0]) : 137 i_max += 1 138 return([L[0][i_min:i_max],L[1][i_min:i_max],L[2][i_min:i_max],L[3][i_min:i_max],L[4][i_min:i_max]]) 139 140 141 def convertion_step_mm(L,begin_mm,end_mm): 142 begin_step = L[0] 143 end_step = L[len(L)-1] 144 a = float((end_mm - begin_mm))/(end_step - begin_step) 145 b = begin_mm - a*begin_step 146 print(a,b) 147 print(L) 148 L = product_list(L, a, b) 149 return(L) 150 151 152 #L = [[i for i in range(51)] for j in range(5)] 153 #print(convertion_step_mm(L[0],3.1,44520)) 154 155 156 def print_data(fichier, min = None, max = None): 157 L = min_max(read_data(fichier),min,max) 120 158 print_graph(L) 159 #print(L) 121 160 122 def print_residu(fichier ):123 L = read_data(fichier)161 def print_residu(fichier, min = None, max = None): 162 L = min_max(read_data(fichier), mini = min, maxi = max) 124 163 residu(L) 125 164 126 print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt")127 print_residu("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt")165 #print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3) 166 #print_residu("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3) 128 167 129 168 #print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_163036_0.txt")
Note: See TracChangeset
for help on using the changeset viewer.