Source code for constants

"""Project wide constants."""

import os
from importlib.resources import files
from pathlib import Path

CORSIKA_PATH = "/workdir/simulation_software/corsika7"

# Schema path
SCHEMA_PATH = files("simtools") / "schemas"
# Schema URL
SCHEMA_URL = "https://raw.githubusercontent.com/gammasim/simtools/main/src/simtools/schemas"
# URL for files in the main branch of the GitHub repository
GITHUB_BLOB_BASE = "https://github.com/gammasim/simtools/blob/main/"
# Path to metadata jsonschema
METADATA_JSON_SCHEMA = SCHEMA_PATH / "metadata.metaschema.yml"
# Path to plotting configuration json schema
PLOT_CONFIG_SCHEMA = SCHEMA_PATH / "plot_configuration.metaschema.yml"
# Path to run time environment json schema
RUN_TIME_ENVIRONMENT_SCHEMA = SCHEMA_PATH / "run_time_environment.schema.yml"
SCIENCE_TEST_SCHEMA_PATH = SCHEMA_PATH / "science_tests"
# Path to model parameter metaschema
MODEL_PARAMETER_METASCHEMA = SCHEMA_PATH / "model_parameter.metaschema.yml"
# Path to model parameter description metaschema
MODEL_PARAMETER_DESCRIPTION_METASCHEMA = (
    SCHEMA_PATH / "model_parameter_and_data_schema.metaschema.yml"
)
# Path to sim_telarray meta-parameter metaschema
SIM_TELARRAY_META_PARAMETER_METASCHEMA = SCHEMA_PATH / "sim_telarray_meta_parameter.metaschema.yml"
# Path to sim_telarray meta-parameter registry
SIM_TELARRAY_META_PARAMETER_REGISTRY = SCHEMA_PATH / "sim_telarray_meta_parameters.schema.yml"
# Path to model parameter schema files
MODEL_PARAMETER_SCHEMA_PATH = SCHEMA_PATH / "model_parameters"
# URL to model parameter schema files
MODEL_PARAMETER_SCHEMA_URL = SCHEMA_URL + "/model_parameters"
# Path to resource files
RESOURCE_PATH = files("simtools") / "resources"
# Paths to test resources
_DEFAULT_TEST_RESOURCES_ROOT = Path("tests/unit_tests/resources")


[docs] def get_test_resources_root(): """Return the test-resource root configured by the test harness.""" return TEST_RESOURCES_ROOT
[docs] def get_configured_test_resources_root(): """Return the test-resource root configured for an application, if any.""" if TEST_RESOURCES_ROOT != _DEFAULT_TEST_RESOURCES_ROOT: return TEST_RESOURCES_ROOT tests_path = os.environ.get("SIMTOOLS_TESTS_PATH") resource_version = _get_test_resource_version() if not tests_path or not resource_version: return None return _versioned_test_resources_path(tests_path, resource_version)
def _versioned_test_resources_path(tests_path, resource_version): """Resolve a versioned resource directory from a checkout or its parent.""" root = Path(tests_path).expanduser() if ( not (root / resource_version).is_dir() and (root / "simtools-tests" / resource_version).is_dir() ): root = root / "simtools-tests" return root / resource_version / "integration_tests" def _get_test_resource_version(): """Return the configured version of the simtools-tests resources.""" for variable in ( "SIMTOOLS_TESTS_RESOURCE_VERSION", "SIMTOOLS_TESTS_REF", "SIMTOOLS_TESTS_TAG", "SIMTOOLS_TESTS_VERSION", ): if version := os.environ.get(variable): return version return None TEST_RESOURCES_ROOT = _DEFAULT_TEST_RESOURCES_ROOT TEST_RESOURCES_STATIC = str(TEST_RESOURCES_ROOT / "static") TEST_RESOURCES_GENERATED = str(TEST_RESOURCES_ROOT / "generated") TEST_RESOURCES_DOWNLOADED = str(TEST_RESOURCES_ROOT / "downloaded") # Maximum value allowed for random seeds in sim_telarray SIMTEL_MAX_SEED = 2147483647 # Random instrument instances (mirror-error realisations) of a ray-tracing image. RAY_TRACING_INSTRUMENT_INSTANCES = 20 # Maximum include filename length accepted by sim_telarray parser (80-char getword buffer). # The include token is written as "<filename>", so keep the filename itself safely below 80 chars. SIM_TELARRAY_INCLUDE_FILENAME_MAX_LENGTH = 77 # Maximum value allowed for random seeds in CORSIKA CORSIKA_MAX_SEED = 900000000 # Default repository URLs for simulations and computing resources DEFAULT_SIMULATIONS_REPO = "https://gitlab.cta-observatory.org/cta-science/simulations" DEFAULT_COMPUTING_REPO = "https://gitlab.cta-observatory.org/cta-computing" DEFAULT_SIMULATION_WORKFLOWS = ( f"{DEFAULT_SIMULATIONS_REPO}/simulation-model/simulation-model-parameter-setting.git" ) CORSIKA_HE_INTERACTION = "epos" CORSIKA_LE_INTERACTION = "urqmd" CORSIKA_INTERACTION_TABLE_PATH = ( "/workdir/external/simpipe/simulation_software/corsika7-interaction-tables/interaction-tables/" ) # Default exponential factor for zenith-dependent total shower scaling. # Derived by the LST team for a 4-LST array, likely different for other array layouts. ZENITH_ANGLE_SCALING_FACTOR_DEFAULT = 3.9781 # Simulation software with configuration parameters that can be reported. SIMULATION_SOFTWARE_CHOICES = ("corsika", "sim_telarray")