ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
cscripts.cssens.cssens Class Reference
Inheritance diagram for cscripts.cssens.cssens:

Public Member Functions

def __init__
 
def __getstate__
 
def __setstate__
 
def process
 
def save
 
def sensitivity
 

Private Member Functions

def _get_parameters
 
def _median
 
def _set_source
 
def _set_obs
 
def _set_obs_ebounds
 
def _get_crab_flux
 
def _get_sensitivity
 
def _set_src_prefactor
 
def _simulate_events
 
def _sim_evt_excess
 
def _predict_flux
 
def _e_bin
 
def _create_fits
 

Private Attributes

 _ebounds
 
 _obs_ebounds
 
 _fits
 
 _srcname
 
 _ra
 
 _dec
 
 _log_clients
 
 _models
 
 _seed
 
 _nthreads
 

Detailed Description

Computes the CTA sensitivity

This class computes the CTA sensitivity for a number of energy bins using
ctlike. Spectra are fitted in narrow energy bins to simulated data,
and the flux level is determined that leads to a particular significance.

The significance is determined using the Test Statistic, defined as twice
the likelihood difference between fitting with and without the test source.

Definition at line 33 of file cssens.py.

Constructor & Destructor Documentation

def cscripts.cssens.cssens.__init__ (   self,
  argv 
)
Constructor

Definition at line 46 of file cssens.py.

Member Function Documentation

def cscripts.cssens.cssens.__getstate__ (   self)
def cscripts.cssens.cssens.__setstate__ (   self,
  state 
)
def cscripts.cssens.cssens._e_bin (   self,
  ieng 
)
private
def cscripts.cssens.cssens._get_crab_flux (   self,
  emin,
  emax 
)
private
Return Crab photon flux in a given energy interval

Parameters
----------
emin : `~gammalib.GEnergy`
    Minimum energy
emax : `~gammalib.GEnergy`
    Maximum energy

Returns
-------
flux : float
    Crab photon flux in specified energy interval (ph/cm2/s)

Definition at line 357 of file cssens.py.

Referenced by cscripts.cssens.cssens._get_sensitivity().

def cscripts.cssens.cssens._get_sensitivity (   self,
  emin,
  emax,
  test_model 
)
private
Determine sensitivity for given observations

Parameters
----------
emin : `~gammalib.GEnergy`
    Minimum energy for fitting and flux computation
emax : `~gammalib.GEnergy`
    Maximum energy for fitting and flux computation
test_model : `~gammalib.GModels`
    Test source model

Returns
-------
result : dict
    Result dictionary

Definition at line 383 of file cssens.py.

References cscripts.cssens.cssens._get_crab_flux(), cscripts.cssens.cssens._log_clients, cscripts.cssens.cssens._obs_ebounds, cscripts.cssens.cssens._predict_flux(), cscripts.cssens.cssens._seed, cscripts.cssens.cssens._set_obs_ebounds(), cscripts.cssens.cssens._set_src_prefactor(), cscripts.cssens.cssens._sim_evt_excess(), cscripts.csphagen.csphagen._srcname, cscripts.cssens.cssens._srcname, cscripts.csphasecrv.csphasecrv._srcname, cscripts.cslightcrv.cslightcrv._srcname, ctobservation.obs(), cscripts.csobsdef.csobsdef.obs(), and cscripts.csiactobs.csiactobs.obs().

Referenced by cscripts.cssens.cssens._e_bin().

def cscripts.cssens.cssens._median (   self,
  array 
)
private
Compute median value for an array

Parameters
----------
array : list of floats
    Array

Returns
-------
median : float
    Median value of array

Definition at line 178 of file cssens.py.

Referenced by cscripts.cssens.cssens._simulate_events().

def cscripts.cssens.cssens._predict_flux (   self,
  results,
  ts 
)
private
Predict Crab flux for a given TS value

The Crab flux at a given Test Statistic value is predicted by doing a
linear regression of the log(TS) and log(crab_flux) values in a results
list.

