def __init__( self, label=None, simtelSourcePath=None, filesLocation=None, ): ''' SimtelRunner. Parameters ---------- 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. ''' self._logger = logging.getLogger(__name__) self._simtelSourcePath = Path( cfg.getConfigArg('simtelPath', simtelSourcePath)) self.label = label # File location self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self.RUNS_PER_SET = 1
def __init__( self, site, layoutName, label=None, keepSeeds=False, filesLocation=None, simtelSourcePath=None, corsikaParametersFile=None, corsikaConfigData=None, corsikaConfigFile=None ): ''' CorsikaRunner init. Parameters ---------- site: str South or North. layoutName: str Name of the layout. label: str Instance label. keepSeeds: bool If True, seeds generated by CorsikaConfig, based on the \ run number and the primary particle will be used. \ If False, random seeds will be defined automatically by sim_telarray. filesLocation: str or Path. Location of the output files. If not given, it will be set from \ the config.yml file. simtelSourcePath: str or Path Location of source of the sim_telarray/CORSIKA package. corsikaConfigData: dict Dict with CORSIKA config data. corsikaConfigFile: str or Path Path to yaml file containing CORSIKA config data. corsikaParametersFile: str or Path Path to yaml file containing CORSIKA parameters. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init CorsikaRunner') self.label = label self.site = names.validateSiteName(site) self.layoutName = names.validateLayoutArrayName(layoutName) self._keepSeeds = keepSeeds self._simtelSourcePath = Path(cfg.getConfigArg('simtelPath', simtelSourcePath)) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._outputDirectory = io.getCorsikaOutputDirectory(self._filesLocation, self.label) self._outputDirectory.mkdir(parents=True, exist_ok=True) self._logger.debug('Creating output dir {}, if needed,'.format(self._outputDirectory)) corsikaConfigData = collectDataFromYamlOrDict(corsikaConfigFile, corsikaConfigData) self._loadCorsikaConfigData(corsikaConfigData) self._loadCorsikaDataDirectories()
def __init__(self, site, telescopeModelName, modelVersion='Current', label=None, modelFilesLocations=None, filesLocation=None, readFromDB=True): ''' TelescopeModel. Parameters ---------- site: str South or North. telescopeModelName: str Telescope name (ex. LST-1, ...). modelVersion: str, optional Version of the model (ex. prod4) (default='Current'). label: str, optional Instance label. Important for output file naming. modelFilesLocation: str (or Path), optional Location of the MC model files. 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. readFromDB: bool, optional If True, parameters will be loaded from the DB at the init level. (default=True). ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init TelescopeModel') self.site = names.validateSiteName(site) self.name = names.validateTelescopeModelName(telescopeModelName) self.modelVersion = names.validateModelVersionName(modelVersion) self.label = label self._extraLabel = None self._modelFilesLocations = cfg.getConfigArg('modelFilesLocations', modelFilesLocations) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._parameters = dict() if readFromDB: self._loadParametersFromDB() self._setConfigFileDirectoryAndName() self._isConfigFileUpdated = False
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, label=None, arrayConfigFile=None, arrayConfigData=None, modelFilesLocations=None, filesLocation=None): ''' ArrayModel. Parameters ---------- arrayConfigFile: str Path to a yaml file with the array config data. arrayConfigData: dict Dict with the array config data. label: str, optional Instance label. Important for output file naming. modelFilesLocation: str (or Path), optional Location of the MC model files. 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. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init ArrayModel') self.label = label self.site = None self.layout = None self.layoutName = None self.modelVersion = None self._modelFilesLocations = cfg.getConfigArg('modelFilesLocations', modelFilesLocations) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) arrayConfigData = collectDataFromYamlOrDict(arrayConfigFile, arrayConfigData) self._loadArrayData(arrayConfigData) self._setConfigFileDirectory() self._buildArrayModel()
def __init__(self, label=None, filesLocation=None, simtelSourcePath=None, configData=None, configFile=None): ''' ArraySimulator init. Parameters ---------- label: str Instance label. filesLocation: str or Path. Location of the output files. If not given, it will be set from \ the config.yml file. simtelSourcePath: str or Path Location of source of the sim_telarray/CORSIKA package. configData: dict Dict with configurable data. configFile: str or Path Path to yaml file containing configurable data. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init ArraySimulator') self.label = label self._simtelSourcePath = Path( cfg.getConfigArg('simtelPath', simtelSourcePath)) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) configData = gen.collectDataFromYamlOrDict(configFile, configData) self._loadArrayConfigData(configData) self._setSimtelRunner() # Storing list of files self._results = dict() self._results['output'] = list() self._results['input'] = list() self._results['log'] = list()
def __init__( self, label=None, filesLocation=None, simtelSourcePath=None, showerConfigData=None, showerConfigFile=None ): ''' ShowerSimulator init. Parameters ---------- label: str Instance label. filesLocation: str or Path. Location of the output files. If not given, it will be set from \ the config.yml file. simtelSourcePath: str or Path Location of source of the sim_telarray/CORSIKA package. showerConfigData: dict Dict with shower config data. showerConfigFile: str or Path Path to yaml file containing shower config data. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init CorsikaRunner') self.label = label self._simtelSourcePath = Path(cfg.getConfigArg('simtelPath', simtelSourcePath)) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) self._outputDirectory = io.getCorsikaOutputDirectory(self._filesLocation, self.label) self._outputDirectory.mkdir(parents=True, exist_ok=True) self._logger.debug( 'Output directory {} - creating it, if needed.'.format(self._outputDirectory) ) showerConfigData = collectDataFromYamlOrDict(showerConfigFile, showerConfigData) self._loadShowerConfigData(showerConfigData) self._setCorsikaRunner()
def __init__(self, site, layoutName, label=None, filesLocation=None, corsikaConfigData=None, corsikaConfigFile=None, corsikaParametersFile=None): ''' CorsikaConfig init. Parameters ---------- site: str South or North. layoutName: str Name of the layout. layout: LayoutArray Instance of LayoutArray. label: str Instance label. filesLocation: str or Path. Main location of the output files. corsikaConfigData: dict Dict with CORSIKA config data. corsikaConfigFile: str or Path Path to yaml file containing CORSIKA config data. corsikaParametersFile: str or Path Path to yaml file containing CORSIKA parameters. ''' self._logger = logging.getLogger(__name__) self._logger.debug('Init CorsikaConfig') self.label = label self.site = names.validateSiteName(site) self._filesLocation = cfg.getConfigArg('outputLocation', filesLocation) # Grabbing layout name and building LayoutArray self.layoutName = names.validateLayoutArrayName(layoutName) self.layout = LayoutArray.fromLayoutArrayName(self.site + '-' + self.layoutName, label=self.label) # Load parameters self._loadCorsikaParametersFile(corsikaParametersFile) corsikaConfigData = collectDataFromYamlOrDict(corsikaConfigFile, corsikaConfigData) self.setUserParameters(corsikaConfigData) self._isFileUpdated = False
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): ''' 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)