Esempio n. 1
0
if save == True:
    if os.path.isdir(save_folder_name) != True:
        os.mkdir(save_folder_name)

from PlottingFunctions import plot_2D_prediction
from PlottingFunctions import plot_distributions_CCNC
from PlottingFunctions import plot_resolution_CCNC
from PlottingFunctions import plot_single_resolution
from PlottingFunctions import plot_compare_resolution
from PlottingFunctions import plot_systematic_slices
from PlottingFunctions import plot_energy_slices

plot_2D_prediction(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                    save=save,savefolder=save_folder_name)
plot_distributions_CCNC(Y_test['file_0'],Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                        save=save,savefolder=save_folder_name)
plot_resolution_CCNC(Y_test['file_0'],Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                        save=save,savefolder=save_folder_name)
plot_single_resolution(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                        save=save,savefolder=save_folder_name)
plot_single_resolution(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                        use_old_reco=True, old_reco=Y_test_energy_reco['file_0'],\
                        save=save,savefolder=save_folder_name)
plot_compare_resolution(Y_test_energy, Y_test_predicted_energy,namelist=namelist,num_namelist=num_namelist,\
                        save=save,savefolder=save_folder_name)
plot_systematic_slices(Y_test_energy, Y_test_predicted_energy,num_namelist,\
                        save=save,savefolder=save_folder_name)
plot_energy_slices(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\
                    use_old_reco=True, old_reco=Y_test_energy_reco['file_0'],\
                    save=save,savefolder=save_folder_name)
    print(
        "Plotting %s at position %i in true test output and %i in NN test output"
        % (plot_name, true_index, NN_index))

    plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor,\
                        Y_test_predicted[:,NN_index]*maxabs_factor,\
                        save,save_folder_name,bins=bins,\
                        minval=minval,maxval=maxval,cut_truth=True,axis_square=True,\
                        variable=plot_name,units=plot_units)
    plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                        save,save_folder_name,bins=bins,\
                        minval=None,maxval=None,\
                        variable=plot_name,units=plot_units)
    plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\
                   Y_test_predicted[:,NN_index]*maxabs_factor,\
                   minaxis=-maxval,maxaxis=maxval,bins=bins,
                   save=save,savefolder=save_folder_name,\
                   variable=plot_name,units=plot_units)
    plot_bin_slices(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                    use_fraction = False,\
                    bins=10,min_val=minval,max_val=maxval,\
                    save=True,savefolder=save_folder_name,\
                    variable=plot_name,units=plot_units)

    if compare_reco:
        plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\
                   Y_test_predicted[:,NN_index]*maxabs_factor,\
                   use_old_reco = True, old_reco = reco_test_use[:,true_index],\
                   minaxis=-maxval,maxaxis=maxval,bins=bins,
                   save=save,savefolder=save_folder_name,\
                   variable=plot_name,units=plot_units, reco_name=reco_name)
Esempio n. 3
0
reco_coszenith = np.array(reco_coszenith)
Y_mask = np.logical_and(Y_energy>min_energy,Y_energy<max_energy)


# isCC = index 11
mask_CC = Y_labels_all[:,11]==1

# multiple masks
energy_cc = np.logical_and(Y_mask,mask_CC)

from PlottingFunctions import plot_single_resolution
from PlottingFunctions import plot_energy_slices
from PlottingFunctions import plot_distributions

plot_single_resolution(Y_energy[energy_cc],reco_energy[energy_cc],bins=100, use_fraction=fractional,\
                        save=True,savefolder=save_folder_name,\
                        variable="Energy", units = "GeV")

plot_single_resolution(Y_coszenith[energy_cc],reco_coszenith[energy_cc],bins=100, use_fraction=fractional,\
                        save=True,savefolder=save_folder_name,\
                        variable="CosZenith", units = "")

plot_energy_slices(Y_energy[energy_cc], reco_energy[energy_cc], \
                       use_fraction = fractional, \
                       bins=10,min_val=5.,max_val=100.,\
                       save=True,savefolder=save_folder_name)

