Import 3ML as always to make sure you have the plugin.
In [1]:
%matplotlib inline
%matplotlib notebook
import numpy as np
from threeML import *
get_available_plugins()
In [2]:
# os.path.join is a way to generate system-independent
# paths (good for unix, windows, Mac...)
trigger_number = 'bn080916009'
data_dir_gbm = os.path.join('gbm',trigger_number)
gbm_data = download_GBM_trigger_data(trigger_number,detectors=['n3','n4','b0'],destination_directory=data_dir_gbm,compress_tte=True)
data_dir_lle = os.path.join('lat')
lle_data = download_LLE_trigger_data(trigger_number,destination_directory=data_dir_lle)
src_selection = "0.-71."
Build our plugins from our data. The LLE plugin is an EventList like the GBM TTE plugin and operates in a similar way.
Simply select a source interval, background interval(s), etc. (all of which can be changed later) and the plugin will prepare the data for you.
As with the TTE plugin (and any OGIPLike plugin), the data can be saved out to PHA files for cross-checking with XSPEC.
In [3]:
lle = FermiLATLLELike("LLE",
os.path.join(data_dir_lle, "gll_lle_bn080916009_v10.fit"),
os.path.join(data_dir_lle, "gll_pt_bn080916009_v10.fit"),
os.path.join(data_dir_lle, "gll_cspec_bn080916009_v10.rsp"),
src_selection,
"-100-0,100-200")
nai3 = FermiGBMTTELike('NAI3',
os.path.join(data_dir_gbm, "glg_tte_n3_bn080916009_v01.fit.gz"),
os.path.join(data_dir_gbm, "glg_cspec_n3_bn080916009_v00.rsp2"),
src_selection,
"-10-0,120-200",
poly_order=2)
nai4 = FermiGBMTTELike('NAI4',
os.path.join(data_dir_gbm, "glg_tte_n4_bn080916009_v01.fit.gz"),
os.path.join(data_dir_gbm, "glg_cspec_n4_bn080916009_v00.rsp2"),
src_selection,
"-10-0,120-200",
poly_order=-1,
verbose=False)
bgo0 = FermiGBMTTELike('BGO0',
os.path.join(data_dir_gbm, "glg_tte_b0_bn080916009_v01.fit.gz"),
os.path.join(data_dir_gbm, "glg_cspec_b0_bn080916009_v00.rsp2"),
src_selection,
"-10-0,120-200")
In [4]:
lle.display()
Let's look at the lightcurve of LLE file to check out background fit:
In [5]:
lle.view_lightcurve(-10,100,dt=.5)
And an NaI:
In [6]:
nai3.view_lightcurve(-10,100.,.5)
In [7]:
lle.set_active_measurements("50000-100000")
lle.view_count_spectrum()
nai3.set_active_measurements("10.0-30.0", "40.0-900.0")
nai4.set_active_measurements("10.0-30.0", "40.0-900.0")
bgo0.set_active_measurements("250-43000")
In [8]:
ra = 121.8
dec = -61.3
data_list = DataList(nai3,nai4,bgo0,lle )
band= Band()
GRB = PointSource( trigger_number, ra, dec, spectral_shape=band )
model = Model( GRB )
In [9]:
jl = JointLikelihood( model, data_list, verbose=False )
res = jl.fit()
In [10]:
sp = SpectralPlotter(jl)
_=sp.plot_model(y_unit='erg2/(cm2 s keV)', num_ene=200,x_max=1E5)
We can examine our fit with the data:
In [11]:
_ = display_ogip_model_counts(jl,min_rate=1,step=False)
In [12]:
res = jl.get_errors()
In [13]:
res = jl.get_contours(band.xp,200,900,20)
In [14]:
res = jl.get_contours(band.xp,250,900,50,band.alpha,-1.2,-0.9,50)
In [ ]:
In [ ]: