Configuration#

Reference documentation for the configuration of simtools applications.

configurator#

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]#

Returns 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, db_config=False, job_submission=False)[source]#

Initialize configuration 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 (use: ‘version’, ‘telescope’, ‘site’)

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#

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, 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’)

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_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”

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]