Changeset 798 in ETALON for BPM


Ignore:
Timestamp:
Sep 6, 2018, 4:40:35 PM (6 years ago)
Author:
delerue
Message:

Added Codesys directory

Location:
BPM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BPM/print_datas.py

    r796 r798  
    1111basename='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_'
    1212
     13#Big dataset 1 (along X)
     14#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes" )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     15#plt.show()
     16#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes" , x_minimal = -50000, x_maximal = 50000) #, centrage = "yes"
     17#plt.show()
     18#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes" , x_minimal = -50000, x_maximal = 50000) #, centrage = "yes"
     19
     20
     21#Decrochage
     22graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "x_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", x_minimal = -200000., x_maximal = -150000. )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     23graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "Va",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", x_minimal = -200000., x_maximal = -150000. )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     24graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "Vb",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", x_minimal = -200000., x_maximal = -150000. )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     25graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "Vc",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", x_minimal = -200000., x_maximal = -150000. )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     26graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_3pts-vertical_20180801_1.txt", "x_motor_mm", "Vd",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", x_minimal = -200000., x_maximal = -150000. )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     27plt.show()
     28
     29#Big data set 2 (along y)
     30#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_3pts-horizontal_100pts-vertical_20180802_0.txt", "y_motor_step", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes" , save_figure = 'y_20180802_0')#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     31#plt.show()
     32#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_3pts-horizontal_100pts-vertical_20180802_0.txt", "y_motor_mm", "y_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes" , centrage = "yes", y_minimal = -20., y_maximal = -10., save_figure = 'y_zoom_20180802_0' )
     33#plt.show()
     34
     35
     36#Ultra Big data set 3 (along x)
     37#graph_fr(basedir+basename+"BPM0-E_BPM1-impr_BPM2-C_100pts-horizontal_5pts-vertical_20180803_0.txt", "x_motor_step", "x_libera_mm",lin_reg = "yes", residu = "yes", rms = "yes",legende = "yes", save_figure = 'x_20180803_0' )#, centrage = "yes", y_minimal = -20., y_maximal = -10.)
     38#plt.show()
     39
     40
     41#tests de decrochage
    1342#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.)
    1443#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.)
     
    2049    print(ifile)
    2150    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 """"
     51"""
    2352
    2453#plt.show(block = False)
  • BPM/print_datas_lib.py

    r796 r798  
    88global_index_figure = 0
    99
    10 figure_size_in_hundreds_pixels=(8,6)
     10figure_size_in_hundreds_pixels=(12,8)
    1111
    1212
     
    262262    if y_data_name == "x_motor_step" or y_data_name == "y_motor_step":
    263263        Y = [i[y_data_number]/1000000. for i in data]
    264     if legende is None:
     264    if not(lin_reg is None):
    265265        plt.plot(X,Y, color+".")
    266         plt.errorbar(X,Y,yerr = rms, ecolor = color)
    267     else:
    268         plt.plot(X,Y, color+".", label = legende)
    269         plt.errorbar(X,Y,yerr = rms, ecolor = color)
    270     if not(lin_reg is None):
    271266        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)
    272267        if legende is None:
     
    274269            plt.plot(X,[slope*i + intercept for i in X], color+"--")
    275270        else:
    276             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)))           
    277             plt.legend(fontsize=15)
     271            plt.plot(X,[slope*i + intercept for i in X], color+"--", label = legende + " : reg. lin, \nerr = "+str(round(std_err,3))+",\ncoef correl = "+str(round(r_value,3))+ "\npente = " + str(round(slope,3)))           
     272            plt.legend(fontsize=15,bbox_to_anchor=(1.11, 1.11))           
     273    else:
     274        if legende is None:
     275            plt.plot(X,Y, color+".")
     276            plt.errorbar(X,Y,yerr = rms, ecolor = color)
     277        else:
     278            plt.plot(X,Y, color+".", label = legende)
     279            plt.errorbar(X,Y,yerr = rms, ecolor = color)
     280
    278281    x_label = plot_legend_fr(x_data_name)
    279282    y_label = plot_legend_fr(y_data_name)
     
    512515
    513516
    514 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, legende = "yes"):
     517def 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", save_figure = None):
    515518    (list_data_name,data) = read_data(fichier)
    516519    if not(x_data_name in list_data_name):
     
    526529    linear_fonction_on_data(list_data_name, data, x_data_name, begin_mm = x_begin_mm, end_mm = x_end_mm)
    527530    linear_fonction_on_data(list_data_name, data, y_data_name, begin_mm = y_begin_mm, end_mm = y_end_mm)
    528     data = cut_data(list_data_name, data, x_data_name, inf = x_maximal, equal = x_maximal)
    529     data = cut_data(list_data_name, data, x_data_name, sup = x_minimal, equal = x_minimal)
    530     data = cut_data(list_data_name, data, y_data_name, inf = y_maximal, equal = y_maximal)
    531     data = cut_data(list_data_name, data, y_data_name, sup = y_minimal, equal = y_minimal)
     531    print("Data size")
     532    print(len(data))
     533    if not(x_maximal is None):
     534        data = cut_data(list_data_name, data, x_data_name, inf = x_maximal, equal = x_maximal)
     535        print("x_maximal "+str(x_maximal))
     536        print(len(data))
     537    if not(x_minimal is None):
     538        data = cut_data(list_data_name, data, x_data_name, sup = x_minimal, equal = x_minimal)
     539        print("x_minimal "+str(x_minimal))
     540        print(len(data))
     541    if not(y_maximal is None):
     542        print("y_maximal "+str(y_maximal))
     543        data = cut_data(list_data_name, data, y_data_name, inf = y_maximal, equal = y_maximal)
     544        print(len(data))
     545    if not(y_minimal is None):
     546        print("y_minimal "+str(y_minimal))
     547        data = cut_data(list_data_name, data, y_data_name, sup = y_minimal, equal = y_minimal)
     548        print(len(data))
    532549    if data == []:
    533550        print("cut to high")
     
    551568                if not(legende is None):
    552569                    the_legend=all_bpm_name[bpm_number]
     570                    print(the_legend)
    553571                else:
    554572                    the_legend=None
    555573                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)
     574                if not(save_figure is None):
     575                    plt.savefig(save_figure+'_'+str(global_index_figure)+'.png')
     576                    print("Figure saved")
     577                    print(save_figure+'_'+str(global_index_figure)+'.png')
    556578                if not(residu is None):
    557579                    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)
     580                    if not(save_figure is None):
     581                        plt.savefig(save_figure+'_residu_'+str(global_index_figure)+'.png')
    558582            global_index_figure += 2
    559583        else:
    560584            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
    565585            for index_value in range(len(all_oposit_y_value)):
    566586                data_cut =  cut_data(list_data_name, data, oposit_y_data_name, equal = all_oposit_y_value[index_value])
    567587                for bpm_number in range(len(all_bpm_name)):
     588                    if not(legende is None):
     589                        the_legend=all_bpm_name[bpm_number]
     590                    else:
     591                        the_legend=None
    568592                    #print(cut_data(list_data_name, data_cut, "bpm_name", equal =  all_bpm_name[bpm_number]))
    569593                    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)
    570594                    if not(residu is None):
    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)
    572             global_index_figure += 2*len(all_oposit_y_value)
     595                        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)                       
     596                if not(save_figure is None):
     597                    plt.figure(global_index_figure + 2*index_value)
     598                    plt.savefig(save_figure+'_'+str(global_index_figure + 2*index_value)+'.png')
     599                    print("Figure saved")
     600                    print(save_figure+'_'+str(global_index_figure + 2*index_value)+'.png')
     601                    if not(residu is None):
     602                        plt.figure(global_index_figure + 2*index_value+1)
     603                        plt.savefig(save_figure+'_residu_'+str(global_index_figure + 2*index_value)+'.png')
     604                global_index_figure += 2*len(all_oposit_y_value)
    573605    else: # need to be done, same as befor with "bpm_number" to replace "bpm_name"
    574606        print("ERROR TYPE OF DATA")
Note: See TracChangeset for help on using the changeset viewer.