def gtlike_followup(self, hypothesis): name = self.name roi = self.reload_roi(hypothesis) cutoff = (not self.no_cutoff) and hypothesis in ['at_pulsar', 'point'] upper_limit = hypothesis=='at_pulsar' if cutoff: modify = import_module(self.modify) cutoff_model=modify.get_gtlike_cutoff_model(name) if cutoff_model is None: pointlike_results = loaddict('results_%s_pointlike_%s.yaml' % (name,hypothesis)) cutoff_model=pointlike_results['test_cutoff']['hypothesis_1']['spectrum'] cutoff_model=pointlike_dict_to_spectrum(cutoff_model) cutoff_model.set_default_limits(oomp_limits=True) print 'override cutoff_model = ',cutoff_model else: cutoff_model=None results=gtlike_analysis(roi, name=name, cutoff_model = cutoff_model, max_free = self.max_free, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, hypothesis=hypothesis, upper_limit=upper_limit, cutoff=cutoff, do_bandfitter=True, do_sed=True, ) savedict(results,'results_%s_gtlike_%s.yaml' % (name,hypothesis))
def main(self): name=self.name rb = RadioPSRROIBuilder(radiopsr_loader=self.radiopsr_loader) roi = rb.build_roi(name=name, fast=self.fast) modify = import_module(self.modify) new_sources, deleted_sources = modify.modify_roi(roi,name) roi.extra = dict(new_sources=new_sources, deleted_sources=deleted_sources) results = self.input_kwargs savedict(results,'results_%s_general.yaml' % name) hypothesis = 'at_pulsar' results=pointlike_analysis(self, roi, name, hypothesis=hypothesis, upper_limit=True) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis)) if not self.no_point: hypothesis = 'point' results=pointlike_analysis(self, roi, name, hypothesis=hypothesis, localize=True) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis)) if not self.no_extended: hypothesis = 'extended' roi.modify(which=name, spatial_model=Gaussian(sigma=0.1), keep_old_center=True) results=pointlike_analysis(self, roi, name, hypothesis=hypothesis, fit_extension=True) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis))
def variability_followup(self, hypothesis): name = self.name roi = self.reload_roi(hypothesis) modify = import_module(self.modify) good_interval = modify.get_variability_time_cuts(name) nbins = 36 if good_interval is not None: ft1files = roi.sa.pixeldata.ft1files earliest_time, latest_time = CombinedVariabilityTester.get_time_range( ft1files) bins = b = np.round( np.linspace(earliest_time, latest_time, nbins + 1)).astype(int) starts = b[:-1] stops = b[1:] print 'Initial binning:' print ' * starts=', starts print ' * stops=', stops starts,stops = zip(*[(start,stop) \ for (start,stop) in zip(starts,stops) \ if good_interval(start,stop)]) print 'Initial binning:' print ' * starts=', starts print ' * stops=', stops kwargs = dict(tstarts=starts, tstops=stops) else: kwargs = dict(nbins=nbins) frozen = freeze_far_away(roi, roi.get_source(name).skydir, self.max_free) v = CombinedVariabilityTester(roi, name, use_pointlike_ltcube=True, refit_background=True, refit_other_sources=True, verbosity=4, **kwargs) unfreeze_far_away(roi, frozen) results = v.todict() savedict(results, 'results_%s_variability_%s.yaml' % (name, hypothesis)) try: v.plot(filename='plots/variability_%s_hypothesis_%s.pdf' % (name, hypothesis)) except Exception, ex: print 'ERROR plotting variability tester:', ex traceback.print_exc(file=sys.stdout)
def variability_followup(self, hypothesis): name = self.name roi = self.reload_roi(hypothesis) modify = import_module(self.modify) good_interval = modify.get_variability_time_cuts(name) nbins=36 if good_interval is not None: ft1files=roi.sa.pixeldata.ft1files earliest_time, latest_time = CombinedVariabilityTester.get_time_range(ft1files) bins = b = np.round(np.linspace(earliest_time, latest_time, nbins+1)).astype(int) starts = b[:-1] stops = b[1:] print 'Initial binning:' print ' * starts=',starts print ' * stops=',stops starts,stops = zip(*[(start,stop) \ for (start,stop) in zip(starts,stops) \ if good_interval(start,stop)]) print 'Initial binning:' print ' * starts=',starts print ' * stops=',stops kwargs=dict(tstarts=starts, tstops=stops) else: kwargs=dict(nbins=nbins) frozen = freeze_far_away(roi, roi.get_source(name).skydir, self.max_free) v = CombinedVariabilityTester(roi,name, use_pointlike_ltcube=True, refit_background=True, refit_other_sources=True, verbosity=4, **kwargs) unfreeze_far_away(roi, frozen) results = v.todict() savedict(results,'results_%s_variability_%s.yaml' % (name,hypothesis)) try: v.plot(filename='plots/variability_%s_hypothesis_%s.pdf' % (name,hypothesis)) except Exception, ex: print 'ERROR plotting variability tester:', ex traceback.print_exc(file=sys.stdout)
def main(self): name = self.name rb = RadioPSRROIBuilder(radiopsr_loader=self.radiopsr_loader) roi = rb.build_roi(name=name, fast=self.fast) modify = import_module(self.modify) new_sources, deleted_sources = modify.modify_roi(roi, name) roi.extra = dict(new_sources=new_sources, deleted_sources=deleted_sources) results = self.input_kwargs savedict(results, 'results_%s_general.yaml' % name) hypothesis = 'at_pulsar' results = pointlike_analysis(self, roi, name, hypothesis=hypothesis, upper_limit=True) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis)) if not self.no_point: hypothesis = 'point' results = pointlike_analysis(self, roi, name, hypothesis=hypothesis, localize=True) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis)) if not self.no_extended: hypothesis = 'extended' roi.modify(which=name, spatial_model=Gaussian(sigma=0.1), keep_old_center=True) results = pointlike_analysis(self, roi, name, hypothesis=hypothesis, fit_extension=True) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis))
def gtlike_followup(self, hypothesis): name = self.name roi = self.reload_roi(hypothesis) cutoff = (not self.no_cutoff) and hypothesis in ['at_pulsar', 'point'] upper_limit = hypothesis == 'at_pulsar' if cutoff: modify = import_module(self.modify) cutoff_model = modify.get_gtlike_cutoff_model(name) if cutoff_model is None: pointlike_results = loaddict('results_%s_pointlike_%s.yaml' % (name, hypothesis)) cutoff_model = pointlike_results['test_cutoff'][ 'hypothesis_1']['spectrum'] cutoff_model = pointlike_dict_to_spectrum(cutoff_model) cutoff_model.set_default_limits(oomp_limits=True) print 'override cutoff_model = ', cutoff_model else: cutoff_model = None results = gtlike_analysis( roi, name=name, cutoff_model=cutoff_model, max_free=self.max_free, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, hypothesis=hypothesis, upper_limit=upper_limit, cutoff=cutoff, do_bandfitter=True, do_sed=True, ) savedict(results, 'results_%s_gtlike_%s.yaml' % (name, hypothesis))
def main(self): do_at_pulsar = not self.no_at_pulsar do_point = not self.no_point do_extended = not self.no_extended do_cutoff = not self.no_cutoff name = self.name if not self.fast: emin = self.emin emax = self.emax binsperdec = self.binsperdec free_radius = 5 roi_size = 10 max_free = self.max_free else: emin = 1e4 emax = 1e5 binsperdec = 2 free_radius = 2 roi_size = 5 max_free = 2 pwnphase = yaml.load(open(self.pwnphase))[name] phase = pwnphase['phase'] print 'phase = ', phase pwndata = yaml.load(open(self.pwndata))[name] savedir = None if self.no_savedir else join(os.getenv('PWD'), 'savedir') results = r = defaultdict(lambda: defaultdict(dict)) results['name'] = name results['phase'] = phase pointlike_kwargs = dict(name=name, max_free=max_free) print 'Building the ROI' reg = PWNRegion(pwndata=self.pwndata, savedir=savedir) roi = reg.get_roi(name=name, phase=phase, catalog_kwargs=dict(free_radius=free_radius, max_free=max_free), fit_emin=emin, fit_emax=emax, binsperdec=binsperdec, roi_size=roi_size, extended=False) modify = import_module(self.modify) roi.extra['phase'] = phase roi.extra['new_sources'] = modify.modify_roi(name, roi) roi.extra['pwnphase'] = pwnphase savedict(results, 'results_%s_general.yaml' % name) assert all_params_limited(roi, except_sources=[name]) mapper0 = roi.get_model(which=name).get_mapper(0) assert isinstance(mapper0, LogMapper) or (type(mapper0) == type and issubclass(mapper0, LogMapper)) cutoff_model = modify.get_cutoff_model(name) override_localization = modify.get_override_localization(name) if do_at_pulsar: hypothesis = 'at_pulsar' results = pointlike_analysis(roi, hypothesis=hypothesis, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, cutoff=do_cutoff, **pointlike_kwargs) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis)) if do_point: hypothesis = 'point' results = pointlike_analysis( roi, hypothesis=hypothesis, localize=True, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, cutoff=do_cutoff, cutoff_model=cutoff_model, override_localization=override_localization, **pointlike_kwargs) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis)) if do_extended: hypothesis = 'extended' roi.modify(which=name, spatial_model=Gaussian(sigma=0.1), keep_old_center=True) results = pointlike_analysis(roi, hypothesis=hypothesis, cutoff=False, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, fit_extension=True, **pointlike_kwargs) savedict(results, 'results_%s_pointlike_%s.yaml' % (name, hypothesis))
def main(self): do_at_pulsar = not self.no_at_pulsar do_point = not self.no_point do_extended = not self.no_extended do_cutoff = not self.no_cutoff name=self.name if not self.fast: emin=self.emin emax=self.emax binsperdec=self.binsperdec free_radius=5 roi_size=10 max_free=self.max_free else: emin=1e4 emax=1e5 binsperdec=2 free_radius=2 roi_size=5 max_free=2 pwnphase=yaml.load(open(self.pwnphase))[name] phase=pwnphase['phase'] print 'phase = ',phase pwndata=yaml.load(open(self.pwndata))[name] savedir=None if self.no_savedir else join(os.getenv('PWD'),'savedir') results=r=defaultdict(lambda: defaultdict(dict)) results['name']=name results['phase']=phase pointlike_kwargs=dict(name=name, max_free=max_free) print 'Building the ROI' reg=PWNRegion(pwndata=self.pwndata, savedir=savedir) roi=reg.get_roi(name=name, phase=phase, catalog_kwargs=dict(free_radius=free_radius, max_free=max_free), fit_emin=emin, fit_emax=emax, binsperdec=binsperdec, roi_size=roi_size, extended=False) modify = import_module(self.modify) roi.extra['phase'] = phase roi.extra['new_sources'] = modify.modify_roi(name,roi) roi.extra['pwnphase'] = pwnphase savedict(results,'results_%s_general.yaml' % name) assert all_params_limited(roi, except_sources=[name]) mapper0 = roi.get_model(which=name).get_mapper(0) assert isinstance(mapper0,LogMapper) or (type(mapper0)==type and issubclass(mapper0,LogMapper)) cutoff_model=modify.get_cutoff_model(name) override_localization=modify.get_override_localization(name) if do_at_pulsar: hypothesis = 'at_pulsar' results=pointlike_analysis(roi, hypothesis=hypothesis, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, cutoff=do_cutoff, **pointlike_kwargs) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis)) if do_point: hypothesis = 'point' results=pointlike_analysis(roi, hypothesis=hypothesis, localize=True, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, cutoff=do_cutoff, cutoff_model = cutoff_model, override_localization=override_localization, **pointlike_kwargs) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis)) if do_extended: hypothesis = 'extended' roi.modify(which=name, spatial_model=Gaussian(sigma=0.1), keep_old_center=True) results=pointlike_analysis(roi, hypothesis=hypothesis, cutoff=False, seddir=self.seddir, datadir=self.datadir, plotdir=self.plotdir, fit_extension=True, **pointlike_kwargs) savedict(results,'results_%s_pointlike_%s.yaml' % (name,hypothesis))