diff --git a/docs/getting_started.rst b/docs/getting_started.rst index b4de5da1a06d9ca40a68f43f1784e63876f0862f..612e39c843ac344070d10fea82a9fd7e96c44734 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -29,7 +29,10 @@ If you have an orcasong config file, you can use it via the command line like th orcasong run aanet_file.h5 orcasong_config.toml --detx_file detector.detx -Check out the git repo here https://git.km3net.de/ml/OrcaSong/-/tree/master/examples for some examples of config files. +For some examples of config files you can check out the git repo here +https://git.km3net.de/ml/OrcaSong/-/tree/master/examples . +These can be loaded from the command line by using the prefix +``orcasong:`` before the filename, e.g. ``orcasong:orcasong_bundle_mupage.toml``. Alternatively, you can use the python frontend of orcasong. See :ref:`orcasong_page` for instructions on how to do this. diff --git a/orcasong/from_toml.py b/orcasong/from_toml.py index 0bf6e723dd204b1b11299fd5eabe2a08f1101206..b22bf115cf65fcb3da6f65af28074b5068852d3c 100644 --- a/orcasong/from_toml.py +++ b/orcasong/from_toml.py @@ -1,3 +1,5 @@ +import os +from pathlib import Path import toml import orcasong.core import orcasong.extractors as extractors @@ -24,7 +26,9 @@ def add_parser_run(subparsers): "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="Orcasong configuration in toml format.") + parser.add_argument('toml_file', type=str, help=( + "Orcasong configuration in toml format. Use prefix 'orcasong:' to load " + "a toml from OrcaSong/examples.")) 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.")) @@ -39,6 +43,8 @@ def run_orcasong(infile, toml_file, detx_file=None, outfile=None): def setup_processor(infile, toml_file, detx_file=None): + if toml_file.startswith("orcasong:"): + toml_file = _get_from_examples(toml_file[9:]) cfg = toml.load(toml_file) processor = _get_verbose(cfg.pop("mode"), MODES) @@ -64,3 +70,9 @@ def _get_verbose(key, d): if key not in d: raise KeyError(f"Unknown key '{key}' (available: {list(d.keys())})") return d[key] + + +def _get_from_examples(filename): + direc = os.path.join(Path(orcasong.core.__file__).parents[1], "examples") + files = {file: os.path.join(direc, file) for file in os.listdir(direc)} + return _get_verbose(filename, files)