Changeset 782 in ETALON


Ignore:
Timestamp:
Jul 11, 2018, 12:25:10 PM (6 years ago)
Author:
moutardier
Message:

correction of issu in print_data.py and add comment

Location:
BPM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BPM/motor_control.py

    r780 r782  
    1010# moteur 2 -> verticale
    1111
     12
     13#motor_reset(2)
     14#motor_disable(2)
     15
     16motor_enable(1)
     17move_motor_absolute(1,5000,-5000)
     18move_motor_absolute(1,5000,0)
     19motor_disable(1)
     20
    1221"""
    13 motor_enable(2)
    14 move_motor_absolute(2,5000,-50000)
    15 while motor_get(1, 'status') != 'READY':
    16     time.sleep(1)
    17 time.sleep(5)
     22for i in range(5):
     23    motor_enable(2)
     24    move_motor_absolute(2,5000,-5000)
     25    while motor_get(2, 'status') != 'READY':
     26        time.sleep(1)
     27    time.sleep(10)
     28
     29
     30    move_motor_absolute(2,5000,0)
     31    while motor_get(2, 'status') != 'READY':
     32        time.sleep(1)
     33    motor_disable(2)
     34    time.sleep(10)
    1835"""
    19 """
    20 move_motor_absolute(2,5000,0)
    21 while motor_get(1, 'status') != 'READY':
    22     time.sleep(1)
    23 """
     36
    2437#controller_hello()
    2538#move_motor_relative(1,1000,-1000)
     
    3750#horizontal_acquisition(4000,0,-4000,"test")   
    3851
    39 acquisition(-100000,100000,20000,-50000,50000,10000,"test")
     52#acquisition(-100000,100000,20000,-50000,50000,10000,"test")
    4053
    4154#acquisition(-10000,10000,1000,-50000,0,5000,"test")
  • BPM/print_datas.py

    r780 r782  
    33from scipy import stats
    44
    5 def float_list(l):
     5def float_list(l): # convert a list of char in a list of float
    66    L = []
    77    for i in l:
     
    99    return(L)
    1010
    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)
     11def product_list(L,x, b = 0): # linear convertion of a list return L*x + b (b is 0 as default)
     12    Lx = []
     13    for i in L:
     14        Lx.append(i*x +b)
     15    return(Lx)
    2216
    2317
    24 def read_data(fichier):
     18def read_data(fichier): # program to read data from a file of data with position of motor and them Va, Vb, Vc and Vd
    2519    fichier = open(fichier, "r")
    26     A = fichier.read()
    27     L = [[],[],[],[],[]]
    28     a = ""
    29     l = 0
    30     for i in A:
     20    Data = fichier.read()
     21    Data_list = [[],[],[],[],[]]
     22    value = ""
     23    index = 0
     24    for i in Data:
    3125        if (i == " ") :
    32             if l == 0:
    33                 L[0].append(a)
    34                 l +=1
    35             elif l == 1:
    36                 L[1].append(a)
    37                 #print(a)
    38                 l += 1
    39             elif l == 2:
    40                 L[2].append(a)
    41                 l += 1
    42             elif l == 3:
    43                 L[3].append(a)
    44                 l += 1
     26            if index == 0:
     27                Data_list[0].append(value)
     28                index +=1
     29            elif index == 1:
     30                Data_list[1].append(value)
     31                #print(value)
     32                index += 1
     33            elif index == 2:
     34                Data_list[2].append(value)
     35                index += 1
     36            elif index == 3:
     37                Data_list[3].append(value)
     38                index += 1
    4539            else:
    46                 L[4].append(a)
    47                 l = 0
    48             a = ""
     40                Data_list[4].append(value)
     41                index = 0
     42            value = ""
    4943        elif (i == "\n") :
    50             a = ""
     44            value = ""
    5145        else:
    52             a += i
     46            value += i
    5347    fichier.close()
    5448    for i in range(5):
    55         L[i] = float_list(L[i])
    56     L[0] = product_list(L[0],10**-6)
     49        Data_list[i] = float_list(Data_list[i])
     50    Data_list[0] = product_list(Data_list[0],10**-6)
    5751    for i in range(1,5):
    58         L[i] = product_list(L[i],1000)
    59     return(L)
     52        Data_list[i] = product_list(Data_list[i],1000)
     53    return(Data_list)
    6054
    6155
    6256
    63 def print_graph(L):
     57def print_graph(L): # program to print graph of data set in a list with [[position][Va][Vb][Vc][Vd]], also do a linear regretion and print the equation
    6458#    a = np.array([L[0][i],L[1][i]] for i in range(len(L[0])))
    6559    fig = plt.figure(1)
     
    8680    plt.show()
    8781
    88 def residu(L):
     82def residu(L): # program to do graph of residu of data give in a list with [[position][Va][Vb][Vc][Vd]]
    8983    fig = plt.figure(1)
    9084    plt.clf()
     
    122116"""
    123117
    124 def min_max(L,mini = None ,maxi = None):
     118def min_max(L,mini = None ,maxi = None): #program to cut a list L = [[position][Va][Vb][Vc][Vd]] with minimum value of position = mini and maximum value of position = maxi
    125119    if mini is None :
    126         mini = -1
     120        mini = L[0][0]
    127121    if maxi is None :
    128         maxi = len(L[0])
    129     i_min = 0
    130     i_max = 0
     122        maxi = L[0][len(L[0])-1]
     123    if mini > maxi:
     124        mini,maxi = maxi,mini
     125    index_list = []
    131126    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]])
     127        if  L[0][i] >= mini and L[0][i] <= maxi :
     128            index_list.append(i)
     129    print(index_list)
     130    return([[L[0][i] for i in index_list],[L[1][i] for i in index_list],[L[2][i] for i in index_list],[L[3][i] for i in index_list],[L[4][i] for i in index_list]])
    139131
    140132
    141 def convertion_step_mm(L,begin_mm,end_mm):
     133def convertion_step_mm(L,begin_mm,end_mm): # length convertion
    142134    begin_step = L[0]
    143135    end_step = L[len(L)-1]
     
    155147   
    156148def print_data(fichier, min = None, max = None):
    157     L = min_max(read_data(fichier),min,max)
     149    L = min_max(read_data(fichier), mini = min, maxi = max)
    158150    print_graph(L)
    159151    #print(L)
     
    163155    residu(L)
    164156
    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)
     157print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3)
     158print_residu("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3)
    167159
    168160#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.