Previous topic

First steps with ctools

Next topic

Binning CTA data

Simulating CTA dataΒΆ

You can simulate a CTA observation with the ctobssim tool.

To invoke the tool, type ctobssim at the console prompt (which is denoted by $). ctobssim will query for a number of parameters:

$ ctobssim
RA of pointing (degrees) (0-360) [83.63]
Dec of pointing (degrees) (-90-90) [22.01]
Radius of FOV (degrees) (0-180) [5.0]
Start time (MET in s) [0.0]
End time (MET in s) [1800.0]
Lower energy limit (TeV) [0.1]
Upper energy limit (TeV) [100.0]
Calibration database [prod2]
Instrument response function [South_0.5h]
Input model XML file [$CTOOLS/share/models/crab.xml]
Output event data file or observation definition XML file [events.fits]

Each line represents a query for one parameter value. The line starts with a short description of the parameter, followed by the default value proposed by ctobssim in squared brackets [ ].

If no parameter is entered the default value will be used (which is the case for all parameters shown here). Otherwise, the specified value will overwrite the default value. The round brackets ( ) indicate the range of possible parameter values (if applicable).

You may have recognised that the environment variable $CTOOLS has been used in the path name of the model. ctools will automatically expand the environment variables in parameter inputs.

The CTA instrument properties (effective area, PSF width) are taken from the prod2 database. The response for the southern array using the cuts optimised for 50 hours of observing time are used.

Note

ctools comes bundled with CTA response functions for the northern and the southern array. The response functions are based on a Prod2 analysis with cuts optimised for 0.5 hours, 5 hours and 50 hours of observing time. The following Instrument Response Functions (IRFs) are available: North_0.5h, North_5h, North_50h, South_0.5h, South_5h, and South_50h.

Events are simulated based on the instrument properties and based on a source and background model. Only events that fall within the specified region of interest (ROI), defined as a circle around a sky position in Right Ascension and Declination (in degrees), will be stored in the output event data file. The duration of the simulation is taken here to 30 minutes (or 1800 seconds). Events are simulated for energies between 0.1 and 100 TeV.

The source and background model is defined by the XML file $CTOOLS/share/models/crab.xml:

<?xml version="1.0" standalone="no"?>
<source_library title="source library">
  <source name="Crab" type="PointSource">
    <spectrum type="PowerLaw">
       <parameter name="Prefactor" scale="1e-16" value="5.7"  min="1e-07" max="1000.0" free="1"/>
       <parameter name="Index"     scale="-1"    value="2.48" min="0.0"   max="+5.0"   free="1"/>
       <parameter name="Scale"     scale="1e6"   value="0.3"  min="0.01"  max="1000.0" free="0"/>
    </spectrum>
    <spatialModel type="SkyDirFunction">
      <parameter name="RA"  scale="1.0" value="83.6331" min="-360" max="360" free="0"/>
      <parameter name="DEC" scale="1.0" value="22.0145" min="-90"  max="90"  free="0"/>
    </spatialModel>
  </source>
  <source name="CTABackgroundModel" type="CTAIrfBackground" instrument="CTA">
    <spectrum type="PowerLaw">
      <parameter name="Prefactor" scale="1.0"  value="1.0"  min="1e-3" max="1e+3"   free="1"/>
      <parameter name="Index"     scale="1.0"  value="0.0"  min="-5.0" max="+5.0"   free="1"/>
      <parameter name="Scale"     scale="1e6"  value="1.0"  min="0.01" max="1000.0" free="0"/>
    </spectrum>
  </source>
</source_library>

The model consists of a source library that contains two components: the Crab nebula and an instrumental background model.

The Crab nebula is modelled by a factorized sky model that has a spectral and a spatial component (tags <spectrum> and <spatialModel>, respectively). The spectrum is modelled by a power law, which is defined by three parameters: the Prefactor, the Index and the Scale. The spatial model has two parameters: Right Ascension in degrees (RA), and Declination in degrees (DEC). Each parameter has a value and a scale factor, the real value of the parameter being the product value * scale. Typically, scale is chosen so that value is of the order of 1 (this is relevant for model fitting). In addition, value is bound by a minimum (min) and maximum (max) value, and a parameter may be free (free="1") or fixed (free="0"). The min, max, and free attributes are not relevant here for the simulations, but they will be important for the model fitting later.