See https://en.wikipedia.org/wiki/Simple_linear_regression

Parameters
----------
results : list of dict
    List of results
ts : float
    Test Statistic value

Returns
-------
crab_flux_prediction, regcoeff : tuple of float
    Predicted Crab flux and regression coefficient

Definition at line 919 of file cssens.py.

Referenced by cscripts.cssens.cssens._get_sensitivity().

def cscripts.cssens.cssens._set_obs (   self,
  emin,
  emax 
)
private
Set an observation container

Parameters
----------
emin : float
    Minimum energy (TeV)
emax : float
    Maximum energy (TeV)

Returns
-------
obs : `~gammalib.GObservations`
    Observation container

Definition at line 240 of file cssens.py.

Referenced by cscripts.cssens.cssens._get_parameters().

def cscripts.cssens.cssens._set_obs_ebounds (   self,
  emin,
  emax 
)
private
Set energy boundaries for all observations in container

Parameters
----------
emin : `~gammalib.GEnergy`
    Minimum energy
emax : `~gammalib.GEnergy`
    Maximum energy

Definition at line 307 of file cssens.py.

References cscripts.cssens.cssens._obs_ebounds, ctobservation.obs(), cscripts.csobsdef.csobsdef.obs(), and cscripts.csiactobs.csiactobs.obs().

Referenced by cscripts.cssens.cssens._get_sensitivity().

def cscripts.cssens.cssens._set_src_prefactor (   self,
  test_model,
  crab_unit,
  test_crab_flux 
)
private
Create a copy of the test models, set the normalisation parameter
of the test source in the models, and append the models to the observation.

Parameters
----------
test_model : `~gammalib.GModels`
    Test source model
crab_unit : float
    Crab unit factor
test_crab_flux : float
    Test flux in Crab units (100 mCrab)

Returns
-------
crab_prefactor : float
    the prefactor that corresponds to a flux of 1 Crab.

Definition at line 724 of file cssens.py.

References cscripts.csphagen.csphagen._srcname, cscripts.cssens.cssens._srcname, cscripts.csphasecrv.csphasecrv._srcname, cscripts.cslightcrv.cslightcrv._srcname, ctobservation.obs(), cscripts.csobsdef.csobsdef.obs(), and cscripts.csiactobs.csiactobs.obs().

Referenced by cscripts.cssens.cssens._get_sensitivity().

def cscripts.cssens.cssens._sim_evt_excess (   self,
  enumbins,
  binsz,
  npix,
  n_bck_evts 
)
private
Return the number of excess events for the source model, compared
to all other models

Parameters
----------
enumbins : int
    Number of bins for the observation simulation
binsz : float
    Bin size for the observation simulation
npix : int
    Pixel size for the observation simulation
n_bck_evts : int
    Number of background counts from previous call

Returns
-------
pass_evt_cut : bool
    Signals that the source passes the minimal excess criteria
n_bck_evts : int
    Number of background counts

Definition at line 841 of file cssens.py.

References cscripts.cssens.cssens._simulate_events(), cscripts.csphagen.csphagen._srcname, cscripts.cssens.cssens._srcname, cscripts.csphasecrv.csphasecrv._srcname, cscripts.cslightcrv.cslightcrv._srcname, ctobservation.obs(), cscripts.csobsdef.csobsdef.obs(), and cscripts.csiactobs.csiactobs.obs().

Referenced by cscripts.cssens.cssens._get_sensitivity().

def cscripts.cssens.cssens._simulate_events (   self,
  obs,
  rad,
  enumbins,
  binsz,
  npix 
)
private
Simulate events

Parameters
----------
obs : `~gammalib.GObservations`
    Observation container
rad : float
    Simulation selection radius (degrees)
enumbins : integer
    Number of energy bins
binsz : float
    Pixel size
npix : integer
    Number of pixels

Definition at line 778 of file cssens.py.

