{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Selecting the relevant events" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "
\"Download
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**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.**\n", "\n", "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.\n", "\n", "As usual start by importing the gammalib, ctools, and cscripts Python modules." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import gammalib\n", "import ctools\n", "import cscripts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "obsfile = 'obs_crab_selected.xml'\n", "select = ctools.ctselect()\n", "select['usethres'] = 'DEFAULT'\n", "select['inobs'] = '$HESSDATA/obs/obs_crab.xml'\n", "select['emin'] = 'INDEF' # no manual energy selection\n", "select['rad'] = 2 # by default select around pointing direction of each observations\n", "select['tmin'] = 'INDEF' # no temporal selection\n", "select['outobs'] = obsfile\n", "select.execute()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Below is a summary of the selected observations." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "=== GObservations ===\n", " Number of observations ....: 4\n", " Number of models ..........: 0\n", " Number of observed events .: 9675\n", " Number of predicted events : 0\n" ] } ], "source": [ "obs_container = gammalib.GObservations(obsfile)\n", "print(obs_container)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the properties of each individual observation." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "=== GCTAObservation ===\n", " Name ......................: Crab\n", " Identifier ................: 023523\n", " Instrument ................: HESS\n", " Event file ................: selected_hess_dl3_dr1_obs_id_023523.fits\n", " Event type ................: EventList\n", " Statistic .................: cstat\n", " Ontime ....................: 1687 s\n", " Livetime ..................: 1581.7368164 s\n", " Deadtime correction .......: 0.937603329223474\n", " User energy range .........: undefined\n", "=== GCTAPointing ===\n", " Pointing direction ........: (RA,Dec)=(83.633333333,21.514444444)\n", "=== GCTAResponseIrf ===\n", " Caldb mission .............: \n", " Caldb instrument ..........: \n", " Response name .............: \n", " Energy dispersion .........: Not used\n", " Safe energy range .........: 0.870963589956081 - 100 TeV\n", "=== GCTAEventList ===\n", " Number of events ..........: 2305 (disposed in \"selected_hess_dl3_dr1_obs_id_023523.fits\")\n", " Time interval .............: 53343.9223400926 - 53343.9418655556 days\n", " Energy interval ...........: 0.870963589956081 - 100 TeV\n", " Region of interest ........: RA=83.633333333333, DEC=21.514444444444 [0,0] Radius=2 deg\n", "=== GSkyRegions ===\n", " Number of regions .........: 0\n", "=== GCTAObservation ===\n", " Name ......................: Crab\n", " Identifier ................: 023526\n", " Instrument ................: HESS\n", " Event file ................: selected_hess_dl3_dr1_obs_id_023526.fits\n", " Event type ................: EventList\n", " Statistic .................: cstat\n", " Ontime ....................: 1683 s\n", " Livetime ..................: 1572.6867676 s\n", " Deadtime correction .......: 0.934454407367796\n", " User energy range .........: undefined\n", "=== GCTAPointing ===\n", " Pointing direction ........: (RA,Dec)=(83.633333333,22.514444444)\n", "=== GCTAResponseIrf ===\n", " Caldb mission .............: \n", " Caldb instrument ..........: \n", " Response name .............: \n", " Energy dispersion .........: Not used\n", " Safe energy range .........: 0.707945784384138 - 100 TeV\n", "=== GCTAEventList ===\n", " Number of events ..........: 2571 (disposed in \"selected_hess_dl3_dr1_obs_id_023526.fits\")\n", " Time interval .............: 53343.9542150926 - 53343.9736942593 days\n", " Energy interval ...........: 0.707945784384138 - 100 TeV\n", " Region of interest ........: RA=83.633333333333, DEC=22.514444444444 [0,0] Radius=2 deg\n", "=== GSkyRegions ===\n", " Number of regions .........: 0\n", "=== GCTAObservation ===\n", " Name ......................: Crab\n", " Identifier ................: 023559\n", " Instrument ................: HESS\n", " Event file ................: selected_hess_dl3_dr1_obs_id_023559.fits\n", " Event type ................: EventList\n", " Statistic .................: cstat\n", " Ontime ....................: 1686 s\n", " Livetime ..................: 1578.1235352 s\n", " Deadtime correction .......: 0.936016331672598\n", " User energy range .........: undefined\n", "=== GCTAPointing ===\n", " Pointing direction ........: (RA,Dec)=(85.253333338,22.014444444)\n", "=== GCTAResponseIrf ===\n", " Caldb mission .............: \n", " Caldb instrument ..........: \n", " Response name .............: \n", " Energy dispersion .........: Not used\n", " Safe energy range .........: 0.660693448007596 - 100 TeV\n", "=== GCTAEventList ===\n", " Number of events ..........: 2631 (disposed in \"selected_hess_dl3_dr1_obs_id_023559.fits\")\n", " Time interval .............: 53345.9619812963 - 53345.9814951852 days\n", " Energy interval ...........: 0.660693448007596 - 100 TeV\n", " Region of interest ........: RA=85.2533333381014, DEC=22.014444444444 [0,0] Radius=2 deg\n", "=== GSkyRegions ===\n", " Number of regions .........: 0\n", "=== GCTAObservation ===\n", " Name ......................: Crab\n", " Identifier ................: 023592\n", " Instrument ................: HESS\n", " Event file ................: selected_hess_dl3_dr1_obs_id_023592.fits\n", " Event type ................: EventList\n", " Statistic .................: cstat\n", " Ontime ....................: 1686 s\n", " Livetime ..................: 1581.2646484 s\n", " Deadtime correction .......: 0.937879388137604\n", " User energy range .........: undefined\n", "=== GCTAPointing ===\n", " Pointing direction ........: (RA,Dec)=(82.013333329,22.014444444)\n", "=== GCTAResponseIrf ===\n", " Caldb mission .............: \n", " Caldb instrument ..........: \n", " Response name .............: \n", " Energy dispersion .........: Not used\n", " Safe energy range .........: 0.870963589956081 - 100 TeV\n", "=== GCTAEventList ===\n", " Number of events ..........: 2168 (disposed in \"selected_hess_dl3_dr1_obs_id_023592.fits\")\n", " Time interval .............: 53347.9131965741 - 53347.932710463 days\n", " Energy interval ...........: 0.870963589956081 - 100 TeV\n", " Region of interest ........: RA=82.0133333285646, DEC=22.014444444444 [0,0] Radius=2 deg\n", "=== GSkyRegions ===\n", " Number of regions .........: 0\n" ] } ], "source": [ "for obs in obs_container:\n", " print(obs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You will find that the following energy ranges were applied for the observations:\n", "\n", "* id=023523: 0.871 - 100 TeV\n", "* id=023526: 0.708 - 100 TeV\n", "* id=023559: 0.661 - 100 TeV\n", "* id=023592: 0.871 - 100 TeV\n", "\n", "The overall energy range that you will from now on use for the data analysis is 0.66 - 100 TeV. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 2 }