The spectral intensity I(E) (in units of photons/cm2/s/MeV) of the power law is given by

\[\frac{dN}{dE} = N_0 \left( \frac{E}{E_0} \right)^{\gamma}\]

where the parameters in the XML definition have the following mappings:

  • \(N_0\) = Prefactor
  • \(\gamma\) = Index
  • \(E_0\) = Scale

Warning

Energies are given in the XML file in MeV units. This is a GammaLib convention that can not be modified. So make sure you always use MeV as energy unit in an XML file.

The instrumental background of CTA is modelled using the background information provided in the IRF (CTAIrfBackground) multipled by a power law. As it is defined here, the power law represents a constant of 1, hence the background IRF will be used without any modification. The power law will become active when fitting the data later and allows a spectral adjustment of the background model that may account for uncertainties in the background information provided in the IRF.

ctobssim has a couple of hidden parameters, the most important one being certainly seed. seed is an integer that specifies the seed value for the random number generator, and changing this parameter will allow to generate statistically independent Monte Carlo samples of CTA event data. To use for example a seed value of 41 you should type:

$ ctobssim seed=41

ctobssim will write 2 files in the working directory: events.fits and ctobssim.log. The first file contains the simulated events in FITS format and can be inspected using fv or ds9. The FITS file will contain three extensions: an empty primary image, a binary table named EVENTS that holds the events (one row per event), and a binary table named GTI holding the Good Time Intervals (for the moment a single row with 2 columns providing the start and the stop time of the simulated time interval).

The second file produced by ctobssim is a human readable log file that contains information about the job execution. As example, the last lines from this file are shown here:

2015-12-07T20:48:30: +======================+
2015-12-07T20:48:30: | Simulate observation |
2015-12-07T20:48:30: +======================+
2015-12-07T20:48:30: === CTA observation ===
2015-12-07T20:48:30:  Simulation area ...........: 1.9635e+11 cm2
2015-12-07T20:48:30:  Simulation cone ...........: RA=83.63 deg, Dec=22.01 deg, r=5.5 deg
2015-12-07T20:48:30:  Time interval .............: 0 - 1800 s
2015-12-07T20:48:30:  Photon energy range .......: 100 GeV - 100 TeV
2015-12-07T20:48:30:  Event energy range ........: 100 GeV - 100 TeV
2015-12-07T20:48:30:  Use model .................: Crab
2015-12-07T20:48:30:  Normalization .............: 1 [Crab]
2015-12-07T20:48:30:  Flux ......................: 5.87297e-10 [Crab] photons/cm2/s
2015-12-07T20:48:30:  Normalized flux ...........: 5.87297e-10 [Crab] photons/cm2/s
2015-12-07T20:48:30:  Photon rate ...............: 115.316 photons/s [Crab]
2015-12-07T20:48:31:  MC source photons .........: 207547 [Crab]
2015-12-07T20:48:31:  MC source events ..........: 3646 [Crab]
2015-12-07T20:48:31:  MC source events ..........: 3646 (all source models)
2015-12-07T20:48:33:  MC events outside ROI .....: 0
2015-12-07T20:48:33:  MC background events ......: 19039
2015-12-07T20:48:33:  MC events .................: 22685 (all models)

Each line starts with the UTC time at which the line has been written. In this run, 207547 Crab photons have been thrown over an area of 19.6 square kilometres during a time interval of 1800 seconds. 3646 of these photons have been registered by CTA as events. In the same time interval, 19039 background events have been registred by CTA.

You may change the name of the log file using the hidden parameter logfile:

$ ctobssim logfile=my-private-log-file

Furthermore, you may decide on the amount of information provided in the log file (the chattiness of the executable) using the hidden parameter chatter:

$ ctobssim chatter=4

chatter can vary between 0 and 4, 0 providing no information while 4 provides the most detailed information.

By default, all ctools have a chatter level of 2.

You may also duplicate the log file information into the console by setting the hidden debug parameter to yes:

$ ctobssim debug=yes