Exemple #1
0
    def estimate_reflected(self, EXCLUSION_FILE, size):

        #just extracts the reflected background
        on_size=0.11 * u.deg #0.11 for point source cuts...
        allsky_mask = SkyImage.read(EXCLUSION_FILE)
        exclusion_mask = allsky_mask.cutout(position=self.obspos,size=size)
        on_region=CircleSkyRegion(self.obspos,on_size)         
        background_estimator = ReflectedRegionsBackgroundEstimator(obs_list=self.obslist, on_region=on_region, exclusion_mask = exclusion_mask)

        background_estimator.run()
        return background_estimator.result[0]
exclusion_mask.data = mask
exclusion_mask.plot()

# ## Estimate background
#
# Next we will manually perform a background estimate by placing [reflected regions](https://docs.gammapy.org/0.10/background/reflected.html) around the pointing position and looking at the source statistics. This will result in a  [gammapy.background.BackgroundEstimate](https://docs.gammapy.org/0.10/api/gammapy.background.BackgroundEstimate.html) that serves as input for other classes in gammapy.

# In[ ]:

background_estimator = ReflectedRegionsBackgroundEstimator(
    observations=observations,
    on_region=on_region,
    exclusion_mask=exclusion_mask,
)

background_estimator.run()

# In[ ]:

# print(background_estimator.result[0])

# In[ ]:

plt.figure(figsize=(8, 8))
background_estimator.plot(add_legend=True)

# ## Source statistic
#
# Next we're going to look at the overall source statistics in our signal region. For more info about what debug plots you can create check out the [ObservationSummary](https://docs.gammapy.org/0.10/api/gammapy.data.ObservationSummary.html#gammapy.data.ObservationSummary) class.

# In[ ]:
Exemple #3
0
exclusion_mask = allsky_mask.cutout(
    position=crab,
    size=Angle('6 deg'),
)

EXCLUSION_FILE = '$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits'
allsky_mask = SkyImage.read(EXCLUSION_FILE)
exclusion_mask = allsky_mask.cutout(
    position=crab,
    size=Angle('6 deg'),
)
from gammapy.background.reflected import ReflectedRegionsBackgroundEstimator
get_ipython().magic(u'pinfo ReflectedRegionsBackgroundEstimator')
on_region=CircleSkyRegion(crab,0.15 * u.deg)
background_estimator = ReflectedRegionsBackgroundEstimator(obs_list=fakerun, on_region=on_region, exclusion_mask = exclusion_mask)
background_estimator.run()
get_ipython().magic(u'pinfo background_estimator.run')
get_ipython().magic(u'pinfo background_estimator.result')
fakerun.obs_id
background_estimator.process()
background_estimator.process(fakerun)
background_estimator.result
background_estimator.result[0]
background_estimator.result
print background_estimator.result
plt.figure(figsize=(8,8))
background_estimator.plot()
len(fakerun)
background_estimator.obs_list
print background_estimator.obs_list
print len(background_estimator.obs_list)