S9_10 Swift Bat

Before running batgrbproduct

(it might be too detail… And also, the latest BAT CALDB might be available to the public
to accomplish this at the time of workshop)

The energy correction applied to the available event data from the Browse might
not be "correct" (not been processed by the latest BAT CALDB). It might be a good
idea to rerun the energy calibration BAT task, bateconvert, with the latest BAT CALDB
to the event data.

taka> cd 00351588000/bat/event/
taka> gunzip sw00351588000bevshsp_uf.evt.gz
taka> bateconvert sw00351588000bevshsp_uf.evt ../hk/sw00351588000bgocb.hk.gz CALDB CALDB CALDB

First of all, you need to gunzip the event data (if they are zipped).
The first argument is the event data. The second argument is a gain and offset file which is located
in bat/hk directory and named as sw?????????bgocb.hk.gz. The third, fourth and fifth arguments are
just input CALDB.

Running batgrbproduct

An instruction on how to run batgrbproduct is described in:


taka> ls
taka> batgrbproduct 00351588000 00351588000-results pcodethresh = 0.05

Outputs of batgrbproduct

Let's check the contents of outputs from batgrbproduct.

Contents of report.txt file

"report.txt" will report the summary of the BAT observation.

The BAT trigger information:

The "BAT trigger Time" is the BAT trigger time in MET. Note that BAT trigger time is
the start time of successful foreground image interval. The "Trigger Stop" is the stop time
of the BAT trigger time (stop time of the foreground image interval). UTC is the BAT trigger
time in UT.

BAT position information:

The position information under "BAT" is the flight position. "Analysis Position:" is the position used in batgrbproduct run. This position should match with the flight position in default. "Refined Position:" is the BAT refined (ground) position based on the pre-slew image. The error radius with "(estimated 90% radius based on SNR)" is the number which BAT team reports in the GCN circular.

The "Partial Coding Fraction:" number tells you (roughly) a fraction of detectors illuminated by the burst. For example, if the burst comes from on-axis, this number is close to 1. If the burst is completely outside of the BAT filed of view, this number is zero.

Fig Calculated BAT mask pattern for a partial coding fraction of 1.015 (case of GX 301-2 trigger).grb101008a_srcpos.gif
Fig Calculated BAT mask pattern for a partial coding fraction of 0.586 (case of GRB 101008A).grb100928a_srcpos.gif
Fig Calculated BAT mask pattern for a partial coding fraction of 0.152 (case of GRB 100928A).

How to create the BAT mask pattern map:
You can create the BAT mask pattern using the BAT task batmaskwtimg. The first argument is the output file name. The second is the spacecraft attitude file which should be located in auxil/sw(obsid)sat.fits.gz. The third and fourth arguments are ra and dec. You also need to specify "infile" option to point one of the DPI file (if you are interested in pre-slew mask pattern, you need to specify dpi/sw(obsid)b_preslew_1chan.dpi). The output file (in the case below, it is bat_mask.img) is the FITS image file which can see by ds9, ximage, …

Explanation of additional rows…

Catalogged Source?: NO <- The source (GRB) is in the on-board catalog?
Point Source?: YES <- The point source found?
GRB Indicated?: YES [ by BAT flight software ] <- Is it GRB?
Image S/N Ratio: 7.48 <- Image significance of the flight software.
Image Trigger?: NO <- Image trigger?
Rate S/N Ratio: 145.485394455938 [ if not an image trigger ] <- Rate significance of the flight software.
Image S/N Ratio: 7.48 <- (bug?) Image significance of the flight software.

BAT GRB duration information:

T90 and T50 values calculated by battblocks using the mask-weighted light curve in the 15-350 keV band.
When battblocks failed to find the burst duration (e.g. weak burst, weak short burst, …), the values are not

BAT GRB count fluence and count flux information:

"Measure from: … to:" numbers are the peak flux and the total fluence (T100 interval) interval (relative to the BAT trigger time) determine by battblocks. These intervals are also used to create the 1-s peak and the T100 spectrum.
The count flux and fluence numbers are not used by the BAT team refined analysis.

Contents of lc directory

All the light curves in this directory is the mask-weighted light curve. *_1chan_*.lc means the light curve in the 15-350 keV band. *_4chan_*.lc means the light curves in 4 energy bands; 15-25 keV, 25-50 keV, 50-100 keV and 100-350 keV band. …_1s.lc is the light curve in 1s bin; …_4ms.lc is the light curve in 4ms; …_64ms.lc is the light curve in 64ms; …_bb.lc is the Bayesian block light curve (none equal binning).

You can see the light curve by fv. For example,

Click "Plot" at the "RATE" extension. Then, specify "TIME-TRIGTIME" in "X" axis and "RATE" in "Y" axis.


You can zoom-in the light curve around the burst by dragging.


Note: what I usually do when I plot the light curves is dumping the data into ascii and plot with your favorite software (e.g. qdp, gnuplot). To dump the file into ascii, ftlist is a good ftools.

Check the help of ftlist for details (fhelp ftlist).

Contents of gti directory

The results based on the temporal analysis done by battblocks task are stored in this directory.

The best GRB duration measurement by battblocks is recorded in sw[obsid]b_dur.gti file.
Note that this estimation is using the mask-weighted light curve in the 15-350 keV band.

For example, T90 start and stop time in MET is

In this case, T90 duration is 263607790.864000 - 263607785.232000 = 5.632 s.

Similarly, T50 is 2.368 s.

Those T50/T90 information is stored in report.txt file (see above).

The spacecraft slew information is recorded at sw*_acs_*gti files. The spacecraft slew start and stop information is in sw*acs_slew.gti file.

For the case of GRB 090510, the spacecraft slew started at T0+16.2846 s and stopped
at T0+78.2846 s.

Contents of img directory

The sky FITS images created by batgrbproduct are stored in this directory. The pre-slew image which used to calculate the BAT ground position is sw(obsid)b_preslew_1chan.img. And the post-slew image is sw(obsid)b_postslew_1chan.img. All the image is created in the 15-350 keV band.

Let's look the pre-slew image by ds9.

Select zoom->zoom 1/2 in ds9. You will see:


When your eyes are getting used to BAT sky image, you can find the burst at green arrow location. Let's zoom-in that portion of the image.

Put your cursor at the location of green arrow. Middle click (Mac Option+click). Select zoom 4. Here you go. That's the GRB in 10.9 sigma detection in BAT.


Note: how to find the foreground and the background interval for creating the sky image:
The pre-slew sky image is created by pre-slew DPI minus pre-burst DPI (unless batgrbproduct
failed to find the pre-burst interval). Therefore, the foreground interval is the GTI of the pre-slew
DPI (GTI of the DPI is in 2nd extension):

The background interval is the GTI of the pre-burst DPI:

So, in this case, the foreground interval of the pre-slew image is from T0 to T0+6224 s
and the background interval is from T0-212.7154 to T0.

Contents of pha directory

The time-averaged spectrum (T100 interval) is sw*_total.pha. First, let's check the interval (start and stop time) of the spectrum. The start and stop time information of the spectrum is stored in the 3rd extension (GTI extension).

The spectral interval of the time-averaged spectrum doesn't contain the spacecraft slew interval (spacecraft slew started at T0+16.2846 s). Therefore, this spectrum can safely fit by the preslew energy response (sw00351588000b_preslew.rsp). In the 2nd and third xspec command (mdefine) in the example below is to define the user model called "pow50" and "cutep50." "pow50" is the simple power-law model but it is normalized at 50 keV (instead of 1 keV in the default xspec power-law model "powerlaw"). The parameter "a" is the photon index. "cutep50" is the power-law times exponential cutoff model but it is parameterized Epeak (instead of E0) and also the normalization at 50 keV. The parameter "a" is the photon index and "b" is Epeak in keV.

The energy range which will be able to use in the standard BAT analysis is from 14 keV to 150 keV. This energy range is well calibrated based on the Crab data.


Let's try to fit the spectrum with a simple power-law model (pow50).


The best fit photon index is 1.156 and the normalization at 50 keV is 8.679e-3 ph/cm2/s/keV.

Next step is to calculate the errors and flux (or fluence). To calculate the error of parameters,
"error" command is used. The "flux" command is used in the lower example.

