Review: LAT Data Analysis

Compare: pyLikelihood - Unbinned and Binned Analysis

Perform:

  1. Setup: SLAC Central Linux
  1. Get Data (using the Astro Server)
  1. UnbinnedAnalysis
    a.) Prerequisite Science Tools: UnbinnedAnalysis

    b.) pyLikelihood: UnbinnedAnalysis
  1. BinnedAnalysis
    a.) Prerequisite Science Tools: BinnedAnalysis

    b.) pyLikelihood: BinnedAnalysis
  1. Interactively Explore pyLikelihood Functions

Example: gt_apps python Script Used in Binaries RSP Analysis; (For more examples, see Richard Dubois' confluence page "Scripts used in Binaries RSP Analysis".

See pyLikelihood:

Also see:

Prerequisite Science Tools: BinnedAnalysis

Prerequisites

  • Setup SLAC Central Linux.
  • Make a subdirectory and name it binned_analysis.
  • Get 6 months of data using the new AstroServer:
    • Job Name — enter a meaningful name for your job (e.g., pyLike_6mosData_binned)
    • Event Sample — select p6_public_v2
    • Energy Range — Min: 100 Max:300000
    • Time Range — Min: 243756000 Max: 259308000
    • Position — RA: 343.6566 DEC: 16.1494
    • Radius — 15.0 degrees
    • Event Classes — Diffuse
    • Output — FT2 (fits).
    • Output — FT1 (fits) FT2 (fits)
    • Debug Mode — False
    • User Comment — optional
    • Click on the Proceed button
  • Copy the data to your binned_analysis directory.

Note: If you wish, you can download the following files obtained from SLAC's Data Portal and used in this tutorial:

 

Procedure

  1. Run gtselect.
  1. Select GTIs (using gtmktime).

Note: Steps 1 and 2, enable you to eliminate photons coming from the Earth limb by applying a zenith angle cut of 105o; gtmktime also updates the Good Time Intervals (GTIs) to match the FT2 data.

For a more detailed discussion, see Agreed procedures for data preparation: Removing Earth's Albedo and Correcting GTIs.

  1. Create an exposure cube (using gtltcube).

Note: gtltcube outputs an expCube.fits file, a HealPix table covering the full sky of the integrated livetime as a function.

  1. Create a 3D Counts Map (using gtbin CCUBE option).
  1. Create a Binned Exposure Map (using gtexpcube2).

The gtexpcube2 tool creates exposure maps that correspond to the counts maps generated above and are used in the likelihood analysis.  The maps cover the same region of the sky as the counts maps and have separate planes for different energies spanning the energy range of the counts maps.

Note: Available as of January 2011 in ScienceTools-09-20-00 and higher, gtexpcube2 replaces the "on-the-fly" binned exposure map calculation that was provided by gtsrcmaps, and it also replaces the gtexpcube application from the map_tools package. It is strongly recommended that the old gtexpcube application no longer be used for Likelihood analysis. (See ScienceTools-09-20-00 New Feature Summary in confluence.)

Important! The exposure needs to be recalculated if the ROI, zenith angle, time, event class, or energy selections applied to the data are changed. For the binned analysis, this also includes the spatial and energy binning of the 3D counts map.

  1. Create a source model XML file (using the Astro Data Viewer tool and the diffuse model recommend by the Diffuse Science Group).

Note: If you've already made a srcModel.xml file for the UnbinnedAnalysis, you can use the same one for the BinnedAnalysis.

  1. Compute Source Maps (using gtsrcmaps)

1. Run gtselect

Refer to: gtselect.
  1. Run gtselect as follows:

bash-3.2$ gtselect
Input FT1 file[pyLike_6mosData_binned-ft1.fits]
Output FT1 file[3C454-ft1.fits]
RA for new search center (degrees) (0:360) [180] 343.6566
Dec for new search center (degrees) (-90:90) [0] 16.1494
radius of new search region (degrees) (0:180) [15]
start time (MET in s) (0:) [243756000]
end time (MET in s) (0:) [259308000]
lower energy limit (MeV) (0:) [100]
upper energy limit (MeV) (0:) [300000]
maximum zenith angle value (degrees) (0:180) [105]
Done.
bash-3.2$

Note: Since we obtained our data from the Astro Data server and are only running gtselect to filter out any data greater than 105o, the maximum zenith angle, we could simply enter: Input FT1 file; Output FT1 file; radius of the new search region [180]; and maximum zenith angle value [105].

  1. Verify that the output file is now in your work directory.
 

2. Select GTIs
     (using gtmktime)

Refer to: gtmktime and and gtvcut

bash-3.2$ $ gtmktime
Spacecraft data file[pyLike_6mosData_binned-ft2-30s.fits]
Filter expression[(DATA_QUAL==1 && LAT_CONFIG==1 && ABS(ROCK_ANGLE)<52)]
Apply ROI-based zenith angle cut[yes]
Event data file[3C454-ft1.fits]
Output event file name[3C454_back-filtered.fits]

Tip: Use gtvcut if you wish to view the Data SubSpace Keywords. (See gtvcut Help file; also see Data SubSpace Keywords.

3. Create Exposure Hypercube
     (using gtltcube)

Refer to: gtltcube
  1. Run gtltcube.
bash-3.2$ gtltcube
Event data file[3C454_back-filtered.fits]
Spacecraft data file[pyLike_6mosData_binned-ft2-30s.fits]
Output file[3C454-expCube.fits]
Step size in cos(theta) (0.:1.) [0.025]
Pixel size (degrees)[1]
Working on file pyLike_6mosData_binned-ft2-30s.fits
.....................!
bash-3.2$
  1. Verify that the output file is now in your work directory.
 

4. Create a (3D) Counts Map
     (using gtbin CCube option)

Refer to: gtbin
  1. Run gtbin and select the CCUBE option.

Note: For the binned likelihood analysis, a three-dimensional counts map with an energy axis is required. Since the spectra of gamma-ray sources are expected to be fairly featureless and modeled rather simply, 20 logarithmically spaced energy bands over the range 30 MeV to 200 GeV is sufficient.

bash-3.2$ $ gtbin
This is gtbin version v2r2p3
Type of output file (CCUBE|CMAP|LC|PHA1|PHA2) [CCUBE]
Event data file name[3C454_back-filtered.fits]
Output file name[3C454-CMap-3D.fits]
Spacecraft data file name[pyLike_6mosData_binned-ft2-30s.fits]
Size of the X axis in pixels[160]
Size of the Y axis in pixels[160]
Image scale (in degrees/pixel)[0.25]
Coordinate system (CEL - celestial, GAL -galactic) (CEL|GAL) [CEL]
First coordinate of image center in degrees (RA or galactic l)[343.6566]
Second coordinate of image center in degrees (DEC or galactic b)[16.1494]
Rotation angle of image axis, in degrees[0]
Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN:[STG]
Algorithm for defining energy bins (FILE|LIN|LOG) [LOG]
Start value for first energy bin in MeV[100]
Stop value for last energy bin in MeV[300000]
Number of logarithmically uniform energy bins[20]
bash-3.2$
  1. Verify that the output file is now in your work directory.
 

5. Create Binned Exposure Map
     (using gtexpcube2)

Refer to: gtexpcube2

The gtexpcube2 tool creates exposure maps that correspond to the counts maps generated above; these exposure maps are then used in the likelihood analysis.  The maps cover the same region of the sky as the counts maps and have separate planes for different energies spanning the energy range of the counts maps. (See gtexpcube2 Help and gtexpcube2 parameter documentation.)

  1. Run gtexpcube2.

bash-3.2$ gtexpcube2
Livetime cube file[3C454-expCube.fits]
Counts map file[3C454_back-filtered.fits] 3C454-CMap-3D.fits
Output file name[3C454-binned-expMap.fits]
Response functions to use[P6_V3_DIFFUSE]
Computing binned exposure map....................!
bash-3.2$

  1. Verify that the output file is now in your work directory.
 

6. Create a Source Model XML File

If you have not already done so:

  1. Create a Source Model XML File (using Astro Data Viewer).
    1. Open a browser window (e.g., firefox).
    2. Then Launch the ASP Data Viewer:

      http://glast-ground.slac.stanford.edu/ASPDataViewer/

  2. Copy your XML source model file(s) to your binned_analysis directory on SLAC Central Linux (see example_3C454-srcModel.xml).

7. Compute Source Maps
     (using gtsrcmaps)

Refer to: gtsrcmaps

gtsrcmaps computes model count maps of each source, i.e., multiplied by exposure and convolved with the effective PSF.

Tip: It is also possible to have gtsrcmaps compute an all-sky map, using the energy bands of the 3D counts map. This exposure map can be reused for subsequent analysis of regions that cover the same time range, and that use the same energy binning. Should you wish to create an all-sky map, you would enter gtsrcmaps ptsrc=no at the command line, then enter Binned exposure map: none and Src maps output file all-sky. Files for both (i.e., "none" and "all-sky" will be generated and placed in your work directory. Later, when running gtlike, you would define your obs constructors as, for example: likeObs = BinnedObs('all-sky', '3C454-expCube.fits', 'none', 'P6_V3_DIFFUSE'). gtlike will then compute these on the fly if they appear in the XML definition and a corresponding map is not in the source maps FITS file.

However, since source map generation for the point sources is fairly quick, and maps for many point sources may take up a lot of disk space, it is preferrable to pre-compute the source maps for these sources at this stage:

bash-3.2$ gtsrcmaps
Exposure hypercube file[3C454-expCube.fits]
Counts map file[3C454-CMap-3D.fits]
Source model file[3C454-srcModel.xml]
Binned exposure map[3C454-binned-expMap.fits]
Source maps output file[3C454-srcMap.fits]
Response functions[P6_V3_DIFFUSE]
Generating SourceMap for EG_v02....................!
Generating SourceMap for EMS1499....................!
Generating SourceMap for EMS1505....................!
Generating SourceMap for EMS1517....................!
Generating SourceMap for EMS1524....................!
Generating SourceMap for EMS1525....................!
Generating SourceMap for EMS1538....................!
Generating SourceMap for EMS1562....................!
Generating SourceMap for GAL_v02....................!
Generating SourceMap for MST0985....................!
Generating SourceMap for PGW0130....................!
Generating SourceMap for PGW1179....................!
Generating SourceMap for PGW1984....................!
Generating SourceMap for UW2246+1551....................!
bash-3.2$

  1. Verify that the output file is now in your work directory.

You are now ready to perform a Binned pyLikelihood analysis; see pyLikelihood: BinnedAnalysis.


Owned by: Jim Chiang

Last updated by: Chuck Patterson 04/01/2011