ctools
2.0.0
|
Butterfly calculation tool. More...
#include <ctbutterfly.hpp>
Public Member Functions | |
ctbutterfly (void) | |
Void constructor. More... | |
ctbutterfly (const GObservations &obs) | |
Observations constructor. More... | |
ctbutterfly (int argc, char *argv[]) | |
Command line constructor. More... | |
ctbutterfly (const ctbutterfly &app) | |
Copy constructor. More... | |
virtual | ~ctbutterfly (void) |
Destructor. More... | |
ctbutterfly & | operator= (const ctbutterfly &app) |
Assignment operator. More... | |
void | clear (void) |
Clear ctbutterfly tool. More... | |
void | process (void) |
Computes the butterfly. More... | |
void | save (void) |
Save butterfly diagram. More... | |
const GFits & | butterfly (void) const |
Return butterfly FITS file. More... | |
Public Member Functions inherited from ctlikelihood | |
ctlikelihood (const std::string &name, const std::string &version) | |
Name constructor. More... | |
ctlikelihood (const std::string &name, const std::string &version, const GApplicationPars &pars) | |
Application parameters constructor. More... | |
ctlikelihood (const std::string &name, const std::string &version, int argc, char *argv[]) | |
Command line constructor. More... | |
ctlikelihood (const std::string &name, const std::string &version, const GObservations &obs) | |
Observations constructor. More... | |
ctlikelihood (const ctlikelihood &app) | |
Copy constructor. More... | |
virtual | ~ctlikelihood (void) |
Destructor. More... | |
ctlikelihood & | operator= (const ctlikelihood &app) |
Assignment operator. More... | |
void | opt (const GOptimizer *opt) |
Set optimizer. More... | |
const GOptimizer * | opt (void) const |
Return optimizer. More... | |
Public Member Functions inherited from ctobservation | |
ctobservation (const std::string &name, const std::string &version) | |
Name constructor. More... | |
ctobservation (const std::string &name, const std::string &version, const GApplicationPars &pars) | |
Application parameters constructor. More... | |
ctobservation (const std::string &name, const std::string &version, int argc, char *argv[]) | |
Command line constructor. More... | |
ctobservation (const std::string &name, const std::string &version, const GObservations &obs) | |
Observations constructor. More... | |
ctobservation (const ctobservation &app) | |
Copy constructor. More... | |
virtual | ~ctobservation (void) |
Destructor. More... | |
ctobservation & | operator= (const ctobservation &app) |
Assignment operator. More... | |
void | obs (const GObservations &obs) |
Set observation container. More... | |
const GObservations & | obs (void) const |
Return observation container. More... | |
Public Member Functions inherited from ctool | |
ctool (const std::string &name, const std::string &version) | |
Name constructor. More... | |
ctool (const std::string &name, const std::string &version, const GApplicationPars &pars) | |
Application parameter constructor. More... | |
ctool (const std::string &name, const std::string &version, int argc, char *argv[]) | |
Command line constructor. More... | |
ctool (const ctool &app) | |
Copy constructor. More... | |
virtual | ~ctool (void) |
Destructor. More... | |
ctool & | operator= (const ctool &app) |
Assignment operator. More... | |
virtual void | run (void) |
Run ctool. More... | |
virtual void | execute (void) |
Execute ctool. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const ctbutterfly &app) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | get_parameters (void) |
Get application parameters. More... | |
void | gaussian_error_propagation (GModels &models) |
Compute butterfly using Gaussian error propagation. More... | |
void | ellipsoid_boundary (GModels &models) |
Compute butterfly using the ellipsoid boundary method. More... | |
void | check_model (void) |
Check if sky model is valid. More... | |
void | eigenvectors (const double &a, const double &b, const double &c, const double &d, double *lambda1, double *lambda2, GVector *vector1, GVector *vector2) |
Compute normalized eigenvectors and eigenvalues. More... | |
void | create_fits (void) |
Set result FITS file. More... | |
Protected Member Functions inherited from ctlikelihood | |
double | evaluate (GModelPar &par, const double &value) |
Evaluates the log-likelihood function. More... | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const ctlikelihood &app) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from ctobservation | |
GCTAObservation * | first_unbinned_observation (void) |
Return first unbinned CTA observation. More... | |
GCTAObservation * | next_unbinned_observation (void) |
Return next unbinned CTA observation. More... | |
const GCTAObservation * | first_unbinned_observation (void) const |
Return first unbinned CTA observation (const version) More... | |
const GCTAObservation * | next_unbinned_observation (void) const |
Return next unbinned CTA observation (const version) More... | |
void | read_ogip_keywords (GFitsHDU *hdu) const |
Read OGIP keywords from FITS HDU. More... | |
void | write_ogip_keywords (GFitsHDU *hdu) const |
Write OGIP keywords in FITS HDU. More... | |
void | set_obs_statistic (const std::string &statistic) |
Set fit statistic for CTA observations. More... | |
void | set_obs_bounds () |
Set observation boundaries for CTA observations. More... | |
void | save_events_fits (void) |
Save event list in FITS format. More... | |
void | save_events_xml (void) |
Save event list(s) in XML format. More... | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const ctobservation &app) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from ctool | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const ctool &app) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | sync_pfiles (void) |
Synchronise parameter files. More... | |
const bool & | read_ahead (void) const |
Signal whether parameters should be read ahead. More... | |
void | setup_observations (GObservations &obs, const bool &response=true, const bool &list=true, const bool &cube=true) |
Setup observation container. More... | |
void | setup_models (GObservations &obs, const std::string &name="") |
Setup model container. More... | |
GEbounds | create_ebounds (void) |
Create energy boundaries from user parameters. More... | |
GEnergies | create_energies (void) |
Create energies from user parameters. More... | |
GSkyMap | create_map (const GObservations &obs) |
Create a skymap from user parameters. More... | |
GCTAEventCube | create_cube (const GObservations &obs) |
Create a CTA event cube from user parameters. More... | |
GCTAObservation | create_cta_obs (void) |
Create a CTA observation from User parameters. More... | |
void | require_inobs (const std::string &method) |
Throws exception if inobs parameter is not valid. More... | |
void | require_inobs_nolist (const std::string &method) |
void | require_inobs_nocube (const std::string &method) |
Throws exception if inobs parameter is a counts cube. More... | |
GCTARoi | get_roi (const GCTAPointing &pnt=GCTAPointing()) |
Return RoI from User parameters. More... | |
GEbounds | get_ebounds (void) |
Return energy boundaries from User parameters. More... | |
GGti | get_gti (const GTimeReference &ref) |
Return Good Time Intervals from User parameter. More... | |
GCTAPointing | get_pointing (void) |
Return CTA pointing from User parameters. More... | |
GSkyDir | get_skydir (void) |
Return sky direction from User parameters. More... | |
std::string | set_outfile_name (const std::string &filename) |
Set output file name. More... | |
bool | is_stacked (void) |
Query user parameters for stacked analysis. More... | |
bool | is_onoff (void) |
Query user parameters for On/Off analysis. More... | |
void | log_parameters (const GChatter &chatter) |
Log application parameters. More... | |
void | log_observations (const GChatter &chatter, const GObservations &obs, const std::string &what="Observation") |
Log observation container. More... | |
void | log_models (const GChatter &chatter, const GModels &models, const std::string &what="Model") |
Log model container. More... | |
void | set_response (GObservations &obs) |
Set response for all CTA observations in container. More... | |
std::vector< bool > | set_edisp (GObservations &obs, const bool &edisp) const |
Set energy dispersion to CTA observations. More... | |
void | restore_edisp (GObservations &obs, const std::vector< bool > &edisp) const |
Restore energy dispersion flags of CTA observations. More... | |
void | set_obs_response (GCTAObservation *obs) |
Set response for CTA observation. More... | |
GObservations | get_observations (const bool &get_response=true) |
Get observation container. More... | |
GSkyDir | get_mean_pointing (const GObservations &obs) |
Derives mean pointing from CTA observations. More... | |
size_t | get_current_rss (void) |
Get current resident set size (physical memory use) in Bytes. More... | |
std::string | get_obs_header (const GObservation *obs) const |
Return observation header string. More... | |
GEnergies | insert_energy_boundaries (const GEnergies &energies, const GCTAObservation &obs) |
Insert observation energy boundaries into list of energies. More... | |
std::vector< bool > | cube_layer_usage (const GEbounds &cube_ebounds, const GEbounds &list_ebounds) const |
Determine the counts cube layer usage. More... | |
std::string | get_gtiname (const std::string &filename, const std::string &evtname) const |
Get Good Time Intervals extension name. More... | |
void | save_event_list (const GCTAObservation *obs, const std::string &infile, const std::string &evtname, const std::string >iname, const std::string &outfile) const |
Save event list into FITS file. More... | |
std::string | warn_too_few_energies (const GEnergies &energies) const |
Set warning string if there are too few energies. More... | |
std::string | warn_xml_suffix (const GFilename &filename) const |
Set warning string if file has no .xml suffix. More... | |
void | provide_help (void) const |
Dump help text in the console. More... | |
Protected Attributes | |
std::string | m_srcname |
Name of source to compute butterfly. More... | |
std::string | m_method |
Computation method. More... | |
double | m_confidence |
Confidence level. More... | |
int | m_max_iter |
Maximum number of iterations. More... | |
bool | m_apply_edisp |
Apply energy dispersion? More... | |
bool | m_fit |
Do fit? More... | |
GEbounds | m_ebounds |
Energy binning definition. More... | |
GFilename | m_outfile |
Output ASCII file name. More... | |
GChatter | m_chatter |
Chattiness. More... | |
GMatrixSparse | m_covariance |
Covariance matrix. More... | |
std::vector< double > | m_energies |
Energy values. More... | |
std::vector< double > | m_intensities |
Power law intensity. More... | |
std::vector< double > | m_min_intensities |
Minimum intensities. More... | |
std::vector< double > | m_max_intensities |
Maximum intensities. More... | |
GFits | m_fits |
FITS file holding butterfly. More... | |
Protected Attributes inherited from ctlikelihood | |
GOptimizerLM | m_opt |
Optimizer. More... | |
Protected Attributes inherited from ctobservation | |
GObservations | m_obs |
Observation container. More... | |
Protected Attributes inherited from ctool | |
bool | m_read_ahead |
Read ahead output parameters. More... | |
bool | m_use_xml |
Use XML file instead of FITS file for observations. More... | |
Butterfly calculation tool.
This class computes the confidence interval of a fitted spectrum (butterfly) for a given set of observations.
The class operates on predefined observation containers, an individual event list or an observation definition XML file.
During the computation the covariance matrix of the fit is used to propagate uncertainties and their correlations through the entire energy range. The output is saved as an ascii files containing the confidence band boundaries
Definition at line 55 of file ctbutterfly.hpp.
ctbutterfly::ctbutterfly | ( | void | ) |
|
explicit |
Observations constructor.
param[in] obs Observation container.
This method creates an instance of the class by copying an existing observations container.
Definition at line 73 of file ctbutterfly.cpp.
References init_members().
ctbutterfly::ctbutterfly | ( | int | argc, |
char * | argv[] | ||
) |
Command line constructor.
[in] | argc | Number of arguments in command line. |
[in] | argv | Array of command line arguments. |
Definition at line 91 of file ctbutterfly.cpp.
References init_members().
ctbutterfly::ctbutterfly | ( | const ctbutterfly & | app | ) |
Copy constructor.
[in] | app | Application. |
Definition at line 107 of file ctbutterfly.cpp.
References copy_members(), and init_members().
|
virtual |
|
inline |
Return butterfly FITS file.
Definition at line 120 of file ctbutterfly.hpp.
References m_fits.
|
protected |
Check if sky model is valid.
GException::invalid_value | Did not find a valid model |
Checks whether the specified sky model exists and whether it is a power law.
Definition at line 786 of file ctbutterfly.cpp.
References G_CHECK_MODEL, m_method, ctobservation::m_obs, and m_srcname.
Referenced by get_parameters().
|
virtual |
Clear ctbutterfly tool.
Clears ctbutterfly tool.
Implements ctlikelihood.
Definition at line 180 of file ctbutterfly.cpp.
References free_members(), ctlikelihood::free_members(), ctool::free_members(), ctobservation::free_members(), init_members(), ctlikelihood::init_members(), ctool::init_members(), and ctobservation::init_members().
|
protected |
Copy class members.
[in] | app | Application. |
Definition at line 401 of file ctbutterfly.cpp.
References m_apply_edisp, m_chatter, m_confidence, m_covariance, m_ebounds, m_energies, m_fit, m_fits, m_intensities, m_max_intensities, m_max_iter, m_method, m_min_intensities, m_outfile, and m_srcname.
Referenced by ctbutterfly(), and operator=().
|
protected |
Set result FITS file.
Set the FITS file with the butterfly results.
Definition at line 897 of file ctbutterfly.cpp.
References m_energies, m_fits, m_intensities, m_max_intensities, and m_min_intensities.
Referenced by process().
|
protected |
Compute normalized eigenvectors and eigenvalues.
[in] | a | Covariance matrix element (0,0) |
[in] | b | Covariance matrix element (0,1) |
[in] | c | Covariance matrix element (1,0) |
[in] | d | Covariance matrix element (1,1) |
[out] | lambda1 | First eigenavlue |
[out] | lambda2 | Second eigenavlue |
[out] | vector1 | First eigenvector (normalized) |
[out] | vector2 | Second eigenvector (normalized) |
Computes the eigenvalues and eigenvectors for a 2x2 matrix. See http://www.math.harvard.edu/archive/21b_fall_04/exhibits/2dmatrices/index.html
Definition at line 844 of file ctbutterfly.cpp.
Referenced by ellipsoid_boundary().
|
protected |
Compute butterfly using the ellipsoid boundary method.
[in] | models | Models. |
Definition at line 503 of file ctbutterfly.cpp.
References eigenvectors(), m_confidence, m_covariance, m_ebounds, m_energies, m_intensities, m_max_intensities, m_min_intensities, and m_srcname.
Referenced by process().
|
protected |
Delete class members.
Definition at line 430 of file ctbutterfly.cpp.
Referenced by clear(), operator=(), and ~ctbutterfly().
|
protected |
Compute butterfly using Gaussian error propagation.
[in] | models | Models. |
Computes the butterfly diagram using Gaussian error propagation. This works for any kind of model.
Definition at line 661 of file ctbutterfly.cpp.
References m_confidence, m_covariance, m_ebounds, m_energies, m_intensities, m_max_intensities, m_min_intensities, ctobservation::m_obs, and m_srcname.
Referenced by process().
|
protected |
Get application parameters.
GException::feature_not_implemented | Loading of covariance matrix is not yet implemented. |
Get all task parameters from parameter file.
Definition at line 445 of file ctbutterfly.cpp.
References check_model(), ctool::create_ebounds(), G_GET_PARAMETERS, ctool::log_parameters(), m_apply_edisp, m_chatter, m_confidence, m_ebounds, m_fit, m_method, ctobservation::m_obs, ctlikelihood::m_opt, m_srcname, ctool::read_ahead(), ctobservation::set_obs_statistic(), ctool::setup_models(), and ctool::setup_observations().
Referenced by process().
|
protected |
Initialise class members.
Definition at line 371 of file ctbutterfly.cpp.
References m_apply_edisp, m_chatter, m_confidence, m_covariance, m_ebounds, m_energies, m_fit, m_fits, m_intensities, m_max_intensities, m_method, m_min_intensities, m_outfile, and m_srcname.
Referenced by clear(), ctbutterfly(), and operator=().
ctbutterfly & ctbutterfly::operator= | ( | const ctbutterfly & | app | ) |
Assignment operator.
[in] | app | Application. |
Definition at line 145 of file ctbutterfly.cpp.
References copy_members(), free_members(), init_members(), and ctlikelihood::operator=().
|
virtual |
Computes the butterfly.
This method takes the spectral fit and its covariance matrix to compute the confidence band via Gaussian error propagation
Implements ctlikelihood.
Definition at line 211 of file ctbutterfly.cpp.
References create_fits(), ellipsoid_boundary(), gaussian_error_propagation(), get_parameters(), ctool::log_observations(), m_apply_edisp, m_chatter, m_covariance, m_ebounds, m_energies, m_fit, m_intensities, m_max_intensities, m_method, m_min_intensities, ctobservation::m_obs, ctlikelihood::m_opt, and ctobservation::obs().
|
virtual |
Save butterfly diagram.
Saves the butterfly diagram FITS file.
Implements ctlikelihood.
Definition at line 338 of file ctbutterfly.cpp.
|
protected |
Apply energy dispersion?
Definition at line 98 of file ctbutterfly.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and process().
|
protected |
Chattiness.
Definition at line 102 of file ctbutterfly.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and process().
|
protected |
Confidence level.
Definition at line 96 of file ctbutterfly.hpp.
Referenced by copy_members(), ellipsoid_boundary(), gaussian_error_propagation(), get_parameters(), and init_members().
|
protected |
Covariance matrix.
Definition at line 105 of file ctbutterfly.hpp.
Referenced by copy_members(), ellipsoid_boundary(), gaussian_error_propagation(), init_members(), and process().
|
protected |
Energy binning definition.
Definition at line 100 of file ctbutterfly.hpp.
Referenced by copy_members(), ellipsoid_boundary(), gaussian_error_propagation(), get_parameters(), init_members(), and process().
|
protected |
Energy values.
Definition at line 106 of file ctbutterfly.hpp.
Referenced by copy_members(), create_fits(), ellipsoid_boundary(), gaussian_error_propagation(), init_members(), and process().
|
protected |
Do fit?
Definition at line 99 of file ctbutterfly.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and process().
|
protected |
FITS file holding butterfly.
Definition at line 110 of file ctbutterfly.hpp.
Referenced by butterfly(), copy_members(), create_fits(), init_members(), and save().
|
protected |
Power law intensity.
Definition at line 107 of file ctbutterfly.hpp.
Referenced by copy_members(), create_fits(), ellipsoid_boundary(), gaussian_error_propagation(), init_members(), and process().
|
protected |
Maximum intensities.
Definition at line 109 of file ctbutterfly.hpp.
Referenced by copy_members(), create_fits(), ellipsoid_boundary(), gaussian_error_propagation(), init_members(), and process().
|
protected |
Maximum number of iterations.
Definition at line 97 of file ctbutterfly.hpp.
Referenced by copy_members().
|
protected |
Computation method.
Definition at line 95 of file ctbutterfly.hpp.
Referenced by check_model(), copy_members(), get_parameters(), init_members(), and process().
|
protected |
Minimum intensities.
Definition at line 108 of file ctbutterfly.hpp.
Referenced by copy_members(), create_fits(), ellipsoid_boundary(), gaussian_error_propagation(), init_members(), and process().
|
protected |
Output ASCII file name.
Definition at line 101 of file ctbutterfly.hpp.
Referenced by copy_members(), init_members(), and save().
|
protected |
Name of source to compute butterfly.
Definition at line 94 of file ctbutterfly.hpp.
Referenced by check_model(), copy_members(), ellipsoid_boundary(), gaussian_error_propagation(), get_parameters(), and init_members().