plot_energy_slices(Y_coszenith[energy_cc], reco_coszenith[energy_cc], \
                       use_fraction = fractional, 
                       bins=10,min_val=-1.,max_val=1.,\
                       save=True,savefolder=save_folder_name,\
                            bins=bins,switch_axis=switch,\
                            minval=minval, maxval=maxval,
                            cut_truth=True, axis_square=True,\
                            variable=plot_name, units=plot_units, reco_name=name2)
        
        if make_resolution:
            #Resolution
            if input_file2 is None:
                use_old_reco = False
            else:
                use_old_reco = True
            plot_single_resolution(true1_value_fullAnalysis, reco1_value_fullAnalysis, 
                           weights=weights1_value_fullAnalysis,
                           old_reco_weights=weights2_value_fullAnalysis,
                           use_old_reco = use_old_reco,
                           old_reco = reco2_value_fullAnalysis,
                           old_reco_truth=true2_value_fullAnalysis,\
                           minaxis=-res_range, maxaxis=res_range, bins=bins,\
                           save=save, savefolder=save_folder_name,\
                           variable=plot_name, units=plot_units, reco_name=name1,
                           flavor=flavor,sample=sample)

            plot_single_resolution(true1_value_fullAnalysis, reco1_value_fullAnalysis,
                            weights=weights1_value_fullAnalysis,
                            old_reco_weights=weights2_value_fullAnalysis,\
                            use_old_reco = use_old_reco,
                            old_reco = reco2_value_fullAnalysis,
                            old_reco_truth=true2_value_fullAnalysis,\
                            minaxis=-frac_res_range, maxaxis=frac_res_range, 
                            bins=bins, use_fraction=True,\
                            save=save, savefolder=save_folder_name,\
                            variable=plot_name, units=plot_units, reco_name=name1,
                                bins=bins,switch_axis=switch,\
                                variable=plot_name, units=plot_units,
                                reco_name=reco_name,flavor=nu_type,sample=sample_name)
                plot_2D_prediction(retro_true_val, retro_val, weights=retro_weights,
                                save=save, savefolder=save_folder_name,
                                bins=bins,switch_axis=switch,\
                                minval=minval, maxval=maxval,
                                cut_truth=True, axis_square=True,\
                                variable=plot_name, units=plot_units,
                                reco_name=reco_name,flavor=nu_type,sample=sample_name)
        if plot_main:
            if retro_val is not None:
                plot_single_resolution(true_val, cnn_val, weights=true_weights,\
                           use_old_reco = True, old_reco = retro_val,\
                           old_reco_truth=retro_true_val,
                            old_reco_weights = retro_weights,old_reco_name=reco_name,
                           minaxis=-maxval, maxaxis=maxval, bins=bins,\
                           save=save, savefolder=save_folder_name,\
                           variable=plot_name, units=plot_units,
                           flavor=nu_type,sample=sample_name)

            else:
                plot_single_resolution(true_val, cnn_val, weights=true_weights,\
                           use_old_reco = False,\
                           minaxis=-maxval, maxaxis=maxval, bins=bins,\
                           save=save, savefolder=save_folder_name,\
                           variable=plot_name, units=plot_units,
                           flavor=nu_type,sample=sample_name)

        if plot_vertex:
            plot_bin_slices(true_val, cnn_val, energy_truth=true_R,
                        weights=true_weights,
    plot_2D_prediction(truth, cnn,weights=weights_plot,\
                            save=save, savefolder=save_folder_name,bins=bins,
                            minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\
                            variable=plot_name, units=plot_units, reco_name="CNN")
    if reco is not None:
        plot_2D_prediction(truth, retro_energy[cuts], weights=weights_plot,
                                save=save, savefolder=save_folder_name,bins=bins,\
                                variable=plot_name, units=plot_units, reco_name="Retro")
        plot_2D_prediction(truth, retro_energy[cuts], weights=weights_plot,
                                save=save, savefolder=save_folder_name,bins=bins,\
                                minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\
                                variable=plot_name, units=plot_units, reco_name="Retro")
    
    plot_single_resolution(truth, cnn, weights=weights_plot,\
                       use_old_reco = use_old_reco_bool, old_reco = old_reco,\
                       minaxis=-maxval, maxaxis=maxval, bins=bins,\
                       save=save, savefolder=save_folder_name,\
                       variable=plot_name, units=plot_units, reco_name="Retro")
    
    plot_bin_slices(truth, cnn, weights=weights_plot,  
                        old_reco = old_reco,\
                        use_fraction = True, bins=syst_bin, min_val=minval, max_val=maxval,\
                        save=save, savefolder=save_folder_name,\
                        variable=plot_name, units=plot_units, reco_name="Retro")

    plot_rms_slices(truth, cnn, weights=weights_plot,  
                        old_reco = old_reco,\
                        use_fraction = True, bins=syst_bin, min_val=minval, max_val=maxval,\
                        save=save, savefolder=save_folder_name,\
                        variable=plot_name, units=plot_units, reco_name="Retro")
    print(
        "Plotting %s at position %i in true test output and %i in NN test output"
        % (plot_name, true_index, NN_index))

    plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor,\
                        Y_test_predicted[:,NN_index]*maxabs_factor,\
                        save,save_folder_name,bins=bins,\
                        minval=minval,maxval=maxval,\
                        variable=plot_name,units=plot_units, epochs=epoch)
    plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                        save,save_folder_name,bins=bins,\
                        minval=None,maxval=None,\
                        variable=plot_name,units=plot_units, epochs = epoch)
    plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\
                    Y_test_predicted[:,NN_index]*maxabs_factor,\
                   minaxis=-2*maxval,maxaxis=maxval*2,
                   save=save,savefolder=save_folder_name,\
                   variable=plot_name,units=plot_units, epochs = epoch)
    plot_bin_slices(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                    use_fraction = False,\
                    bins=10,min_val=minval,max_val=maxval,\
                    save=True,savefolder=save_folder_name,\
                    variable=plot_name,units=plot_units, epochs = epoch)

    if compare_reco:
        plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\
                   Y_test_predicted[:,NN_index]*maxabs_factor,\
                   use_old_reco = True, old_reco = reco_test_use[:,true_index],\
                   old_reco_truth=Y_test_use2[:,true_index],\
                   minaxis=-2*maxval,maxaxis=maxval*2,
                   save=save,savefolder=save_folder_name,\
                            variable=plot_name, units=plot_units, reco_name="CNN")
    plot_2D_prediction(true_energy[cuts], retro_energy[cuts], weights=true_weights,
                            save=save, savefolder=save_folder_name,bins=bins,switch_axis=switch,\
                            variable=plot_name, units=plot_units, reco_name="Retro")
    plot_2D_prediction(true_energy[cuts], cnn_energy[cuts],weights=true_weights,\
                            save=save, savefolder=save_folder_name,bins=bins,switch_axis=switch,\
                            minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\
                            variable=plot_name, units=plot_units, reco_name="CNN")
    plot_2D_prediction(true_energy[cuts], retro_energy[cuts], weights=true_weights,
                            save=save, savefolder=save_folder_name,bins=bins,switch_axis=switch,\
                            minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\
                            variable=plot_name, units=plot_units, reco_name="Retro")
    """
    plot_single_resolution(true_energy[cuts], cnn_energy[cuts], weights=true_weights,\
                       use_old_reco = True, old_reco = retro_energy[cuts],\
                       minaxis=-maxval, maxaxis=maxval, bins=bins,\
                       save=save, savefolder=save_folder_name,\
                       variable=plot_name, units=plot_units, reco_name="Retro")
    plot_single_resolution(true_energy[cuts], cnn_energy[cuts], weights=true_weights,\
                       use_old_reco = True, old_reco = retro_energy[cuts],\
                       minaxis=-2, maxaxis=2, bins=bins,\
                       save=save, savefolder=save_folder_name,use_fraction=True,\
                       variable=plot_name, units=plot_units, reco_name="Retro")

    plot_bin_slices(true_energy[cuts], cnn_energy[cuts], weights=true_weights,
                        old_reco = retro_energy[cuts],\
                        use_fraction = True, bins=syst_bin, min_val=minval, max_val=maxval,\
                        save=save, savefolder=save_folder_name,\
                        variable=plot_name, units=plot_units, reco_name="Retro")
    """
    plot_bin_slices(true_energy[cuts], cnn_energy[cuts], weights=true_weights,  
 use_frac = use_fractions[name_index]
 bins = bins_array[name_index]
 print("Plotting %s at position %i in true test output and %i in NN test output"%(plot_name, true_index,NN_index))
 
 plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor,\
                     Y_test_predicted[:,NN_index]*maxabs_factor,\
                     save,save_folder_name,bins=bins,\
                     minval=minval,maxval=maxval,\
                     variable=plot_name,units=plot_units)
 plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                     save,save_folder_name,bins=bins,\
                     minval=None,maxval=None,\
                     variable=plot_name,units=plot_units)
 plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\
                 Y_test_predicted[:,NN_index]*maxabs_factor,\
                minaxis=-2*maxval,maxaxis=maxval*2,
                save=save,savefolder=save_folder_name,\
                variable=plot_name,units=plot_units)
 plot_distributions(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                 save,save_folder_name,\
                 variable=plot_name,units=plot_units)
 plot_bin_slices(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                 use_fraction = use_frac,\
                 bins=10,min_val=minval,max_val=maxval,\
                save=True,savefolder=save_folder_name,\
                variable=plot_name,units=plot_units)
 if first_var == "energy" and num ==0:
     plot_2D_prediction_fraction(Y_test_use[:,true_index]*maxabs_factor,\
                     Y_test_predicted[:,NN_index]*maxabs_factor,\
                     save,save_folder_name,bins=bins,\
                     minval=0,maxval=2,\