Source code for km3dq_grl

import atexit
import sys

try:
    from importlib.metadata import version as get_version
[docs] version = get_version(__name__)
except ImportError: from pkg_resources import get_distribution version = get_distribution(__name__).version from .calc import Calculator if sys.version_info < (3, 9): import importlib_resources try: from importlib_resources import as_file except ImportError: from importlib_resources.trees import as_file else: import importlib.resources as importlib_resources from importlib.resources import as_file try: from contextlib import ExitStack except ImportError: from contextlib2 import ExitStack ###############################################################################
[docs] def get_site(det): """Return the site of a detector""" if "ARCA" in det: return "ARCA" return "ORCA"
###############################################################################
[docs] def defect_path(defect_type, defect_descr, det, defect_tag): """Return the absolute filepath for a given defect""" rel_path = ( f"{get_site(det)}/{det}/Defects/" f"{defect_type}_{defect_descr}_{defect_tag}.txt" ) ref = importlib_resources.files("km3dq_grl") / rel_path file_manager = ExitStack() atexit.register(file_manager.close) file_path = file_manager.enter_context(as_file(ref)) return str(file_path)
###############################################################################
[docs] def fact_path(fact_type, det): """Return the absolute filepath for a given defect""" rel_path = f"{get_site(det)}/{det}/Facts/{fact_type}.txt" ref = importlib_resources.files("km3dq_grl") / rel_path file_manager = ExitStack() atexit.register(file_manager.close) file_path = file_manager.enter_context(as_file(ref)) return str(file_path)