Selecting the relevant events¶
In this tutorial you will learn how to select the relevant events for a target and how to determine the useful energy range for a set of observations.
Now you are ready for your first H.E.S.S. data analysis. As an exemple you will analyse the observations of the Crab nebula. Note that all the output from this notebook will go to the folder from which the notebook is executed.
As usual start by importing the gammalib, ctools, and cscripts Python modules.
In [1]:
import gammalib
import ctools
import cscripts
The first step of your analysis consists in selecting the relevant events from the observations. In this step you can select a specific energy range, time range, or region of interest. In the example below you will select events according to the safe energy thresholds that are defined in the effective area component of the instrument response functions. You do this by setting the hidden parameter usethres=DEFAULT. In addition, you will select all events within 2 degrees of the pointing direction. We will write the selected observations to disk for easier use in the following steps.
In [2]:
obsfile = 'obs_crab_selected.xml'
select = ctools.ctselect()
select['usethres'] = 'DEFAULT'
select['inobs'] = '$HESSDATA/obs/obs_crab.xml'
select['emin'] = 'INDEF' # no manual energy selection
select['rad'] = 2 # by default select around pointing direction of each observations
select['tmin'] = 'INDEF' # no temporal selection
select['outobs'] = obsfile
select.execute()
Below is a summary of the selected observations.
In [3]:
obs_container = gammalib.GObservations(obsfile)
print(obs_container)
=== GObservations ===
Number of observations ....: 4
Number of models ..........: 0
Number of observed events .: 9675
Number of predicted events : 0
Let’s look at the properties of each individual observation.
In [4]:
for obs in obs_container:
print(obs)
=== GCTAObservation ===
Name ......................: Crab
Identifier ................: 023523
Instrument ................: HESS
Event file ................: selected_hess_dl3_dr1_obs_id_023523.fits
Event type ................: EventList
Statistic .................: cstat
Ontime ....................: 1687 s
Livetime ..................: 1581.7368164 s
Deadtime correction .......: 0.937603329223474
User energy range .........: undefined
=== GCTAPointing ===
Pointing direction ........: (RA,Dec)=(83.633333333,21.514444444)
=== GCTAResponseIrf ===
Caldb mission .............:
Caldb instrument ..........:
Response name .............:
Energy dispersion .........: Not used
Safe energy range .........: 0.870963589956081 - 100 TeV
=== GCTAEventList ===
Number of events ..........: 2305 (disposed in "selected_hess_dl3_dr1_obs_id_023523.fits")
Time interval .............: 53343.9223400926 - 53343.9418655556 days
Energy interval ...........: 0.870963589956081 - 100 TeV
Region of interest ........: RA=83.633333333333, DEC=21.514444444444 [0,0] Radius=2 deg
=== GSkyRegions ===
Number of regions .........: 0
=== GCTAObservation ===
Name ......................: Crab
Identifier ................: 023526
Instrument ................: HESS
Event file ................: selected_hess_dl3_dr1_obs_id_023526.fits
Event type ................: EventList
Statistic .................: cstat
Ontime ....................: 1683 s
Livetime ..................: 1572.6867676 s
Deadtime correction .......: 0.934454407367796
User energy range .........: undefined
=== GCTAPointing ===
Pointing direction ........: (RA,Dec)=(83.633333333,22.514444444)
=== GCTAResponseIrf ===
Caldb mission .............:
Caldb instrument ..........:
Response name .............:
Energy dispersion .........: Not used
Safe energy range .........: 0.707945784384138 - 100 TeV
=== GCTAEventList ===
Number of events ..........: 2571 (disposed in "selected_hess_dl3_dr1_obs_id_023526.fits")
Time interval .............: 53343.9542150926 - 53343.9736942593 days
Energy interval ...........: 0.707945784384138 - 100 TeV
Region of interest ........: RA=83.633333333333, DEC=22.514444444444 [0,0] Radius=2 deg
=== GSkyRegions ===
Number of regions .........: 0
=== GCTAObservation ===
Name ......................: Crab
Identifier ................: 023559
Instrument ................: HESS
Event file ................: selected_hess_dl3_dr1_obs_id_023559.fits
Event type ................: EventList
Statistic .................: cstat
Ontime ....................: 1686 s
Livetime ..................: 1578.1235352 s
Deadtime correction .......: 0.936016331672598
User energy range .........: undefined
=== GCTAPointing ===
Pointing direction ........: (RA,Dec)=(85.253333338,22.014444444)
=== GCTAResponseIrf ===
Caldb mission .............:
Caldb instrument ..........:
Response name .............:
Energy dispersion .........: Not used
Safe energy range .........: 0.660693448007596 - 100 TeV
=== GCTAEventList ===
Number of events ..........: 2631 (disposed in "selected_hess_dl3_dr1_obs_id_023559.fits")
Time interval .............: 53345.9619812963 - 53345.9814951852 days
Energy interval ...........: 0.660693448007596 - 100 TeV
Region of interest ........: RA=85.2533333381014, DEC=22.014444444444 [0,0] Radius=2 deg
=== GSkyRegions ===
Number of regions .........: 0
=== GCTAObservation ===
Name ......................: Crab
Identifier ................: 023592
Instrument ................: HESS
Event file ................: selected_hess_dl3_dr1_obs_id_023592.fits
Event type ................: EventList
Statistic .................: cstat
Ontime ....................: 1686 s
Livetime ..................: 1581.2646484 s
Deadtime correction .......: 0.937879388137604
User energy range .........: undefined
=== GCTAPointing ===
Pointing direction ........: (RA,Dec)=(82.013333329,22.014444444)
=== GCTAResponseIrf ===
Caldb mission .............:
Caldb instrument ..........:
Response name .............:
Energy dispersion .........: Not used
Safe energy range .........: 0.870963589956081 - 100 TeV
=== GCTAEventList ===
Number of events ..........: 2168 (disposed in "selected_hess_dl3_dr1_obs_id_023592.fits")
Time interval .............: 53347.9131965741 - 53347.932710463 days
Energy interval ...........: 0.870963589956081 - 100 TeV
Region of interest ........: RA=82.0133333285646, DEC=22.014444444444 [0,0] Radius=2 deg
=== GSkyRegions ===
Number of regions .........: 0
You will find that the following energy ranges were applied for the observations:
- id=023523: 0.871 - 100 TeV
- id=023526: 0.708 - 100 TeV
- id=023559: 0.661 - 100 TeV
- id=023592: 0.871 - 100 TeV
The overall energy range that you will from now on use for the data analysis is 0.66 - 100 TeV.