Skip to content
Snippets Groups Projects
Commit e02df80b authored by Stefan Reck's avatar Stefan Reck
Browse files

breaking: renamed detx input args to 'orcasong run' command and detx an not be...

breaking: renamed detx input args to 'orcasong run' command and detx an not be given in toml anymore
parent 898b01e5
No related branches found
Tags v4.5
No related merge requests found
......@@ -26,7 +26,7 @@ Produce DL h5 files from the aanet h5 files using OrcaSong.
You can either produce images or graphs.
If you have an orcasong config file, you can use it via the command line like this::
orcasong run aanet_file.h5 orcasong_config.toml --detx_file detector.detx
orcasong run aanet_file.h5 orcasong_config.toml --detx detector.detx
For some examples of config files you can check out the git repo here
......
......@@ -5,7 +5,7 @@ import orcasong.core
import orcasong.extractors as extractors
# built-in extractors. First argument has to be the input filename,
# other parameters can be set via 'extractor_config' dict in the toml
# other parameters can be set via '[extractor_config]' in the toml
EXTRACTORS = {
"nu_chain_neutrino": extractors.get_neutrino_mc_info_extr,
"nu_chain_muon": extractors.get_muon_mc_info_extr,
......@@ -23,23 +23,20 @@ MODES = {
def add_parser_run(subparsers):
parser = subparsers.add_parser(
"run",
description='Produce a dl file from an aanet file.')
"run", description='Produce a dl file from an aanet file.')
parser.add_argument('infile', type=str, help="Aanet file in h5 format.")
parser.add_argument('toml_file', type=str, help=(
parser.add_argument('config', type=str, help=(
"Orcasong configuration in toml format. Use prefix 'orcasong:' to load "
"a toml from OrcaSong/configs."))
parser.add_argument('--detx_file', type=str, default=None, help=(
"Optional detx file to calibrate on the fly. Can not be used if a "
"detx_file has also been given in the toml file."))
parser.add_argument('--detx', type=str, default=None, help=(
"Optional detx file to calibrate on the fly."))
parser.add_argument('--outfile', type=str, default=None, help=(
"Path to output file. Default: Save with auto generated name in cwd."))
parser.set_defaults(func=run_orcasong)
def run_orcasong(infile, toml_file, detx_file=None, outfile=None):
setup_processor(infile, toml_file, detx_file).run(
infile=infile, outfile=outfile)
def run_orcasong(infile, config, detx=None, outfile=None):
setup_processor(infile, config, detx).run(infile=infile, outfile=outfile)
def setup_processor(infile, toml_file, detx_file=None):
......@@ -48,14 +45,10 @@ def setup_processor(infile, toml_file, detx_file=None):
cfg = toml.load(toml_file)
processor = _get_verbose(cfg.pop("mode"), MODES)
if "detx_file" in cfg:
if detx_file is not None:
raise ValueError("detx_file passed to run AND defined in toml")
detx_file = cfg.pop("detx_file")
if "extractor" in cfg:
extractor_cfg = cfg.pop("extractor_config", {})
extractor = _get_verbose(cfg.pop("extractor"), EXTRACTORS)(infile, **extractor_cfg)
extractor = _get_verbose(
cfg.pop("extractor"), EXTRACTORS)(infile, **extractor_cfg)
else:
extractor = None
......
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