def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Get datapath if not already set if self._datapath == '': self._datapath = self['datapath'].string() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get filename of master index file self._master_indx = self['master_indx'].string() self._master_file = os.path.join(self._datapath, self._master_indx) # Check for presence of master index file if not os.path.isfile(self._master_file): raise RuntimeError('Master index file "'+self._master_file+ '" not found. Use hidden parameter '+ '"master_indx" to specifiy a different '+ 'filename.') # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Get datapath if not already set if self._datapath == '': self._datapath = self['datapath'].string() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get filename of master index file self._master_indx = self['master_indx'].string() self._master_file = os.path.join(self._datapath, self._master_indx) # Check for presence of master index file if not os.path.isfile(self._master_file): raise RuntimeError('Master index file "' + self._master_file + '" not found. Use hidden parameter ' + '"master_indx" to specifiy a different ' + 'filename.') # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Query datapath. If the parameter is not NONE then use it, otherwise # use the datapath from the VHEFITS environment variable datapath = self['datapath'].string() if gammalib.toupper(datapath) != 'NONE': self._datapath = datapath else: self._datapath = os.getenv('VHEFITS', '') # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get filename of master index file self._master_indx = self['master_indx'].string() self._master_file = os.path.join(self._datapath, self._master_indx) # Check for presence of master index file if not os.path.isfile(self._master_file): raise RuntimeError('Master index file "' + self._master_file + '" not found. Use hidden parameter ' + '"master_indx" to specifiy a different ' + 'filename.') # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Get Parameters self._remote_master = self['remote_master'].filename() if not self._remote_master.exists(): raise RuntimeError('*** ERROR: FITS data not available. No ' 'master index file found in "' + self._remote_master + '". Make sure remote ' 'file system is properly mounted.') # Get parameters self._prodname = self['prodname'].string() self._outpath = gammalib.expand_env(self['outpath'].string()) self._runlist = self['runlist'].filename() # Write input parameters into logger if self._logTerse(): self._log_parameters() self._log('\n') # Return return
def get_parameters(self): """ Get parameters from parfile and setup the observation. """ # Get datapath if not already set if self.datapath == "": self.datapath = self["datapath"].string() # Expand environment self.datapath = gammalib.expand_env(self.datapath) # Get filename of master index file self.m_master_indx = self["master_indx"].string() self.m_master_file = os.path.join(self.datapath, self.m_master_indx) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Get Parameters self._remote_master = self['remote_master'].filename() if not self._remote_master.exists(): raise RuntimeError('*** ERROR: FITS data not available. No ' 'master index file found in "'+ self._remote_master+'". Make sure remote ' 'file system is properly mounted.') # Get parameters self._prodname = self['prodname'].string() self._outpath = gammalib.expand_env(self['outpath'].string()) self._runlist = self['runlist'].filename() # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Set data path if self._datapath == '': self._datapath = self['datapath'].string() # Query input parameters self['inmodel'].filename() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Read FITS production self._prodname = self['prodname'].string() # Read runlist file if list not already filled if len(self._runlist) == 0: # Get file name self._runlistfile = self['infile'].filename() # Read runlist from file runfile = open(self._runlistfile.url()) for line in runfile.readlines(): if len(line) == 0: continue if line[0] == '#': continue if len(line.split()) > 0: self._runlist.append(line.split()[0]) runfile.close() # Read number of background parameters self._bkgpars = self['bkgpars'].integer() # Query ahead output parameters if self._read_ahead(): self['outmodel'].filename() self['outobs'].filename() # Master index file name self._master_indx = self['master_indx'].string() # Read flag for background scaling factor self._use_bkg_scale = self['bkg_scale'].boolean() # Read hierarchy of file loading self._ev_hiera = self['ev_hiera'].string().split('|') self._aeff_hiera = self['aeff_hiera'].string().split('|') self._psf_hiera = self['psf_hiera'].string().split('|') self._bkg_hiera = self['bkg_hiera'].string().split('|') self._edisp_hiera = self['edisp_hiera'].string().split('|') self._bkg_mod_hiera = self['bkg_mod_hiera'].string().split('|') # Read hidden background parameters self._bkg_gauss_norm = self['bkg_gauss_norm'].real() self._bkg_gauss_index = self['bkg_gauss_index'].real() self._bkg_gauss_sigma = self['bkg_gauss_sigma'].real() self._bkg_aeff_index = self['bkg_aeff_index'].real() self._bkg_aeff_norm = self['bkg_aeff_norm'].real() self._bkg_range_factor = self['bkg_range_factor'].real() # Open master index file and look for prodname master_file = os.path.join(self._datapath, self._master_indx) if not os.path.isfile(master_file): raise RuntimeError('FITS data store not available. No master index file found. Make sure the file is copied from the server and your datapath is set correctly.') # Open and load JSON file json_data = open(master_file).read() data = json.loads(json_data) if not 'datasets' in data: raise RuntimeError('Key "datasets" not available in master index file.') # Get configurations configs = data['datasets'] # Initialise HDUs self._hdu_index = self._obs_index = '' # Get HDUs for config in configs: # Check if prodname is present if self._prodname == config['name']: self._hdu_index = str(os.path.join(self._datapath, config['hduindx'])) self._obs_index = str(os.path.join(self._datapath, config['obsindx'])) # Leave loop if index file names were found break # Check index files if self._hdu_index == '' or self._obs_index == '': raise RuntimeError('*** ERROR: FITS data store "'+self._prodname+'" not available. Run csiactdata to get a list of available storage names') # Check HDU names filename = gammalib.GFilename(self._hdu_index+'[HDU_INDEX]') if not filename.is_fits(): raise RuntimeError('*** ERROR: HDU index file "'+self._hdu_index+'[HDU_INDEX]" for FITS data store "'+self._prodname+'" not available. Check your master index file or run csiactdata to get a list of available storage names.') # Check for existence of 'BKG_SCALE' in the observation index file if required if self._use_bkg_scale: # Create filename filename = gammalib.GFilename(self._obs_index+'[OBS_INDEX]') # Check if it is a FITS file if filename.is_fits(): # Open FITS file fits = gammalib.GFits(self._obs_index) # Check if column "BKG_SCALE" is found and signal its possible usage if not fits['OBS_INDEX'].contains('BKG_SCALE'): self._use_bkg_scale = False # Close FITS file fits.close() else: # Signal that there is no background scale self._use_bkg_scale = False # Create base data directory from hdu index file location self._subdir = os.path.dirname(self._hdu_index) self._debug = False # Debugging in client tools # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation. """ # Get parameters if self._datapath == '': self._datapath = self['datapath'].string() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get production name self._prodname = self['prodname'].string() # Master index file name master_indx = self['master_indx'].string() # Initialise flag if spatial selection is required self._select_radec = True # Initialise invalid radius self._radius = 0.0 # Check for validity of spatial parameters if (self['ra'].is_valid() and self['dec'].is_valid() and self['rad'].is_valid()): # Read spatial parameters self._ra = self['ra'].real() self._dec = self['dec'].real() self._radius = self['rad'].real() # ... otherwise signal that there are no spatial parameters for # selection else: self._select_radec = False # Check Radius for validity if self._radius <= 0.0: self._select_radec = False # Query other parameters self['min_qual'].integer() self['expression'].string() # Read ahead output parameters if self._read_ahead(): self['outfile'].filename() # Set filename of JSON master file and raise an exception if the file # does not exist master_file = os.path.join(self._datapath, master_indx) if not os.path.isfile(master_file): msg = ('FITS data store not available. No master index file found ' 'at "%s". Make sure the file is copied from the server and ' 'your datapath is set correctly.' % master_file) raise RuntimeError(msg) # Open and load JSON master file. If the "dataset" key is not available # then raise an exception json_data = open(master_file).read() data = json.loads(json_data) if not 'datasets' in data: msg = ('Key "datasets" not available in master index file.') raise RuntimeError(msg) # Get configurations from JSON master file configs = data['datasets'] # Initialise obs index file self._obs_index = '' # Get name of observation index file for config in configs: if self._prodname == config['name']: self._obs_index = str( os.path.join(self._datapath, config['obsindx'])) break # If the observation index file name is empty then raise an exception if self._obs_index == '': msg = ('FITS data store "%s" not available. Run csiactdata to get ' 'a list of available storage names.' % self._prodname) raise RuntimeError(msg) # If the observation index file is not a FITS file then raise an # exception filename = gammalib.GFilename(self._obs_index + '[OBS_INDEX]') if not filename.is_fits(): msg = ( 'Observation index file "%s[OBS_INDEX]" for FITS data store ' '"%s" not available. Check your master index file or run ' 'csiactdata to get a list of available storage names.' % (self._obs_index, self._prodname)) raise RuntimeError(msg) # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation """ # Set data path if self._datapath == '': self._datapath = self['datapath'].string() # Query input parameters self['inmodel'].filename() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Read FITS production self._prodname = self['prodname'].string() # Read runlist file if list not already filled if len(self._runlist) == 0: # Get file name self._runlistfile = self['infile'].filename() # Read runlist from file runfile = open(self._runlistfile.url()) for line in runfile.readlines(): if len(line) == 0: continue if line[0] == '#': continue if len(line.split()) > 0: self._runlist.append(line.split()[0]) runfile.close() # Read number of background parameters self._bkgpars = self['bkgpars'].integer() # Query ahead output parameters if self._read_ahead(): self['outmodel'].filename() self['outobs'].filename() # Master index file name self._master_indx = self['master_indx'].string() # Read flag for background scaling factor self._use_bkg_scale = self['bkg_scale'].boolean() # Read hierarchy of file loading self._ev_hiera = self['ev_hiera'].string().split('|') self._aeff_hiera = self['aeff_hiera'].string().split('|') self._psf_hiera = self['psf_hiera'].string().split('|') self._bkg_hiera = self['bkg_hiera'].string().split('|') self._edisp_hiera = self['edisp_hiera'].string().split('|') self._bkg_mod_hiera = self['bkg_mod_hiera'].string().split('|') # Read hidden background parameters self._bkg_gauss_norm = self['bkg_gauss_norm'].real() self._bkg_gauss_index = self['bkg_gauss_index'].real() self._bkg_gauss_sigma = self['bkg_gauss_sigma'].real() self._bkg_aeff_index = self['bkg_aeff_index'].real() self._bkg_aeff_norm = self['bkg_aeff_norm'].real() self._bkg_range_factor = self['bkg_range_factor'].real() # Open master index file and look for prodname master_file = os.path.join(self._datapath, self._master_indx) if not os.path.isfile(master_file): raise RuntimeError( 'FITS data store not available. No master index file found. Make sure the file is copied from the server and your datapath is set correctly.' ) # Open and load JSON file json_data = open(master_file).read() data = json.loads(json_data) if not 'datasets' in data: raise RuntimeError( 'Key "datasets" not available in master index file.') # Get configurations configs = data['datasets'] # Initialise HDUs self._hdu_index = self._obs_index = '' # Get HDUs for config in configs: # Check if prodname is present if self._prodname == config['name']: self._hdu_index = str( os.path.join(self._datapath, config['hduindx'])) self._obs_index = str( os.path.join(self._datapath, config['obsindx'])) # Leave loop if index file names were found break # Check index files if self._hdu_index == '' or self._obs_index == '': raise RuntimeError( '*** ERROR: FITS data store "' + self._prodname + '" not available. Run csiactdata to get a list of available storage names' ) # Check HDU names filename = gammalib.GFilename(self._hdu_index + '[HDU_INDEX]') if not filename.is_fits(): raise RuntimeError( '*** ERROR: HDU index file "' + self._hdu_index + '[HDU_INDEX]" for FITS data store "' + self._prodname + '" not available. Check your master index file or run csiactdata to get a list of available storage names.' ) # Check for existence of 'BKG_SCALE' in the observation index file if required if self._use_bkg_scale: # Create filename filename = gammalib.GFilename(self._obs_index + '[OBS_INDEX]') # Check if it is a FITS file if filename.is_fits(): # Open FITS file fits = gammalib.GFits(self._obs_index) # Check if column "BKG_SCALE" is found and signal its possible usage if not fits['OBS_INDEX'].contains('BKG_SCALE'): self._use_bkg_scale = False # Close FITS file fits.close() else: # Signal that there is no background scale self._use_bkg_scale = False # Create base data directory from hdu index file location self._subdir = os.path.dirname(self._hdu_index) self._debug = False # Debugging in client tools # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return
def get_parameters(self): """ Get parameters from parfile and setup the observation. """ if self.datapath == "": self.datapath = self["datapath"].string() # Expand environment self.datapath = gammalib.expand_env(self.datapath) # Read user parameters self.m_prodname = self["prodname"].string() self.m_runlistfile = gammalib.expand_env(self["runlistfile"].filename()) self.m_bkgpars = self["bkgpars"].integer() # Output model file self.outmodel = self["outmodel"].filename() # Observation outfile self.outobs = self["outobs"].filename() # Master index file name self.m_master_indx = self["master_indx"].string() # Read hierarchy of file loading self.m_ev_hiera = self["ev_hiera"].string().split("|") self.m_aeff_hiera = self["aeff_hiera"].string().split("|") self.m_psf_hiera = self["psf_hiera"].string().split("|") self.m_bkg_hiera = self["bkg_hiera"].string().split("|") self.m_edisp_hiera = self["edisp_hiera"].string().split("|") self.m_bkg_mod_hiera = self["bkg_mod_hiera"].string().split("|") # Read hidden background parameters self.m_bkg_gauss_norm = self["bkg_gauss_norm"].real() self.m_bkg_gauss_index = self["bkg_gauss_index"].real() self.m_bkg_gauss_sigma = self["bkg_gauss_sigma"].real() self.m_bkg_aeff_index = self["bkg_aeff_index"].real() self.m_bkg_aeff_norm = self["bkg_aeff_norm"].real() self.m_bkg_range_factor = self["bkg_range_factor"].real() # Open master index file and look for prodname master_file = os.path.join(self.datapath, self.m_master_indx) if not os.path.isfile(master_file): raise RuntimeError("FITS data store not available. No master index file found. Make sure the file is copied from the server and your datapath is set correctly.") # Open and load JSON file json_data = open(master_file).read() data = json.loads(json_data) if not "datasets" in data: raise RuntimeError("Key \"datasets\" not available in master index file.") # Get configurations configs = data["datasets"] # Initialise HDUs self.m_hdu_index = self.m_obs_index = "" # Get HDUs for config in configs: if self.m_prodname == config["name"]: self.m_hdu_index = str(os.path.join(self.datapath, config["hduindx"])) self.m_obs_index = str(os.path.join(self.datapath, config["obsindx"])) break # Check HDUs if self.m_hdu_index == "" or self.m_obs_index == "": raise RuntimeError("FITS data store \""+self.m_prodname+"\" not available. Run csdsinfo to get a list of available storage names") if not gammalib.is_fits(self.m_hdu_index+"[HDU_INDEX]"): raise RuntimeError("HDU index file \""+self.m_hdu_index+"[HDU_INDEX]\" for FITS data store \""+self.m_prodname+"\" not available. Check your master index file or run csdsinfo to get a list of available storage names.") # Load index if gammalib.is_fits(self.m_obs_index+"[OBS_INDEX]"): fits = gammalib.GFits(self.m_obs_index) self.has_bkg_scale = fits["OBS_INDEX"].contains("BKG_SCALE") fits.close() else: self.has_bkg_scale = False # Create base data directory from hdu index file location self.subdir = os.path.dirname(self.m_hdu_index) self.m_log = False # Logging in client tools self.m_debug = False # Debugging in client tools self.m_clobber = self["clobber"].boolean() # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation. """ # Get parameters if self._datapath == '': self._datapath = self['datapath'].string() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get production name self._prodname = self['prodname'].string() # Master index file name master_indx = self['master_indx'].string() # Intiialise flag if spatial selection is required self._select_radec = True # Initialise invalid radius self._radius = 0.0 # Check for vailidity of spatial parameters if (self['ra'].is_valid() and self['dec'].is_valid() and self['rad'].is_valid()): # Read spatial parameters self._ra = self['ra'].real() self._dec = self['dec'].real() self._radius = self['rad'].real() else: self._select_radec = False # Check Radius for validity if self._radius <= 0.0: self._select_radec = False # Query other parameters self['min_qual'].integer() self['expression'].string() # Read ahead output parameters if self._read_ahead(): self['outfile'].filename() # Open master index file and look for prodname master_file = os.path.join(self._datapath, master_indx) if not os.path.isfile(master_file): raise RuntimeError('FITS data store not available. ' + 'No master index file found at "' + master_file + '". Make sure the file ' + 'is copied from the server and your ' + 'datapath is set correctly.') # Open and load JSON file json_data = open(master_file).read() data = json.loads(json_data) if not 'datasets' in data: raise RuntimeError('Key "datasets" not available in ' + 'master index file.') # Get configurations configs = data['datasets'] # Initialise obs index file self._obs_index = '' # Get HDUs for config in configs: if self._prodname == config['name']: self._obs_index = str( os.path.join(self._datapath, config['obsindx'])) break # Check HDUs if self._obs_index == '': raise RuntimeError('FITS data store "' + self._prodname + '" not available. Run csiactdata to get ' + 'a list of available storage names') filename = gammalib.GFilename(self._obs_index + '[OBS_INDEX]') if not filename.is_fits(): raise RuntimeError('Observation index file "' + self._obs_index + '[OBS_INDEX]" for FITS data store "' + self._prodname + '" not available. Check your master index ' + 'file or run csiactdata to get a list of ' + 'available storage names.') # Write input parameters into logger if self._logTerse(): self._log_parameters() self._log('\n') # Return return
def _get_parameters(self): """ Get parameters from parfile and setup the observation. """ # Get parameters if self._datapath == '': self._datapath = self['datapath'].string() # Expand environment self._datapath = gammalib.expand_env(self._datapath) # Get production name self._prodname = self['prodname'].string() # Master index file name master_indx = self['master_indx'].string() # Initialise flag if spatial selection is required self._select_radec = True # Initialise invalid radius self._radius = 0.0 # Check for validity of spatial parameters if (self['ra'].is_valid() and self['dec'].is_valid() and self['rad'].is_valid()): # Read spatial parameters self._ra = self['ra'].real() self._dec = self['dec'].real() self._radius = self['rad'].real() # ... otherwise signal that there are no spatial parameters for # selection else: self._select_radec = False # Check Radius for validity if self._radius <= 0.0: self._select_radec = False # Query other parameters self['min_qual'].integer() self['expression'].string() # Read ahead output parameters if self._read_ahead(): self['outfile'].filename() # Set filename of JSON master file and raise an exception if the file # does not exist master_file = os.path.join(self._datapath, master_indx) if not os.path.isfile(master_file): msg = ('FITS data store not available. No master index file found ' 'at "%s". Make sure the file is copied from the server and ' 'your datapath is set correctly.' % master_file) raise RuntimeError(msg) # Open and load JSON master file. If the "dataset" key is not available # then raise an exception json_data = open(master_file).read() data = json.loads(json_data) if not 'datasets' in data: msg = ('Key "datasets" not available in master index file.') raise RuntimeError(msg) # Get configurations from JSON master file configs = data['datasets'] # Initialise obs index file self._obs_index = '' # Get name of observation index file for config in configs: if self._prodname == config['name']: self._obs_index = str(os.path.join(self._datapath, config['obsindx'])) break # If the observation index file name is empty then raise an exception if self._obs_index == '': msg = ('FITS data store "%s" not available. Run csiactdata to get ' 'a list of available storage names.' % self._prodname) raise RuntimeError(msg) # If the observation index file is not a FITS file then raise an # exception filename = gammalib.GFilename(self._obs_index+'[OBS_INDEX]') if not filename.is_fits(): msg = ('Observation index file "%s[OBS_INDEX]" for FITS data store ' '"%s" not available. Check your master index file or run ' 'csiactdata to get a list of available storage names.' % (self._obs_index, self._prodname)) raise RuntimeError(msg) # Write input parameters into logger self._log_parameters(gammalib.TERSE) # Return return