From 6049333a243fe109209d5573fc86021a5ab91da0 Mon Sep 17 00:00:00 2001 From: ViaFerrata <michimoser@onlinehome.de> Date: Fri, 11 Jan 2019 16:14:00 +0100 Subject: [PATCH] Bugfixes and changed toml files to new format. --- docs/conf.py | 2 +- orcasong/make_nn_images.py | 67 ++++++++++--------- .../conf_ORCA_115l_1-5GeV_xyz-c.toml | 31 ++++++--- .../conf_ORCA_115l_1-5GeV_xyz-t.toml | 31 ++++++--- .../conf_ORCA_115l_3-100GeV_xyz-c.toml | 31 ++++++--- .../conf_ORCA_115l_3-100GeV_xyz-t.toml | 31 ++++++--- .../conf_ORCA_115l_mupage_xyz-c.toml | 54 ++++++--------- .../conf_ORCA_115l_mupage_xyz-t.toml | 31 ++++++--- .../conf_ORCA_115l_random_noise_xyz-c.toml | 31 ++++++--- .../conf_ORCA_115l_random_noise_xyz-t.toml | 31 ++++++--- 10 files changed, 205 insertions(+), 135 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index bdd9b9a..57c9513 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,7 +60,7 @@ autoapi_options = [ # , 'private-members', 'special-members' ] autoapi_ignore = [ - "*/tests/*", "*test_*.py", "*/doc/conf.py", "*/pydataskel*", "*/style/*" + "*/tests/*", "*test_*.py", "*/docs/conf.py", "*/pydataskel*", "*/style/*" ] autoapi_include_summaries = True diff --git a/orcasong/make_nn_images.py b/orcasong/make_nn_images.py index 0a405a9..d581e30 100644 --- a/orcasong/make_nn_images.py +++ b/orcasong/make_nn_images.py @@ -95,17 +95,19 @@ def load_config(config_filepath): config = toml.load(config_filepath) print('Loaded the config file from ' + os.path.abspath(config_filepath)) - check_config(config) - return config -def check_config(config): +def check_user_input(fname, detx_filepath, config): """ Sanity check of the user input. Parameters ---------- + 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 : dict Dictionary that contains all configuration options of the make_nn_images function. An explanation of the config parameters can be found in orcasong/default_config.toml. @@ -114,39 +116,38 @@ def check_config(config): #---- Checks input types ----# # Check for options with a single, non-boolean element - number_args = {'do2d_plots_n': int, 'data_cut_e_low ': float, 'data_cut_e_high': float, + number_args = {'do2d_plots_n': int, 'data_cut_e_low': float, 'data_cut_e_high': float, 'data_cut_throw_away': float, 'prod_ident': int} for key in number_args: expected_arg_type = number_args[key] parsed_arg = config[key] - if parsed_arg is None: # we don't want to check args when there has been no user input + if parsed_arg in [None, 'None']: # we don't want to check args when there has been no user input continue - try: - map(expected_arg_type, parsed_arg) - except ValueError: - raise TypeError('The argument option ', key, ' only accepts ', str(expected_arg_type), - ' values as an input.') + if type(parsed_arg) != expected_arg_type: + try: + map(expected_arg_type, parsed_arg) + except ValueError: + raise TypeError('The argument option ', key, ' only accepts ', str(expected_arg_type), + ' values as an input.') # Checks the n_bins tuple input - try: - map(int, config['n_bins'].split(',')) - except ValueError: - raise TypeError('The argument option n_bins only accepts integer values as an input' - ' (Format: --n_bins 11,13,18,60).') - + for dim in config['n_bins']: + if type(dim) != int: + raise TypeError('The argument option n_bins only accepts integer values as an input!' + ' Your values have the type ' + str(type(dim))) # ---- Checks input types ----# # ---- Check other things ----# - if not os.path.isfile(config['SIMFILE']): - raise IOError('The file -' + config['SIMFILE'] + '- does not exist.') + if not os.path.isfile(fname): + raise IOError('The file -' + fname+ '- does not exist.') - if not os.path.isfile(config['DETXFILE']): - raise IOError('The file -' + config['DETXFILE'] + '- does not exist.') + if not os.path.isfile(detx_filepath): + raise IOError('The file -' + detx_filepath + '- does not exist.') if all(do_nd == False for do_nd in [config['do2d'], config['do3d'],config['do4d']]): raise ValueError('At least one of do2d, do3d or do4d options must be set to True.') @@ -154,7 +155,7 @@ def check_config(config): if config['do2d'] == False and config['do2d_plots'] == True: raise ValueError('The 2D pdf images cannot be created if do2d=False!') - if config['do2d_plots'] == True and int(config['do2d_plots_n']) > 100: + if config['do2d_plots'] == True and config['do2d_plots_n'] > 100: warnings.warn('You declared do2d_pdf=(True, int) with int > 100. This will take more than two minutes.' 'Do you really want to create pdfs images for so many events?') @@ -369,14 +370,13 @@ def skip_event(event_track, data_cuts): """ continue_bool = False - if data_cuts['energy_lower_limit'] is not None: continue_bool = event_track.energy[0] < data_cuts['energy_lower_limit'] # True if E < lower limit if data_cuts['energy_upper_limit'] is not None and continue_bool == False: continue_bool = event_track.energy[0] > data_cuts['energy_upper_limit'] # True if E > upper limit - if data_cuts['throw_away_prob'] > 0 and continue_bool == False: + if data_cuts['throw_away_prob'] is not None and continue_bool == False: throw_away_prob = data_cuts['throw_away_prob'] throw_away = np.random.choice([False, True], p=[1 - throw_away_prob, throw_away_prob]) if throw_away: continue_bool = True @@ -404,20 +404,22 @@ def make_nn_images(fname, detx_filepath, config): """ # Load all parameters from the config output_dirpath = config['output_dirpath'] - chunksize, complib, complevel = int(config['chunksize']), int(config['complib']), int(config['complevel']) - flush_freq = int(config['flush_freq']) - n_bins = tuple(map(int, config['n_bins'].split(','))) - timecut, do_mc_hits = config['timecut'], config['do_mc_hits'] + chunksize, complib, complevel = config['chunksize'], config['complib'], config['complevel'] + flush_freq = config['flush_freq'] + n_bins = tuple(config['n_bins']) + timecut = (config['timecut_mode'], config['timecut_timespan']) + do_mc_hits = config['do_mc_hits'] det_geo = config['det_geo'] - do2d, do2d_plots = (config['do2d'], int(config['do2d_plots'])) + do2d = config['do2d'] + do2d_plots = (config['do2d_plots'], config['do2d_plots_n']) do3d = config['do3d'] do4d = (config['do4d'], config['do4d_mode']) - prod_ident = int(config['prod_ident']) if config['prod_ident'] is not 'None' else None + prod_ident = config['prod_ident'] if config['prod_ident'] != 'None' else None data_cuts = dict() data_cuts['triggered'] = config['data_cut_triggered'] - data_cuts['energy_lower_limit'] = float(config['data_cut_e_low']) if config['data_cut_e_low'] is not 'None' else None - data_cuts['energy_upper_limit'] = float(config['data_cut_e_high']) if config['data_cut_e_high'] is not 'None' else None - data_cuts['throw_away_prob'] =float(config['data_cut_throw_away']) if config['data_cut_e_high'] is not 'None' else 0.00 + data_cuts['energy_lower_limit'] = config['data_cut_e_low'] if config['data_cut_e_low'] != 'None' else None + data_cuts['energy_upper_limit'] = config['data_cut_e_high'] if config['data_cut_e_high'] != 'None' else None + data_cuts['throw_away_prob'] = config['data_cut_throw_away'] if config['data_cut_throw_away'] != 'None' else None make_output_dirs(output_dirpath, do2d, do3d, do4d) @@ -482,6 +484,7 @@ def main(): """ fname, detx_filepath, config_filepath = parse_input() config = load_config(config_filepath) + check_user_input(fname, detx_filepath, config) make_nn_images(fname, detx_filepath, config) diff --git a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-c.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-c.toml index 0476b79..d3c9e48 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-c.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-c.toml @@ -30,13 +30,24 @@ ## XYZ-C ---n_bins = '11,13,18,31' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'channel_id' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 2 # only for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod. ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,31] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'channel_id' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +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_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-t.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-t.toml index de45470..e49be23 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-t.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_1-5GeV_xyz-t.toml @@ -30,13 +30,24 @@ ## XYZ-T ---n_bins = '11,13,18,100' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'time' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 2 # only for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod. ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,100] +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-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +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_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-c.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-c.toml index cbdba56..2ddabb0 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-c.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-c.toml @@ -30,13 +30,24 @@ ## XYZ-C ---n_bins = '11,13,18,31' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'channel_id' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 1 # only for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod. ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,31] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'channel_id' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +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_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-t.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-t.toml index 1af7c4d..72a8ec0 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-t.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_3-100GeV_xyz-t.toml @@ -30,13 +30,24 @@ ## XYZ-T ---n_bins = '11,13,18,100' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'time' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 1 # only for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod. ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,100] +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-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +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_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-c.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-c.toml index afe026d..87ec61f 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-c.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-c.toml @@ -1,28 +1,6 @@ # A config file for OrcaSong with a list of all configuration options. # More info about the .toml format at https://github.com/toml-lang/toml -### All available options with some dummy values -# --o = '/home/woody/capn/mppi033h/orcasong_output' -# --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 = 3 -# --data_cut_e_high = 100 -# --data_cut_throw_away = 0.00 -# --prod_ident = 1 - ####----- Configuration for ORCA 115l -----#### @@ -30,13 +8,25 @@ ## XYZ-C ---n_bins = '11,13,18,31' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'channel_id' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 3 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h/test3' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,31] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'channel_id' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +prod_ident = 3 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 + diff --git a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-t.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-t.toml index cc7a776..e53134a 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-t.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_mupage_xyz-t.toml @@ -30,13 +30,24 @@ ## XYZ-T ---n_bins = '11,13,18,100' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'time' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 3 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,100] +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-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +prod_ident = 3 # 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_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-c.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-c.toml index 79d51c1..467d660 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-c.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-c.toml @@ -30,13 +30,24 @@ ## XYZ-C ---n_bins = '11,13,18,31' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'channel_id' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 4 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,31] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'channel_id' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +prod_ident = 4 # 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_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-t.toml b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-t.toml index 812a39b..1a7cb78 100644 --- a/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-t.toml +++ b/user/config/orca_115l_mupage_rn_neutr_classifier/conf_ORCA_115l_random_noise_xyz-t.toml @@ -30,13 +30,24 @@ ## XYZ-T ---n_bins = '11,13,18,100' ---det_geo = 'Orca_115l_23m_h_9m_v' ---do4d_mode = 'time' ---timecut_mode = 'trigger_cluster' ---timecut_timespan = 'tight-0' ---prod_ident = 4 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 ---o = '/home/woody/capn/mppi033h' ---chunksize = 32 ---complib = 'zlib' ---complevel = 1 \ No newline at end of file +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,100] +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-0' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +prod_ident = 4 # 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