コード例 #1
0
ファイル: gtutils.py プロジェクト: NAH8/fermipy
 def __init__(self,
              binnedData,
              srcModel=None,
              optimizer='Drmngb',
              use_bl2=False,
              verbosity=0,
              psfcorr=True,
              convolve=True,
              resample=True,
              resamp_fact=2,
              minbinsz=0.1,
              wmap=None):
     AnalysisBase.__init__(self)
     if srcModel is None:
         srcModel, optimizer = self._srcDialog()
     self.binnedData = binnedData
     self.srcModel = srcModel
     self.optimizer = optimizer
     if use_bl2:
         self.logLike = pyLike.BinnedLikelihood2(binnedData.countsMap,
                                                 binnedData.observation,
                                                 binnedData.srcMaps, True,
                                                 psfcorr, convolve,
                                                 resample, resamp_fact,
                                                 minbinsz)
     else:
         if wmap is None or wmap == "none":
             self.logLike = pyLike.BinnedLikelihood(binnedData.countsMap,
                                                    binnedData.observation,
                                                    binnedData.srcMaps,
                                                    True, psfcorr, convolve,
                                                    resample, resamp_fact,
                                                    minbinsz)
             self._wmap = None
         else:
             self._wmap = pyLike.WcsMapLibrary.instance().wcsmap(
                 wmap, "SKYMAP")
             self._wmap.setInterpolation(False)
             self._wmap.setExtrapolation(True)
             self.logLike = pyLike.BinnedLikelihood(
                 binnedData.countsMap, self._wmap, binnedData.observation,
                 binnedData.srcMaps, True, psfcorr, convolve, resample,
                 resamp_fact, minbinsz)
     self.verbosity = verbosity
     self.logLike.initOutputStreams()
     self.logLike.readXml(srcModel, _funcFactory, False, True, False)
     self.model = SourceModel(self.logLike, srcModel)
     self.energies = np.array(self.logLike.energies())
     self.e_vals = np.sqrt(self.energies[:-1] * self.energies[1:])
     self.nobs = self.logLike.countsSpectrum()
     self.sourceFitPlots = []
     self.sourceFitResids = []
コード例 #2
0
    def __init__(self,
                 binnedData,
                 srcModel=None,
                 optimizer='Drmngb',
                 use_bl2=False,
                 verbosity=0,
                 psfcorr=True,
                 convolve=True,
                 resample=True,
                 resamp_fact=2,
                 minbinsz=0.1,
                 wmap=None,
                 edisp_bins=-1):
        AnalysisBase.__init__(self)
        if srcModel is None:
            srcModel, optimizer = self._srcDialog()
        self.binnedData = binnedData
        self.srcModel = srcModel
        self.optimizer = optimizer
        if use_bl2:
            raise ValueError("BinnedLikelilihood2 is not longer supported")

        if wmap is None or wmap == "none":
            self._wmap = None
        else:
            self._wmap = pyLike.WcsMapLibrary.instance().wcsmap(wmap, "")
            self._wmap.setInterpolation(False)
            self._wmap.setExtrapolation(True)

        try:
            self.binned_config = ba.BinnedConfig(use_edisp=edisp_bins != 0,
                                                 applyPsfCorrections=psfcorr,
                                                 performConvolutiion=convolve,
                                                 resample=resample,
                                                 resamp_factor=resamp_fact,
                                                 minbinsz=minbinsz,
                                                 verbose=(verbosity > 0),
                                                 edisp_bins=edisp_bins)

            self.logLike = pyLike.BinnedLikelihood(binnedData.countsMap,
                                                   binnedData.observation,
                                                   self.binned_config,
                                                   binnedData.srcMaps,
                                                   self._wmap)
        except NotImplementedError as msg:
            print(
                "Failed to construct a BinnedLikelihood object because of a mismatch between fermipy and fermitools versions"
            )
            raise NotImplementedError(msg)

        self.verbosity = verbosity
        self.logLike.initOutputStreams()
        self.logLike.readXml(srcModel, _funcFactory, False, True, False)
        self.model = SourceModel(self.logLike, srcModel)
        self.energies = np.array(self.logLike.energies())
        self.e_vals = np.sqrt(self.energies[:-1] * self.energies[1:])
        self.nobs = self.logLike.countsSpectrum()
        self.sourceFitPlots = []
        self.sourceFitResids = []
コード例 #3
0
    def __init__(self,
                 binnedData,
                 srcModel=None,
                 optimizer='Drmngb',
                 use_bl2=False,
                 verbosity=0,
                 psfcorr=True,
                 wmap=None,
                 config=None,
                 delete_local_fixed=False):
        AnalysisBase.__init__(self)
        if srcModel is None:
            srcModel, optimizer = self._srcDialog()
        self.binnedData = binnedData
        self.srcModel = srcModel
        self.optimizer = optimizer
        if wmap and wmap != "none":
            self.wmap = pyLike.WcsMapLibrary.instance().wcsmap(wmap, "")
            self.wmap.setInterpolation(False)
            self.wmap.setExtrapolation(True)
        else:
            self.wmap = None

        if use_bl2:
            raise ValueError("BinnedLikelihood2 is no longer supported")

        if config is None:
            config = BinnedConfig(applyPsfCorrections=psfcorr,
                                  delete_local_fixed=delete_local_fixed)

        self.logLike = pyLike.BinnedLikelihood(binnedData.countsMap,
                                               binnedData.observation, config,
                                               binnedData.srcMaps, self.wmap)

        self.verbosity = verbosity
        self.logLike.initOutputStreams()
        self.logLike.readXml(srcModel, _funcFactory, False, True, False)
        self.model = SourceModel(self.logLike, srcModel)
        self.energies = num.array(self.logLike.energies())
        self.e_vals = num.sqrt(self.energies[:-1] * self.energies[1:])
        self.nobs = self.logLike.countsSpectrum()
        self.nobs_wt = self.logLike.countsSpectrum(True)
        self.sourceFitPlots = []
        self.sourceFitResids = []