From 29bfa60dc5b542e5d51e06d87e50d468e54e04ac Mon Sep 17 00:00:00 2001 From: ViaFerrata <michimoser@onlinehome.de> Date: Mon, 11 Feb 2019 16:38:09 +0100 Subject: [PATCH] - Bugfix for docopt parser - Minor other stuff --- orcasong/io.py | 24 ------------- orcasong/make_nn_images.py | 26 +++++++++++++- orcasong/utils.py | 2 +- .../get_func_for_flat_track_shower.py | 34 +++++++++++++++---- .../conf_ORCA_115l_1-5GeV_xyz-c.toml | 2 -- .../conf_ORCA_115l_1-5GeV_xyz-t.toml | 2 -- .../conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml | 32 +++++++++++++++++ .../conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml | 32 +++++++++++++++++ ...conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml | 32 +++++++++++++++++ ...conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml | 32 +++++++++++++++++ 10 files changed, 181 insertions(+), 37 deletions(-) create mode 100644 user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml create mode 100644 user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml create mode 100644 user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml create mode 100644 user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml diff --git a/orcasong/io.py b/orcasong/io.py index 938139d..ee1e1c9 100644 --- a/orcasong/io.py +++ b/orcasong/io.py @@ -9,33 +9,9 @@ IO Code for OrcaSong. import os import errno import toml -from docopt import docopt import warnings -def parse_input(): - """ - Parses and returns all necessary input options for the make_nn_images function. - - Returns - ------- - fname : str - Full filepath to the input .h5 file. - detx_filepath : str - Full filepath to the .detx geometry file that belongs to the fname. - config_filepath : str - Full filepath to a config file. An example can be found in orcasong/default_config.toml - - """ - args = docopt(__doc__) - - fname = args['SIMFILE'] - detx_filepath = args['DETXFILE'] - config_filepath = args['CONFIGFILE'] - - return fname, detx_filepath, config_filepath - - def load_config(config_filepath): """ Loads the config from a .toml file. diff --git a/orcasong/make_nn_images.py b/orcasong/make_nn_images.py index 2c8cfee..cca183b 100644 --- a/orcasong/make_nn_images.py +++ b/orcasong/make_nn_images.py @@ -41,16 +41,40 @@ import sys import km3pipe as kp import km3modules as km import matplotlib as mpl +from docopt import docopt mpl.use('Agg') from matplotlib.backends.backend_pdf import PdfPages from orcasong.file_to_hits import EventDataExtractor from orcasong.hits_to_histograms import HistogramMaker -from orcasong.io import parse_input, load_config, check_user_input, make_output_dirs +from orcasong.io import load_config, check_user_input, make_output_dirs from orcasong.geo_binning import calculate_bin_edges from orcasong.utils import get_file_particle_type, EventSkipper +def parse_input(): + """ + Parses and returns all necessary input options for the make_nn_images function. + + Returns + ------- + fname : str + Full filepath to the input .h5 file. + detx_filepath : str + Full filepath to the .detx geometry file that belongs to the fname. + config_filepath : str + Full filepath to a config file. An example can be found in orcasong/default_config.toml + + """ + args = docopt(__doc__) + + fname = args['SIMFILE'] + detx_filepath = args['DETXFILE'] + config_filepath = args['CONFIGFILE'] + + return fname, detx_filepath, config_filepath + + def make_nn_images(fname, detx_filepath, config): """ Main code with config parameters. Reads raw .hdf5 files and creates 2D/3D histogram projections that can be used diff --git a/orcasong/utils.py b/orcasong/utils.py index affba0c..871aeaa 100644 --- a/orcasong/utils.py +++ b/orcasong/utils.py @@ -87,7 +87,7 @@ def use_custom_skip_function(skip_function, event_track): continue_bool = False else: - prob_for_e_bin_arr_path = 'placeholder.npy' + prob_for_e_bin_arr_path = '/home/woody/capn/mppi033h/Code/OrcaSong/orcasong_contrib/utilities/arr_fract_for_e_bins.npy' # Fraction of tracks compared to showers (n_muon-cc / (n_e-cc + n_e-nc)) arr_fract_for_e_bins = np.load(prob_for_e_bin_arr_path) # 2d arr, one row e_bins, second row prob e_bins = arr_fract_for_e_bins[0, :] diff --git a/orcasong_contrib/utilities/get_func_for_flat_track_shower.py b/orcasong_contrib/utilities/get_func_for_flat_track_shower.py index a01f3cb..44f6240 100644 --- a/orcasong_contrib/utilities/get_func_for_flat_track_shower.py +++ b/orcasong_contrib/utilities/get_func_for_flat_track_shower.py @@ -163,7 +163,12 @@ def plot_e_and_make_flat_func(energies_for_ic): pdfpages = PdfPages('./e_hist_plots.pdf') fig, ax = plt.subplots() - e_bins = 199 + e_bins_1_to_2 = np.linspace(1, 2, 3) + e_bins_2_to_25 = np.linspace(2.25, 25, 92) + e_bins_25_to_60 = np.linspace(25.5, 60, 70) + e_bins_60_to_100 = np.linspace(61, 100, 40) + + e_bins = np.concatenate([e_bins_1_to_2, e_bins_2_to_25, e_bins_25_to_60, e_bins_60_to_100], axis=0) # plot hist_muon_cc = plt.hist(energies_for_ic['muon_cc'], bins=e_bins) @@ -187,19 +192,34 @@ def plot_e_and_make_flat_func(energies_for_ic): # hist_shower[0][1] = hist_shower[0][1] / 2 # 2-3GeV track_div_shower = np.divide(hist_muon_cc[0], hist_shower[0]) - print(hist_muon_cc[0]) - print(hist_shower[0]) + # print(hist_muon_cc[0]) + # print(hist_shower[0]) bins=hist_muon_cc[1] # doesnt matter which bins to use - track_div_shower = np.append(track_div_shower, track_div_shower[-1]) - print(bins) - print(track_div_shower) - ax.step(bins, track_div_shower, linestyle='-', where='post') + track_div_shower_mpl = np.append(track_div_shower, track_div_shower[-1]) + + ax.step(bins, track_div_shower_mpl, linestyle='-', where='post') plt.title('Ratio tracks divided by showers') make_plot_options_and_save(ax, pdfpages, ylabel='Fraction') pdfpages.close() + # save e_bins and corresponding fractions + + # make e_bins with mean center + e_bins = [] + for i in range(bins.shape[0] - 1): + e_mean = (bins[i] + bins[i+1]) / 2 + e_bins.append(e_mean) + + e_bins = np.array(e_bins) + + + arr_fract_for_e_bins = np.vstack((e_bins, track_div_shower)) + print(arr_fract_for_e_bins) + + np.save('./arr_fract_for_e_bins.npy', arr_fract_for_e_bins) + def main(): dirs = { diff --git a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml index 1d6272b..f8ad34c 100644 --- a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml +++ b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml @@ -6,8 +6,6 @@ ###--- 1-5GeV ---### -### only take < 3GeV events, info throw away: elec-CC 0.25, muon-CC 0.25, elec-NC: 0.00 - ## XYZ-C output_dirpath = '/home/woody/capn/mppi033h' diff --git a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml index ff17a47..5b93630 100644 --- a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml +++ b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml @@ -6,8 +6,6 @@ ###--- 1-5GeV ---### -### only take < 3GeV events, info throw away: elec-CC 0.25, muon-CC 0.25, elec-NC: 0.00 - ## XYZ-T output_dirpath = '/home/woody/capn/mppi033h' diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml new file mode 100644 index 0000000..edd80db --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 1-5GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-1' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 2 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml new file mode 100644 index 0000000..e013c55 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 1-5GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-2' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 2 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml new file mode 100644 index 0000000..bd5a153 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 3-100GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-1' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 1 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml new file mode 100644 index 0000000..bf31746 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 3-100GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-2' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 1 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file -- GitLab