In [1]:
from threeML import *
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
triggerName = 'bn090217206'
ra = 204.9
dec = -8.4
#Data are in the current directory
datadir = os.path.abspath('.')
#Create an instance of the GBM plugin for each detector
#Data files
obsSpectrum = os.path.join( datadir, "bn090217206_n6_srcspectra.pha{1}" )
bakSpectrum = os.path.join( datadir, "bn090217206_n6_bkgspectra.bak{1}" )
rspFile = os.path.join( datadir, "bn090217206_n6_weightedrsp.rsp{1}" )
#Plugin instance
NaI6 = FermiGBMLike( "NaI6", obsSpectrum, bakSpectrum, rspFile )
#Choose energies to use (in this case, I exclude the energy
#range from 30 to 40 keV to avoid the k-edge, as well as anything above
#950 keV, where the calibration is uncertain)
NaI6.setActiveMeasurements( "10.0-30.0", "40.0-950.0" )
In [3]:
#This declares which data we want to use. In our case, all that we have already created.
data_list = DataList( NaI6 )
In [4]:
powerlaw = powerlaw()
In [5]:
GRB = PointSource( triggerName, ra, dec, spectral_shape=powerlaw )
In [6]:
model = Model( GRB )
In [7]:
jl = JointLikelihood( model, data_list )
res = jl.fit()
In [8]:
res = jl.get_errors()
In [10]:
res = jl.get_contours(powerlaw.index,-1.3,-1.1,20)
In [15]:
res = jl.get_contours(powerlaw.index,-1.25,-1.1,50,powerlaw.K,1.9,3.2,50)
In [16]:
bayes = BayesianAnalysis(model, data_list)
In [17]:
powerlaw.index.prior = uniform_prior(lower_bound=-5.0, upper_bound=5.0)
powerlaw.K.prior = log_uniform_prior(lower_bound=1.0, upper_bound=10)
In [18]:
samples = bayes.sample(n_walkers=20,burn_in=100, n_samples=1000)
In [20]:
fig = bayes.corner_plot()
In [ ]: