Configuration#

Reference documentation for the configuration of simtools applications.

configurator#

Application configuration.

class configuration.configurator.Configurator(config=None, label=None, usage=None, description=None, epilog=None)[source]#

Application configuration.

Allow to set configuration parameters by

  • command line arguments

  • configuration file (yml file)

  • configuration dict when calling the class

  • environmental variables

Assigns unique ACTIVITY_ID to this configuration (uuid).

Configuration parameter names are converted always to lower case.

Parameters:
config: dict

Configuration parameters as dict.

label: str

Class label.

usage: str

Application usage description.

description: str

Text displayed as description.

epilog: str

Text display after all arguments.

default_config(arg_list=None, add_db_config=False)[source]#

Return dictionary of default configuration.

Parameters:
arg_list: list

List of arguments.

add_db_config: bool

Add DB configuration file.

Returns:
dict

Configuration parameters as dict.

initialize(require_command_line=True, paths=True, output=False, simulation_model=None, simulation_configuration=None, db_config=False, job_submission=False)[source]#

Initialize application configuration.

Configure from command line, configuration file, class config, or environmental variable.

Priorities in parameter settings. 1. command line; 2. yaml file; 3. class init; 4. env variables.

Conflicting configuration settings raise an Exception, with the exception of settings from environmental variables, which are only done when the configuration parameter is None.

Parameters:
require_command_line: bool

Require at least one command line argument.

paths: bool

Add path configuration to list of args.

output: bool

Add output file configuration to list of args.

simulation_model: list

List of simulation model configuration parameters to add to list of args

simulation_configuration: list

List of simulation software configuration parameters to add to list of args.

db_config: bool

Add database configuration parameters to list of args.

job_submission: bool

Add job submission configuration to list of args.

Returns:
dict

Configuration parameters as dict.

dict

Dictionary with DB parameters

exception configuration.configurator.InvalidConfigurationParameterError[source]#

Exception for Invalid configuration parameter.

commandline_parser#

Command line parser for applications.

class configuration.commandline_parser.CommandLineParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]#

Command line parser for applications.

Wrapper around standard python argparse.ArgumentParser.

Command line arguments should be given in snake_case, e.g. input_meta.

Parameters:
argparse.ArgumentParser class

Object for parsing command line strings into Python objects. For a list of keywords, please refer to argparse.ArgumentParser documentation.

static azimuth_angle(angle)[source]#

Argument parser type to check that the azimuth angle provided is in the interval [0, 360].

Other allowed options are north, south, east or west which will be translated to an angle where north corresponds to zero.

Parameters:
angle: float or str

azimuth angle to verify or convert

Returns:
Astropy.Quantity

Validated/Converted azimuth angle in degrees

Raises:
argparse.ArgumentTypeError

When angle is outside of the interval [0, 360] or not in (north, south, east, west)

static efficiency_interval(value)[source]#

Argument parser type to check that value is an efficiency in the interval [0,1].

Parameters:
value: float

value provided through the command line

Returns:
float

Validated efficiency interval

Raises:
argparse.ArgumentTypeError

When value is outside of the interval [0,1]

initialize_application_execution_arguments()[source]#

Initialize application execution arguments.

initialize_config_files()[source]#

Initialize configuration files.

initialize_db_config_arguments()[source]#

Initialize DB configuration parameters.

initialize_default_arguments(paths=True, output=False, simulation_model=None, simulation_configuration=None, db_config=False, job_submission=False)[source]#

Initialize default arguments used by all applications (e.g., verbosity or test flag).

Parameters:
paths: bool

Add path configuration to list of args.

output: bool

Add output file configuration to list of args.

simulation_model: list

List of simulation model configuration parameters to add to list of args (use: ‘version’, ‘telescope’, ‘site’)

simulation_configuration: list

List of simulation software configuration parameters to add to list of args.

db_config: bool

Add database configuration parameters to list of args.

job_submission: bool

Add job submission configuration parameters to list of args.

initialize_job_submission_arguments()[source]#

Initialize job submission arguments for simulator.

initialize_output_arguments()[source]#

Initialize application output files(s).

initialize_path_arguments()[source]#

Initialize paths.

initialize_simulation_configuration_arguments(simulation_configuration)[source]#

Initialize default arguments for simulation configuration and simulation software.

Parameters:
simulation_configuration: list

List of simulation software configuration parameters.

initialize_simulation_model_arguments(model_options)[source]#

Initialize default arguments for simulation model definition.

Note that the model version is always required.

Parameters:
model_options: list

Options to be set: “telescope”, “site”, “layout”, “layout_file”

static parse_integer_and_quantity(input_string)[source]#

Parse a string representing an integer and a quantity with units.

This is e.g., used for the ‘core_scatter’ argument.

Parameters:
input_string: str

The input string (e.g., “5 1500 m”).

Returns:
tuple: A tuple containing an integer and an astropy.units.Quantity object.
Raises:
ValueError: If the input string does not match the required format.
static parse_quantity_pair(string)[source]#

Parse a string representing a pair of astropy quantities separated by a space.

Args:

string: The input string (e.g., “0 deg 1.5 deg”).

Returns:
tuple: A tuple containing two astropy.units.Quantity objects.
Raises:
ValueError: If the string is not formatted correctly (e.g., missing space).
static site(value)[source]#

Argument parser type to check that a valid site name is given.

Parameters:
value: str

site name

Returns:
str

Validated site name

Raises:
argparse.ArgumentTypeError

for invalid sites

static telescope(value)[source]#

Argument parser type to check that a valid telescope name is given.

Parameters:
value: str

telescope name

Returns:
str

Validated telescope name

Raises:
argparse.ArgumentTypeError

for invalid telescope

static zenith_angle(angle)[source]#

Argument parser type to check that the zenith angle provided is in the interval [0, 180].

We allow here zenith angles larger than 90 degrees in the improbable case such simulations are requested. It is not guaranteed that the actual simulation software supports such angles!.

Parameters:
angle: float, str, astropy.Quantity

zenith angle to verify

Returns:
Astropy.Quantity

Validated zenith angle in degrees

Raises:
argparse.ArgumentTypeError

When angle is outside of the interval [0, 180]