Skip to content
Snippets Groups Projects
Commit 29bfa60d authored by ViaFerrata's avatar ViaFerrata
Browse files

- Bugfix for docopt parser

- Minor other stuff
parent 315719a3
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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
......
......@@ -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, :]
......
......@@ -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 = {
......
......@@ -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'
......
......@@ -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'
......
# 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
# 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
# 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
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment