Esempio n. 1
0
 def fit(just_prefactor=False, fit_bg_first=False):
     """ Convenience function incase fit fails. """
     try:
         if just_prefactor:
             fit_prefactor(roi, name)
         else:
             roi.fit(fit_bg_first=fit_bg_first)
     except Exception, ex:
         print 'ERROR spectral fitting pointlike for hypothesis %s:' % hypothesis, ex
         traceback.print_exc(file=sys.stdout)
Esempio n. 2
0
 def fit(just_prefactor=False, fit_bg_first=False):
     """ Convenience function incase fit fails. """
     try:
         if just_prefactor:
             fit_prefactor(roi, name) 
         else:
             roi.fit(fit_bg_first=fit_bg_first)
     except Exception, ex:
         print 'ERROR spectral fitting pointlike for hypothesis %s:' % hypothesis, ex
         traceback.print_exc(file=sys.stdout)
Esempio n. 3
0
    def fit(self):
        roi = self.roi
        which = self.which

        fit_prefactor(roi, which, **self.fit_kwargs)
        roi.fit(**self.fit_kwargs)
        if self.localize:
            roi.localize(which=which, update=True)
            roi.fit(**self.fit_kwargs)
        ll = -roi.logLikelihood(roi.parameters())
        return ll
Esempio n. 4
0
    def fit(self):
        roi=self.roi
        which=self.which

        fit_prefactor(roi, which, **self.fit_kwargs)
        roi.fit(**self.fit_kwargs)
        if self.localize: 
            roi.localize(which=which, update=True)
            roi.fit(**self.fit_kwargs)
        ll=-roi.logLikelihood(roi.parameters())
        return ll
Esempio n. 5
0
 def fit(just_prefactor=False, just_source=False, fit_bg_first=False):
     """ Convenience function incase fit fails. """
     try:
         if just_prefactor:
             fit_prefactor(roi, name) 
         elif just_source:
             fit_only_source(roi, name)
         elif fit_bg_first:
             roi.fit(fit_bg_first=True)
         else:
             roi.fit()
             # For some reason, one final fit seems to help with convergence and not getting negative TS values *shurgs*
             roi.fit() 
     except Exception, ex:
         print 'ERROR spectral fitting pointlike for hypothesis %s:' % hypothesis, ex
         traceback.print_exc(file=sys.stdout)
Esempio n. 6
0
def pointlike_analysis(roi, name, plotdir):

    print_summary = lambda: roi.print_summary(galactic=True, maxdist=10)

    print_summary()
    fit_prefactor(roi, name) 
    roi.fit()
    print_summary()

    results  = sourcedict(roi, name)

    results['powerlaw_upper_limit'] = powerlaw_upper_limit(roi, name, powerlaw_index=2.1, 
                                                           emin=emin, emax=emax, cl=.95)

    roi.plot_sed(which=name, filename='%s/sed_pointlike_%s.png' % (plotdir,name), use_ergs=True)

    return results
Esempio n. 7
0
def pointlike_analysis(roi, name, plotdir):

    print_summary = lambda: roi.print_summary(galactic=True, maxdist=10)

    print_summary()
    fit_prefactor(roi, name)
    roi.fit()
    print_summary()

    results = sourcedict(roi, name)

    results['powerlaw_upper_limit'] = powerlaw_upper_limit(roi,
                                                           name,
                                                           powerlaw_index=2.1,
                                                           emin=emin,
                                                           emax=emax,
                                                           cl=.95)

    roi.plot_sed(which=name,
                 filename='%s/sed_pointlike_%s.png' % (plotdir, name),
                 use_ergs=True)

    return results