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)
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)
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
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
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)
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
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