def __init__(self, srcMaps=None, expCube=None, binnedExpMap=None, irfs=None, phased_expmap=None): if srcMaps is None or expCube is None: srcMaps, expCube, binnedExpMap, irfs = self._obsDialog(srcMaps, expCube) self._inputs ='\n'.join(('Source maps: ' + str(srcMaps), 'Exposure cube: ' + str(expCube), 'Exposure map: ' + str(binnedExpMap), 'IRFs: ' + str(irfs))) if phased_expmap is not None: self._inputs += '\n %s' % phased_expmap self.srcMaps = srcMaps self.expCube = expCube self.binnedExpMap = binnedExpMap self.phased_expmap = phased_expmap if irfs is None or irfs == 'CALDB': my_cuts = pyLike.Cuts(srcMaps, "", False, True, True) self.irfs = my_cuts.CALDB_implied_irfs() else: self.irfs = irfs pyLike.AppHelpers_checkExposureMap(srcMaps, binnedExpMap) # EAC switch to using AppHelpers... self.countsMap = pyLike.AppHelpers_readCountsMap(srcMaps) self._createObservation(srcMaps, expCube, self.irfs)
def __init__(self, eventFile=None, scFile=None, expMap=None, expCube=None, irfs=None, checkCuts=True, sctable='SC_DATA'): self.sctable = sctable self.checkCuts = checkCuts if eventFile is None and scFile is None: eventFile, scFile, expMap, expCube, irfs = self._obsDialog() if checkCuts: self._checkCuts(eventFile, expMap, expCube) self.expMap = expMap self.expCube = expCube if irfs is None or irfs == 'CALDB': evfiles = self._fileList(eventFile) my_cuts = pyLike.Cuts(evfiles[0], "EVENTS", False, True, True) self.irfs = my_cuts.CALDB_implied_irfs() else: self.irfs = irfs self._inputs = '\n'.join( ('Event file(s): ' + str(eventFile), 'Spacecraft file(s): ' + str(scFile), 'Exposure map: ' + str(expMap), 'Exposure cube: ' + str(expCube), 'IRFs: ' + str(irfs))) self._respFuncs = pyLike.ResponseFunctions() evfiles = self._fileList(eventFile) self._respFuncs.load_with_event_types(self.irfs, "", evfiles[0], "EVENTS") self._expMap = pyLike.ExposureMap() if expMap is not None and expMap != "": self._expMap.readExposureFile(expMap) self._scData = pyLike.ScData() self._roiCuts = pyLike.RoiCuts() self._expCube = pyLike.ExposureCube() if expCube is not None and expCube != "": self._expCube.readExposureCube(expCube) self._expCube.setEfficiencyFactor(self._respFuncs.efficiencyFactor()) self._eventCont = pyLike.EventContainer(self._respFuncs, self._roiCuts, self._scData) self.observation = pyLike.Observation(self._respFuncs, self._scData, self._roiCuts, self._expCube, self._expMap, self._eventCont) self._readData(scFile, eventFile)
def __init__( self, name, eventFile, ft2File, livetimeCube, kind, exposureMap=None, sourceMaps=None, binnedExpoMap=None, source_name=None, ): # Initially the nuisance parameters dict is empty, as we don't know yet # the likelihood model. They will be updated in set_model super(FermiLATLike, self).__init__(name, {}) # Read the ROI cut cc = pyLike.RoiCuts() cc.readCuts(eventFile, "EVENTS") self.ra, self.dec, self.rad = cc.roiCone() # Read the IRF selection c = pyLike.Cuts(eventFile, "EVENTS") self.irf = c.CALDB_implied_irfs() self.ft2File = ft2File self.livetimeCube = livetimeCube # These are the boundaries and the number of energies for the computation # of the model (in keV) self.emin = 1e4 self.emax = 5e8 self.Nenergies = 200 # This is the limit on the effective area correction factor, # which is a multiplicative factor in front of the whole model # to account for inter-calibration issues. By default it can vary # by 10%. This can be changed by issuing: # FermiLATUnbinnedLikeInstance.effCorrLimit = [new limit] # where for example a [new limit] of 0.2 allow for an effective # area correction up to +/- 20 % self.effCorrLimit = 0.1 if kind.upper() != "UNBINNED" and kind.upper() != "BINNED": raise RuntimeError("Accepted values for the kind parameter are: " + "binned, unbinned. You specified: %s" % (kind)) else: self.kind = kind.upper() if kind.upper() == "UNBINNED": assert exposureMap is not None, "You have to provide an exposure map" self.eventFile = eventFile self.exposureMap = exposureMap # Read the files and generate the pyLikelihood object self.obs = UnbinnedAnalysis.UnbinnedObs( self.eventFile, self.ft2File, expMap=self.exposureMap, expCube=self.livetimeCube, irfs=self.irf, ) elif kind.upper() == "BINNED": assert sourceMaps is not None, "You have to provide a source map" assert ( binnedExpoMap is not None), "You have to provided a (binned) exposure map" self.sourceMaps = sourceMaps self.binnedExpoMap = binnedExpoMap self.obs = BinnedAnalysis.BinnedObs( srcMaps=self.sourceMaps, expCube=self.livetimeCube, binnedExpMap=self.binnedExpoMap, irfs=self.irf, ) pass # Activate inner minimization by default self.setInnerMinimization(True) self._source_name = source_name