Changeset 779 in ETALON for BPM/print_datas.py


Ignore:
Timestamp:
Jun 15, 2018, 2:13:45 PM (6 years ago)
Author:
moutardier
Message:

add fonction to print residu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BPM/print_datas.py

    r777 r779  
    1616
    1717
    18 def print_data(fichier):
     18def read_data(fichier):
    1919    fichier = open(fichier, "r")
    2020    A = fichier.read()
     
    5252    for i in range(1,5):
    5353        L[i] = product_list(L[i],1000)
    54     print_graph(L)
     54    return(L)
     55
     56
    5557
    5658def print_graph(L):
    57     a = np.array([L[0][i],L[1][i]] for i in range(len(L[0])))
     59#    a = np.array([L[0][i],L[1][i]] for i in range(len(L[0])))
    5860    fig = plt.figure(1)
    5961    plt.clf()
    60    
    6162    lr1 = stats.linregress(L[0],L[1]) # return tuple (pente,ordonnee a l'origine, coef de correlation, p-value, erreur standard de l'estimation)
    6263    plt.plot(L[0],L[1], "r", label = "BMP_ref")
     
    8081    plt.show()
    8182
     83def residu(L):
     84    fig = plt.figure(1)
     85    plt.clf()
     86    plt.title("Residu")
     87    lr1 = stats.linregress(L[0],L[1]) # return tuple (pente (.slope),ordonnee a l'origine (.intercept), coef de correlation (.rvalue), p-value (.pvalue ?), erreur standard de l'estimation (.stderr))
     88    for i in range(len(L[1])):
     89        L[1][i] = L[1][i] -  lr1.slope*L[0][i] - lr1.intercept
     90    plt.plot(L[0],L[1], "r", label = "BMP_ref")
     91   
     92    lr2 = stats.linregress(L[0],L[2])
     93    for i in range(len(L[2])):
     94        L[2][i] = L[2][i] -  lr1.slope*L[0][i] - lr1.intercept
     95    plt.plot(L[0],L[2], "b", label = "BMP_impr")
     96
     97    lr3 = stats.linregress(L[0],L[3])
     98    for i in range(len(L[3])):
     99        L[3][i] = L[3][i] -  lr1.slope*L[0][i] - lr1.intercept
     100    plt.plot(L[0],L[3], "g", label = "BMP_ref")
     101 
     102    lr4 = stats.linregress(L[0],L[4])
     103    for i in range(len(L[4])):
     104        L[4][i] = L[4][i] -  lr1.slope*L[0][i] - lr1.intercept
     105    plt.plot(L[0],L[4], "m", label = "BMP_impr")
     106    plt.legend()
     107    plt.xlabel("length in million motor step")
     108    plt.ylabel("tension in mV")
     109    plt.show()
    82110   
    83111"""   
     
    88116    plt.show()
    89117"""
     118def print_data(fichier):
     119    L = read_data(fichier)
     120    print_graph(L)
    90121
     122def print_residu(fichier):
     123    L = read_data(fichier)
     124    residu(L)
    91125
    92 #print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt")
     126print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt")
     127print_residu("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt")
     128
    93129#print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_163036_0.txt")
    94130
    95131#print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_vertical_acquisition_20180612_0.txt")
    96 print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_vertical_acquisition_20180612_0.txt")
     132#print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_vertical_acquisition_20180612_0.txt")
Note: See TracChangeset for help on using the changeset viewer.