References cscripts.cssens.cssens._log_clients, cscripts.cssens.cssens._median(), and cscripts.cssens.cssens._seed.

Referenced by cscripts.cssens.cssens._sim_evt_excess().

def cscripts.cssens.cssens.process (   self)
Process the script

Definition at line 1115 of file cssens.py.

References cscripts.csphasecrv.csphasecrv._create_fits(), cscripts.cspull.cspull._create_fits(), cscripts.cssens.cssens._create_fits(), cscripts.csfindobs.csfindobs._dec, cscripts.cssens.cssens._dec, cscripts.cssens.cssens._e_bin(), cscripts.csobsselect.csobsselect._get_parameters(), cscripts.csadd2caldb.csadd2caldb._get_parameters(), cscripts.csebins.csebins._get_parameters(), cscripts.csmodelselect.csmodelselect._get_parameters(), cscripts.csroot2caldb.csroot2caldb._get_parameters(), cscripts.csresmap.csresmap._get_parameters(), cscripts.csresspec.csresspec._get_parameters(), cscripts.csmodelinfo.csmodelinfo._get_parameters(), cscripts.csmodelmerge.csmodelmerge._get_parameters(), cscripts.csobsinfo.csobsinfo._get_parameters(), cscripts.csfindobs.csfindobs._get_parameters(), cscripts.csiactdata.csiactdata._get_parameters(), cscripts.csiactcopy.csiactcopy._get_parameters(), cscripts.cscaldb.cscaldb._get_parameters(), cscripts.csmodelsois.csmodelsois._get_parameters(), cscripts.csobs2caldb.csobs2caldb._get_parameters(), cscripts.csbkgmodel.csbkgmodel._get_parameters(), cscripts.cspull.cspull._get_parameters(), cscripts.csfootprint.csfootprint._get_parameters(), cscripts.csiactobs.csiactobs._get_parameters(), cscripts.csobsdef.csobsdef._get_parameters(), cscripts.cssens.cssens._get_parameters(), cscripts.csphasecrv.csphasecrv._get_parameters(), cscripts.cslightcrv.cslightcrv._get_parameters(), cscripts.csscs.csscs._get_parameters(), cscripts.csphagen.csphagen._get_parameters(), cscripts.csbkgmodel.csbkgmodel._models, cscripts.csmodelselect.csmodelselect._models, cscripts.csmodelinfo.csmodelinfo._models, cscripts.csmodelmerge.csmodelmerge._models, cscripts.csphagen.csphagen._models, cscripts.csiactobs.csiactobs._models, cscripts.csmodelsois.csmodelsois._models, cscripts.cssens.cssens._models, cscripts.cspull.cspull._nthreads, cscripts.csscs.csscs._nthreads, cscripts.csphagen.csphagen._nthreads, cscripts.cssens.cssens._nthreads, cscripts.csphasecrv.csphasecrv._nthreads, cscripts.cslightcrv.cslightcrv._nthreads, cscripts.csfindobs.csfindobs._ra, cscripts.cssens.cssens._ra, cscripts.csphagen.csphagen._srcname, cscripts.cssens.cssens._srcname, cscripts.csphasecrv.csphasecrv._srcname, cscripts.cslightcrv.cslightcrv._srcname, ctobservation.obs(), cscripts.csobsdef.csobsdef.obs(), and cscripts.csiactobs.csiactobs.obs().

def cscripts.cssens.cssens.sensitivity (   self)
Return sensitivity FITS file

Returns:
    FITS file containing sensitivity curve

Definition at line 1199 of file cssens.py.

References cscripts.cspull.cspull._fits, cscripts.csresspec.csresspec._fits, cscripts.csscs.csscs._fits, cscripts.cssens.cssens._fits, cscripts.csphasecrv.csphasecrv._fits, and cscripts.cslightcrv.cslightcrv._fits.

Member Data Documentation


The documentation for this class was generated from the following file: