Ejemplo n.º 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]
Ejemplo n.º 2
0
                            proj="TAN",
                            coordsys="GAL")

mask = exclusion_mask.geom.region_mask([exclusion_region], inside=False)
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
Ejemplo n.º 3
0
)

mask = exclusion_mask.geom.region_mask([exclusion_region], inside=False)
exclusion_mask.data = mask
exclusion_mask.plot()


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

# In[ ]:


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

background_estimator.run()


# In[ ]:


# print(background_estimator.result[0])


# In[ ]:


plt.figure(figsize=(8, 8))
Ejemplo n.º 4
0
allsky_mask = SkyImage.read(EXCLUSION_FILE)
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
Ejemplo n.º 5
0
b=a
plt.plot(a,b)
plt.show()
import matplotlib.pyplot as plt
ana.spectrum_result.plot(
    energy_range=ana.fit.fit_range,
    energy_power=2,
    flux_unit='erg-1 cm-2 s-1',
    fig_kwargs=dict(figsize = (8,8)),
)
plt.show()
plt.plot()
x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)
plt.show()
allsky_mask = SkyImage.read(EXCLUSION_FILE)
exclusion_mask = allsky_mask.cutout(
    position=on_region.center,
    size=Angle('6 deg'),
)
background_estimator = ReflectedRegionsBackgroundEstimator(obs_list=crablist, 
on_region=on_region, exclusion_mask = exclusion_mask)
background_estimator.run()
print(background_estimator.result[0])
plt.figure(figsize=(8,8))
background_estimator.plot()
plt.plot()
plt.show()
get_ipython().magic(u'save testfit.py 1-194')