By using "error" command, you can calculate the error of free parameters. "err 1" means calculate the error of parameter 1 which means "a" (photon index). In default (if you don't specify 3rd argument), the calculated error by "error" command is 90% confidence (you can calculate whatever confidence level you want by specifying 3rd argument). The flux in the specific energy range can be calculated by "flux" command. The 2nd and 3rd arguments are lower and upper energy range of the flux measurement. The number by "flux" command is the time-averaged flux of input spectrum. Since what we input is the "total" (T100) spectrum, you can get the energy fluence by multiplying the duration of the spectrum (6.224 s). In this case, the fluence in the 15-150 keV band is 5.55e-7 erg/cm2. By adding "err" in the 4th column (which is the number of set of parameters), flux command will calculate the error whatever the confidence you specified in the 6th argument (in upper case "90" which means 90% confidence).

Note: I personally prefer to use "pegpwrlw" model to calculate the flux in a simple power-law model. Here is the example of using pegpwrlw to calculate the flux.

If you want to calculate the flux between 15 keV and 150 keV, the 2nd and 3rd parameters
are 15 and 150. When you do the "fit," the 4th parameter is in the unit of 1e-12 erg/cm/2.

Let's fit with a power-law times exponential cutoff model, cutep50, (same definition as "Comptonized model" which BATSE team used).

The chi2 in a cutoff power-law model is 70.74 (56 dof). On the other hand, the chi2 is a simple power-law model is 70.71 (57 dof). There is no significant improvement in chi2 in a cutoff power-law model fit over a simple power-law fit. Therefore, the accepted model from the BAT data is a simple power-law.

Note: Majority of the BAT spectrum is successfully fit by a simple power-law model (~80%). But this doesn't necessary mean the Eepak is always above the BAT energy range (see Sakamoto et al. 2009).

Contents of auxil directory

This directory contains the FITS file of the auxiliary raytracing file (sw[obsid]b_all.evaux), the enable/disable map (flight enable/disable map + ground bathotpix/batdetmask run;sw[obsid]b_qmap.fits), the input catalog (sw[obsid]b_intput.cat), the output catalog (sw[obsid]b_output.cat) and the spacecraft file (sw[obsid]sat.fits.gz).

The output catalog file (sw(obsid)b_output.cat) contains the information about the BAT position of the burst based on the batgrbproduct. You can extract the BAT ground position and SNR information by ftools ftlist. Those numbers should match with the numbers in report.txt file (Refined Postion:).

Contents of dpi directory

This directory contains the Detector Plane Image (DPI) of a pre-burst (from a start time of the event data to a start time of BAT T0; "preburst"), a pre-slew (from a start time of the burst T0 to a stop time of BAT T100 or a spacecraft slew start time; "preslew") and a post-slew (from a start time of a spacecraft slew stop time to a stop time of the event data; "postslew"). "1chan" is the DPI in the 15-350 keV band (total) and "4chan" is the DPIs in the 15-25 keV, 25-50 keV, 50-100 keV and 100-350 keV band (4 band images).

You can see the DPI by ds9. Below is example of seeing pre-slew 1 channel DPI by ds9.

taka>ds9 sw00351588000b_preslew_1chan.dpi


Contents of event directory

The "masktagged" event data are stored in this directory. The full length event data are sw[obsid]b_all.evt. There are additional three event data products splitting the whole event data to 1) pre-slew interval (sw[obsid]b_preslew.evt), 2) during the slew (sw[obsid]b_slew.evt) and 3) post-slew interval (sw[obsid]b_postslew.evt).

Contents of process.log

"process.log" is the log file of all the processes run by batgrbproduct.

Analysis threads

I want to create the BAT light curve with different time bin and energy band.

If you want to create the BAT light curve with different time bin and/or energy band, you can create it by running "batbinevt" task. See below for the example of making the BAT light curve in 16ms bin and in the 15-150 keV band. You need to specify "timedel" option to "0.016" (s). And also, "energybins" as "15-150" which means from 15 to 150 keV. For "detmask," you should use the mask file created by the batgrbproduct (located at auxil directory).

You might also want to see "Making BAT Light Curves" section at the BAT Analysis Threads web page (http://heasarc.gsfc.nasa.gov/docs/swift/analysis/threads/bat_threads.html).


I want to create the spectrum at the different time region.

See the BAT-GBM joint fit (below).
See the "Making BAT Spectra and Response Matrices" at the BAT analysis threads.


Do the spectral fit at the interval which includes the spacecraft slew

Let's check the time-averaged spectral interval of GRB 100906A.

Since the trigger time is 305473773.568, the interval is from T0(BAT)-0.192s to T0(BAT)+130.456s.

Let's check the slew start and stop time.

So, the BAT time-averaged spectrum includes pre-slew, slew and post-slew interval.
Let's create the weighted energy respose using addrmf_bat.sh script.


averaged.rmf is the weighted count averaged energy response to be used to fit the BAT time-averaged spectrum (sw00433509000b_total.pha).

Step by step process to create the BAT spectrum to do joint fit with the Fermi data

Find the start and stop time in Swift MET for the interval to create the spectrum to do the joint fit

GRB 090510

The BAT trigger time, T0(BAT), is:

(always a good idea to refer the BAT trigger time from report.txt file)

The Fermi/GBM trigger time, T0(GBM), is 2009-05-10T00:22:59.97 (Fermi MET:263607781.971090). The time-averaged spectrum defined in Ackermann et al. is T0(GBM)+0.5 to T0(GBM)+1.0s. This corresponds 23:00:00.47 to 23:00:00.97 in UT. When I convert this GBM start and stop time into the offset time from the BAT trigger time, the start and stop time is T0(BAT)-0.018 and T0(BAT)+0.482. Therefore the Swift MET interval is from 263607785.198 to 263607785.698.

GRB 100906A

The BAT trigger time T0(BAT) is:

The Fermi/GBM trigger time T0(GBM) is 2010-09-06 13:49:27.630 UT (Fermi MET: 305473769.629578).

Making the BAT spectrum and the energy response file at the specific time interval

GRB 090510

Now we know what is the tstart and tstop time in Swift MET for creating the BAT spectrum to do the joint fit. Let's run several BAT tools to create the spectrum.

Joint fit with GBM pha files by xspec

GRB 090510







T. Sakamoto (11/09/10)