def __init__(self, telescopeModel, label=None, simtelSourcePath=None, filesLocation=None, configData=None, configFile=None, singleMirrorMode=False): ''' SimtelRunner. Parameters ---------- telescopeModel: str Instance of TelescopeModel class. label: str, optional Instance label. Important for output file naming. simtelSourcePath: str (or Path), optional Location of sim_telarray installation. If not given, it will be taken from the config.yml file. filesLocation: str (or Path), optional Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. singleMirrorMode: bool True for single mirror simulations. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init SimtelRunnerRayTracing') super().__init__(label=label, simtelSourcePath=simtelSourcePath, filesLocation=filesLocation) self.telescopeModel = self._validateTelescopeModel(telescopeModel) self.label = label if label is not None else self.telescopeModel.label # File location self._baseDirectory = io.getOutputDirectory(self._filesLocation, self.label, 'ray-tracing') self._baseDirectory.mkdir(parents=True, exist_ok=True) self._singleMirrorMode = singleMirrorMode # RayTracing - default parameters self._repNumber = 0 self.RUNS_PER_SET = 1 if self._singleMirrorMode else 20 self.PHOTONS_PER_RUN = 10000 # Loading configData _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData) _parameterFile = io.getDataFile( 'parameters', 'simtel-runner-ray-tracing_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) self._loadRequiredFiles()
def _loadArrayConfigData(self, configData): ''' Load configData, create arrayModel and store reamnining parameters in config. ''' _arrayModelConfig, _restConfig = self._collectArrayModelParameters( configData) _parameterFile = io.getDataFile('parameters', 'array-simulator_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_restConfig, _parameters) self.arrayModel = ArrayModel(label=self.label, arrayConfigData=_arrayModelConfig)
def __init__(self, label=None, name=None, filesLocation=None, configData=None, configFile=None): ''' LayoutArray init. Parameters ---------- name: str Name of the telescope (e.g L-01, S-05, ...) label: str Instance label. filesLocation: str (or Path), optional Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init LayoutArray') self.label = label self.name = name self._telescopeList = [] # Loading configData _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData, allowEmpty=True) _parameterFile = io.getDataFile('parameters', 'layout-array_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) # Making config entries into attributes for par, value in zip(self.config._fields, self.config): self.__dict__['_' + par] = value self._loadArrayCenter() # Output directory self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._outputDirectory = io.getLayoutOutputDirectory( self._filesLocation, self.label) self._outputDirectory.mkdir(parents=True, exist_ok=True)
def __init__(self, telescopeModel, label=None, simtelSourcePath=None, filesLocation=None, configData=None, configFile=None): ''' CameraEfficiency init. Parameters ---------- telescopeModel: TelescopeModel Instance of the TelescopeModel class. label: str Instance label, optional. simtelSourcePath: str (or Path), optional. Location of sim_telarray installation. If not given, it will be taken from the config.yml file. filesLocation: str (or Path), optional. Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. ''' self._logger = logging.getLogger(__name__) self._simtelSourcePath = Path( cfg.getConfigArg('simtelPath', simtelSourcePath)) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._telescopeModel = self._validateTelescopeModel(telescopeModel) self.label = label if label is not None else self._telescopeModel.label self._baseDirectory = io.getCameraEfficiencyOutputDirectory( self._filesLocation, self.label) self._baseDirectory.mkdir(parents=True, exist_ok=True) self._hasResults = False _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData, allowEmpty=True) _parameterFile = io.getDataFile('parameters', 'camera-efficiency_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) self._loadFiles()
def __init__(self, arrayModel, label=None, simtelSourcePath=None, filesLocation=None, configData=None, configFile=None): ''' SimtelRunnerArray. Parameters ---------- arrayModel: str Instance of TelescopeModel class. label: str, optional Instance label. Important for output file naming. simtelSourcePath: str (or Path), optional Location of sim_telarray installation. If not given, it will be taken from the config.yml file. filesLocation: str (or Path), optional Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init SimtelRunnerArray') super().__init__(label=label, simtelSourcePath=simtelSourcePath, filesLocation=filesLocation) self.arrayModel = self._validateArrayModel(arrayModel) self.label = label if label is not None else self.arrayModel.label # File location self._baseDirectory = io.getOutputDirectory(self._filesLocation, self.label, 'array') self._baseDirectory.mkdir(parents=True, exist_ok=True) # Loading configData _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData) _parameterFile = io.getDataFile('parameters', 'simtel-runner-array_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) self._loadSimtelDataDirectories()
def _loadCorsikaParametersFile(self, filename): ''' Load CORSIKA parameters from a given file (filename not None), or from the default parameter file provided in the data directory (filename is None). ''' if filename is not None: # User provided file. self._corsikaParametersFile = filename else: # Default file from data directory. self._corsikaParametersFile = io.getDataFile( 'corsika', 'corsika_parameters.yml') self._logger.debug('Loading CORSIKA parameters from file {}'.format( self._corsikaParametersFile)) with open(self._corsikaParametersFile, 'r') as f: self._corsikaParameters = yaml.load(f)
def __init__(self, name=None, prodId=dict(), configData=None, configFile=None): ''' TelescopeData init. Parameters ---------- name: str Name of the telescope (e.g L-01, S-05, ...) prodId: dict ... configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init TelescopeData') self.name = name self._prodId = prodId # Loading configData _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData, allowEmpty=True) _parameterFile = io.getDataFile('parameters', 'telescope-data_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) # Making config entries into attributes for par, value in zip(self.config._fields, self.config): self.__dict__['_' + par] = value
def fromLayoutArrayName(cls, layoutArrayName, label=None, filesLocation=None): ''' Create a LayoutArray from a layout name (e.g. South-4LST, North-Prod5, ...) Parameters ---------- layoutArrayName: str e.g. South-4LST, North-Prod5 ... label: str, optional Instance label. Important for output file naming. filesLocation: str (or Path), optional Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. Returns ------- Instance of the LayoutArray class. ''' spl = layoutArrayName.split('-') siteName = names.validateSiteName(spl[0]) arrayName = names.validateLayoutArrayName(spl[1]) validLayoutArrayName = siteName + '-' + arrayName layout = cls(name=validLayoutArrayName, label=label, filesLocation=filesLocation) telescopeListFile = io.getDataFile( 'layout', 'telescope_positions-{}.ecsv'.format(validLayoutArrayName)) layout.readTelescopeListFile(telescopeListFile) return layout
def __init__(self, telescopeModel, label=None, simtelSourcePath=None, filesLocation=None, configData=None, configFile=None): ''' RayTracing init. Parameters ---------- telescopeModel: TelescopeModel Instance of the TelescopeModel class. label: str Instance label. simtelSourcePath: str (or Path), optional Location of sim_telarray installation. If not given, it will be taken from the config.yml file. filesLocation: str (or Path), optional Parent location of the output files created by this class. If not given, it will be taken from the config.yml file. configData: dict. Dict containing the configurable parameters. configFile: str or Path Path of the yaml file containing the configurable parameters. ''' self._logger = logging.getLogger(__name__) self._simtelSourcePath = Path( cfg.getConfigArg('simtelPath', simtelSourcePath)) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._telescopeModel = self._validateTelescopeModel(telescopeModel) # Loading configData _configDataIn = gen.collectDataFromYamlOrDict(configFile, configData) _parameterFile = io.getDataFile('parameters', 'ray-tracing_parameters.yml') _parameters = gen.collectDataFromYamlOrDict(_parameterFile, None) self.config = gen.validateConfigData(_configDataIn, _parameters) self.label = label if label is not None else self._telescopeModel.label self._outputDirectory = io.getRayTracingOutputDirectory( self._filesLocation, self.label) self._outputDirectory.mkdir(parents=True, exist_ok=True) # Loading relevant attributes in case of single mirror mode. if self.config.singleMirrorMode: # Recalculating source distance. self._logger.debug( 'Single mirror mode is activate - source distance is being recalculated to 2 * flen' ) mirFlen = self._telescopeModel.getParameterValue( 'mirror_focal_length') self._sourceDistance = 2 * float(mirFlen) * u.cm.to(u.km) # km # Setting mirror numbers. if self.config.mirrorNumbers is None: self._mirrorNumbers = list( range(0, self._telescopeModel.mirrors.numberOfMirrors)) else: self._mirrorNumbers = self.config.mirrorNumbers else: self._sourceDistance = self.config.sourceDistance self._hasResults = False # Results file fileNameResults = names.rayTracingResultsFileName( self._telescopeModel.site, self._telescopeModel.name, self._sourceDistance, self.config.zenithAngle, self.label) self._outputDirectory.joinpath('results').mkdir(parents=True, exist_ok=True) self._fileResults = self._outputDirectory.joinpath('results').joinpath( fileNameResults)