Changeset 796 in ETALON


Ignore:
Timestamp:
Aug 7, 2018, 11:57:15 AM (6 years ago)
Author:
delerue
Message:

BPM code modified to remove legend when not needed

Location:
BPM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BPM/print_datas.py

    r795 r796  
    88global_index_figure = 0
    99
     10basedir='/Users/delerue/Downloads/BPM_data/'
     11basename='bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_'
    1012
    11        
    12 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_0.txt", "x_motor_step", "x_libera_mm",lin_reg = "true", residu = "yes", rms = "yes")
     13#graph_fr(basedir+basename+"test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_0.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = None )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     14#graph_fr(basedir+basename+"test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_1.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = None )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     15#graph_fr(basedir+basename+"test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_2.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = None )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     16#graph_fr(basedir+basename+"test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_3.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = None )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
    1317
    14 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "true", residu = "yes", rms = "yes", x_begin_mm =103.78 , x_end_mm = 72.5)
     18"""
     19for ifile in range(0,10):
     20    print(ifile)
     21    graph_fr(basedir+basename+"test_decrochage_BPM0-E_BPM1-impr_BPM2-C_20180803_"+str(ifile)+".txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = None )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     22""""
    1523
    16 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "true", residu = "yes", rms = "yes", centrage = "yes", x_begin_mm =103.78, x_end_mm = 72.5 , x_minimal = 86., x_maximal = 96.)#, centrage = "yes")#, x_minimal = 77, x_maximal = 99
    17 
    18 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_3pts-horizontal_100pts-vertical_20180802_0.txt", "y_motor_mm", "y_libera_mm",lin_reg = "true", residu = "yes", rms = "yes", centrage = "yes")
    19 
    20 #graph_fr("/Users/delerue/Downloads/BPM_data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_2.txt", "y_motor_step", "y_libera_mm",lin_reg = "true", residu = "yes", rms = "yes")#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
    21 graph_fr("/Users/delerue/Downloads/BPM_data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_test_decrochage_BPM0-E_BPM1-impr_BPM2-C_High_Stat_20180803_2.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes" )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
    22 
    23 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_3pts-horizontal_100pts-vertical_20180802_0.txt", "y_motor_mm", "Va", residu = "yes", centrage = "yes", one_bpm = "BPM_E")#, rms = "yes")
    24 
    25 
    26 
    27 #graph_fr("data/bpm_name_bpm_number_x_motor_step_x_motor_mm_y_motor_step_y_motor_mm_Va_Vb_Vc_Vd_Sum_x_libera_mm_y_libera_mm_BPM0-E_BPM1-impr_BPM2-C_3pts-horizontal_100pts-vertical_20180802_0.txt", "y_motor_mm", "y_libera_mm",lin_reg = "true", residu = "yes", rms = "yes",x_minimal = -10, x_maximal = -20)#need data complete
    28 
    29 
    30 
    31 
    32 
    33 
    34 
    35 
    36 
    37 
    38 
    39 
    40 
    41 
    42 
    43 
    44 
    45    
    46 #print_data_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/BPM-number_x-motor_y-motor_Va_Vb_Vc_Vd_Sum_X_Y_BPM0-soleil_BPM1-impr_BPM2-ref_20180718_1.txt",  miny = 0, maxy = 57)
    47 #print_residu_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/BPM-number_x-motor_y-motor_Va_Vb_Vc_Vd_Sum_X_Y_BPM0-soleil_BPM1-impr_BPM2-ref_20180718_1.txt")
    48 
    49 #print_data_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/BPM-number_x-motor_y-motor_Va_Vb_Vc_Vd_Sum_X_Y_BPM0-soleil_BPM1-impr_BPM2-ref_20180718_2_convert-100000_94,36_100000_78,72.txt", begin_mm = 78.72, end_mm = 94.36)
    50 #print_residu_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/BPM-number_x-motor_y-motor_Va_Vb_Vc_Vd_Sum_X_Y_BPM0-soleil_BPM1-impr_BPM2-ref_20180718_2_convert-100000_94,36_100000_78,72.txt")
    51 
    52 #print_data_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/test.txt", begin_mm = 100)
    53 #print_data_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/test.txt, begin_mm = 0, end_mm = 1")
    54 #print_residu_xmotor_ymotor_Va_Vb_Vc_Vd_sum_x_y("data/test.txt")
    55 
    56 
    57 #print_data_position_Va_Vb_Vc_Vd("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3)
    58 #print_residu_position_Va_Vb_Vc_Vd("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_160153_0.txt",0.1,0.3)
    59 #print_data_position_Va_Vb_Vc_Vd("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180611_163036_0.txt")
    60 #print_data_position_Va_Vb_Vc_Vd("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_vertical_acquisition_20180612_0.txt")
    61 #print_data_position_Va_Vb_Vc_Vd("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_vertical_acquisition_20180612_0.txt")
    6224#plt.show(block = False)
    6325plt.show()
    6426
    65    
    66 """   
    67     ax2 = fig.add_axes((0.1,0.1,0.8,0.0))
    68     ax2.yaxis.set_visible(False) # hide the yaxis
    69     ax2.set_xticklabels(10*L[0])
    70     ax2.set_xlabel("lenght in mm")
    71     plt.show()
    72 """
  • BPM/print_datas_lib.py

    r794 r796  
    77
    88global_index_figure = 0
     9
     10figure_size_in_hundreds_pixels=(8,6)
     11
     12
    913
    1014def float_list(l, avoid = []): # convert a list of char in a list of float, and it avoid all data in the list of index that must be avoid
     
    240244
    241245def print_graph_fr(list_data_name, data, x_data_name, y_data_name, index_figure, color = "r",title = None, legende = None, lin_reg = None, rms = None, centrage = None): # program to print graph of y_data_name vs x_data_name in french
    242     fig1 = plt.figure(index_figure)
     246    fig1 = plt.figure(index_figure,figsize=figure_size_in_hundreds_pixels, dpi=100)
    243247    if not(centrage is None):
    244248        mini,maxi =  min_max(list_data_name, data, x_data_name)
     
    267271        slope, intercept, r_value, p_value, std_err = stats.linregress(X,Y) # return tuple (pente,ordonnee a l'origine, coef de correlation, p-value, erreur standard de l'estimation)
    268272        if legende is None:
    269             plt.plot(X,[slope*i + intercept for i in X], color+"--", label =  " regression lineaire, \nerreur = "+str(round(std_err,3))+",\ncoefficient de correlation = "+str(round(r_value,3)) + "\npente de la regression lineaire = " + str(round(slope,3)))
     273#            plt.plot(X,[slope*i + intercept for i in X], color+"--", label =  " regression lineaire, \nerreur = "+str(round(std_err,3))+",\ncoefficient de correlation = "+str(round(r_value,3)) + "\npente de la regression lineaire = " + str(round(slope,3)))
     274            plt.plot(X,[slope*i + intercept for i in X], color+"--")
    270275        else:
    271276            plt.plot(X,[slope*i + intercept for i in X], color+"--", label = legende + " : regression lineaire, \nerreur = "+str(round(std_err,3))+",\ncoefficient de correlation  = "+str(round(r_value,3))+ "\npente de la regression lineaire = " + str(round(slope,3)))           
    272     plt.legend(fontsize=15)
     277            plt.legend(fontsize=15)
    273278    x_label = plot_legend_fr(x_data_name)
    274279    y_label = plot_legend_fr(y_data_name)
     
    336341        mini,maxi =  min_max(list_data_name, data, y_data_name)
    337342        data = linear_fonction_on_data(list_data_name, data, y_data_name, begin_mm = (mini - maxi)/2., end_mm = (maxi - mini)/2.)
    338     fig1 = plt.figure(index_figure)
     343    fig1 = plt.figure(index_figure,figsize=figure_size_in_hundreds_pixels, dpi=100)
    339344    if rms is None:
    340345        x_data_number = number_of_data_name(list_data_name, x_data_name)
     
    358363        slope, intercept, r_value, p_value, std_err = stats.linregress(X,Y) # return tuple (pente,ordonnee a l'origine, coef de correlation, p-value, erreur standard de l'estimation)
    359364        if legende is None:
    360             plt.plot(X,[slope*i + intercept for i in X], color+"--", label =  "linear regression, \nerror = "+str(round(std_err,3))+",\ncorrelation coefficient = "+str(round(r_value,3)) + "\nslope = " + str(round(slope,3)))
     365#            plt.plot(X,[slope*i + intercept for i in X], color+"--", label =  "linear regression, \nerror = "+str(round(std_err,3))+",\ncorrelation coefficient = "+str(round(r_value,3)) + "\nslope = " + str(round(slope,3)))
     366            plt.plot(X,[slope*i + intercept for i in X], color+"--")
    361367        else:
    362368            plt.plot(X,[slope*i + intercept for i in X], color+"--", label = legende + " : lineare regression, \nerror = "+str(round(std_err,3))+",\ncorrelation coefficient = "+str(round(r_value,3))+ "\nslope = " + str(round(slope,3)))
     
    381387        mini,maxi =  min_max(list_data_name, data, y_data_name)
    382388        data = linear_fonction_on_data(list_data_name, data, y_data_name, begin_mm = (mini - maxi)/2., end_mm = (maxi - mini)/2.)
    383     fig1 = plt.figure(index_figure)
     389    fig1 = plt.figure(index_figure,figsize=figure_size_in_hundreds_pixels, dpi=100)
    384390    if rms is None:
    385391        x_data_number = number_of_data_name(list_data_name, x_data_name)
     
    428434        #mini,maxi =  min_max(list_data_name, data, y_data_name)
    429435        #data = linear_fonction_on_data(list_data_name, data, y_data_name, begin_mm = (mini - maxi)/2., end_mm = (maxi - mini)/2.)
    430     fig1 = plt.figure(index_figure)
     436    fig1 = plt.figure(index_figure,figsize=figure_size_in_hundreds_pixels, dpi=100)
    431437    if rms is None:
    432438        x_data_number = number_of_data_name(list_data_name, x_data_name)
     
    451457    else:
    452458        plt.plot(X,Y, color+".", label = legende + " residu moyen = " + str(round(moyenne,4)))
    453     plt.legend(fontsize=15)
     459        plt.legend(fontsize=15)
    454460    x_label = plot_legend_fr(x_data_name)
    455461    y_label = plot_legend_fr(y_data_name)
     
    506512
    507513
    508 def graph_fr(fichier, x_data_name, y_data_name, lin_reg = None, residu = None, rms = None, x_begin_mm = None, x_end_mm = None, y_begin_mm = None, y_end_mm = None, x_minimal = None, x_maximal = None, y_minimal = None,  y_maximal = None, centrage = None, one_bpm = None):
     514def graph_fr(fichier, x_data_name, y_data_name, lin_reg = None, residu = None, rms = None, x_begin_mm = None, x_end_mm = None, y_begin_mm = None, y_end_mm = None, x_minimal = None, x_maximal = None, y_minimal = None,  y_maximal = None, centrage = None, one_bpm = None, legende = "yes"):
    509515    (list_data_name,data) = read_data(fichier)
    510516    if not(x_data_name in list_data_name):
     
    543549        if oposit_y_data_number == "":
    544550            for bpm_number in range(len(all_bpm_name)):
    545                 print_graph_fr(list_data_name, cut_data(list_data_name, data, "bpm_name", equal =  all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure, color = color_list[bpm_number], legende = all_bpm_name[bpm_number], lin_reg = lin_reg, rms = rms, centrage = centrage)
     551                if not(legende is None):
     552                    the_legend=all_bpm_name[bpm_number]
     553                else:
     554                    the_legend=None
     555                print_graph_fr(list_data_name, cut_data(list_data_name, data, "bpm_name", equal =  all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure, color = color_list[bpm_number], legende = the_legend, lin_reg = lin_reg, rms = rms, centrage = centrage)
    546556                if not(residu is None):
    547                     print_residu_fr(list_data_name,  cut_data(list_data_name, data, "bpm_name", equal = all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 1, color_list[bpm_number], legende = all_bpm_name[bpm_number], rms = rms, centrage = centrage)
     557                    print_residu_fr(list_data_name,  cut_data(list_data_name, data, "bpm_name", equal = all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 1, color_list[bpm_number], legende = the_legend, rms = rms, centrage = centrage)
    548558            global_index_figure += 2
    549559        else:
    550560            all_oposit_y_value = all_value_of_data(list_data_name, data,oposit_y_data_name)
     561            if not(legende is None):
     562                the_legend=all_bpm_name[bpm_number]
     563            else:
     564                the_legend=None
    551565            for index_value in range(len(all_oposit_y_value)):
    552566                data_cut =  cut_data(list_data_name, data, oposit_y_data_name, equal = all_oposit_y_value[index_value])
    553567                for bpm_number in range(len(all_bpm_name)):
    554568                    #print(cut_data(list_data_name, data_cut, "bpm_name", equal =  all_bpm_name[bpm_number]))
    555                     print_graph_fr(list_data_name, cut_data(list_data_name, data_cut, "bpm_name", equal =  all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 2*index_value, color = color_list[bpm_number], legende = all_bpm_name[bpm_number], lin_reg = lin_reg, rms = rms, title = oposit_y_data_name + " = " + str(all_oposit_y_value[index_value]), centrage = centrage)
     569                    print_graph_fr(list_data_name, cut_data(list_data_name, data_cut, "bpm_name", equal =  all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 2*index_value, color = color_list[bpm_number], legende = the_legend, lin_reg = lin_reg, rms = rms, title = oposit_y_data_name + " = " + str(all_oposit_y_value[index_value]), centrage = centrage)
    556570                    if not(residu is None):
    557                         print_residu_fr(list_data_name, cut_data(list_data_name, data_cut, "bpm_name", equal = all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 2*index_value + 1, color_list[bpm_number], legende = all_bpm_name[bpm_number], rms = rms, title = oposit_y_data_name + " = " + str(all_oposit_y_value[index_value]), centrage = centrage)
     571                        print_residu_fr(list_data_name, cut_data(list_data_name, data_cut, "bpm_name", equal = all_bpm_name[bpm_number]), x_data_name, y_data_name, global_index_figure + 2*index_value + 1, color_list[bpm_number], legende = the_legend, rms = rms, title = oposit_y_data_name + " = " + str(all_oposit_y_value[index_value]), centrage = centrage)
    558572            global_index_figure += 2*len(all_oposit_y_value)
    559573    else: # need to be done, same as befor with "bpm_number" to replace "bpm_name"
Note: See TracChangeset for help on using the changeset viewer.