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

change parsing

parent 912feb17
No related branches found
No related tags found
1 merge request!20Parser
import os import os
import toml import toml
from orcasong.core import FileGraph from orcasong.core import FileGraph
from orcasong.extractors import get_neutrino_mc_info_extr import orcasong.extractors as extractors
EXTRACTORS = { EXTRACTORS = {
"neutrino": get_neutrino_mc_info_extr, "neutrino_mc": extractors.get_neutrino_mc_info_extr,
"neutrino_data": extractors.get_real_data_info_extr,
} }
...@@ -14,21 +15,29 @@ def add_parser(subparsers): ...@@ -14,21 +15,29 @@ def add_parser(subparsers):
"graph", "graph",
description='Produce graph dl file from aanet file.') description='Produce graph dl file from aanet file.')
parser.add_argument('infile', type=str) parser.add_argument('infile', type=str)
parser.add_argument('config', type=str) parser.add_argument('toml_file', type=str)
parser.add_argument('detx_file', type=str) parser.add_argument('--detx_file', type=str, default=None)
parser.add_argument('--outfile', type=str, default=None) parser.add_argument('--outfile', type=str, default=None)
return parser.parse_args() return parser.parse_args()
def make_graph(infile, config, detx_file, outfile=None): def make_graph(infile, toml_file, detx_file=None, outfile=None):
if outfile is None: if outfile is None:
outfile = f"{os.path.splitext(os.path.basename(infile))[0]}_dl.h5" outfile = f"{os.path.splitext(os.path.basename(infile))[0]}_dl.h5"
cfg = toml.load(config) cfg = toml.load(toml_file)
extractor_cfg = cfg.pop("extractor") if "detx_file" in cfg:
extractor_name = extractor_cfg.pop("name") if detx_file is not None:
inps = {"infile": infile, "config": config, "detx_file": detx_file, "outfile": outfile} raise ValueError
extractor = EXTRACTORS[extractor_name](inps, **extractor_cfg) detx_file = cfg.pop("detx_file")
extractor_name = cfg.pop("extractor")
if "extractor_config" in cfg:
extractor_cfg = cfg.pop("extractor_config")
else:
extractor_cfg = {}
extractor = EXTRACTORS[extractor_name](infile, **extractor_cfg)
FileGraph( FileGraph(
det_file=detx_file, det_file=detx_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