ctools
2.0.0
|
Base class for ctools. More...
#include <ctool.hpp>
Public Member Functions | |
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 | clear (void)=0 |
virtual void | process (void)=0 |
virtual void | save (void)=0 |
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 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 | |
bool | m_read_ahead |
Read ahead output parameters. More... | |
bool | m_use_xml |
Use XML file instead of FITS file for observations. More... | |
Base class for ctools.
This class is the generic base class for all ctools. It enforces implementation of the clear(), run() and save() methods by all ctools, and it implements the execute() method.
The class also provides a number of helper methods for ctools.
ctool::ctool | ( | const std::string & | name, |
const std::string & | version | ||
) |
Name constructor.
[in] | name | Application name. |
[in] | version | Application version. |
Constructs a ctool from the name
and version
. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The parameters will be loaded from the parameter file.
No log file will be opened. To open the log file an explicit call to the logFileOpen() method is required.
This constructor should be used for using a ctool from Python.
Definition at line 90 of file ctool.cpp.
References init_members(), and sync_pfiles().
ctool::ctool | ( | const std::string & | name, |
const std::string & | version, | ||
const GApplicationPars & | pars | ||
) |
Application parameter constructor.
[in] | name | Application name. |
[in] | version | Application version. |
[in] | pars | Application parameters. |
Constructs a ctool from the name
, version
and application parameters pars
. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The constructor opens the log file.
Definition at line 116 of file ctool.cpp.
References init_members().
ctool::ctool | ( | const std::string & | name, |
const std::string & | version, | ||
int | argc, | ||
char * | argv[] | ||
) |
Command line constructor.
[in] | name | Application name. |
[in] | version | Application version. |
[in] | argc | Number of arguments in command line. |
[in] | argv | Array of command line arguments. |
Constructs a ctool from the name
, version
and command line arguments. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The parameters will be loaded from the parameter file. In addition, the constructor opens the log file.
If the "--help" option is provided as command line argument a help text about the usage of the ctool will be shown in the console and the ctool will exit. No log file will be opened in that case.
Definition at line 149 of file ctool.cpp.
References init_members(), provide_help(), and sync_pfiles().
ctool::ctool | ( | const ctool & | app | ) |
Copy constructor.
[in] | app | Application. |
Construct a ctools from another ctool instance.
Definition at line 181 of file ctool.cpp.
References copy_members(), and init_members().
|
virtual |
|
pure virtual |
Implemented in ctbin, ctbutterfly, cttsmap, ctmodel, ctobservation, ctobssim, ctulimit, ctlikelihood, ctphase, ctcubemask, ctfindvar, ctprob, ctselect, ctskymap, ctbkgcube, ctedispcube, ctexpcube, ctpsfcube, ctmapcube, ctool_like, ctool_obs, cterror, ctlike, and ctool_base.
|
protected |
Copy class members.
[in] | app | Application. |
Definition at line 343 of file ctool.cpp.
References m_read_ahead, and m_use_xml.
Referenced by ctool(), and operator=().
|
protected |
Create a CTA observation from User parameters.
Creates an empty CTA observation from User parameters. An empty event list including RoI, GTI and energy boundary information is attached to the observation. The method also sets the pointing direction using the ra and dec parameter, the ROI based on ra, dec and rad, a single GTI based on tmin and tmax, and a single energy boundary based on emin and emax. The method furthermore sets the ontime, livetime and deadtime correction factor.
The following parameters are read
ra: Right Ascension of pointing and RoI centre (deg) dec: Declination of pointing and RoI centre (deg) rad: Radius of RoI (deg) deadc: Deadtime correction factor tmin: Start time tmax: Stop time emin: Minimum energy (TeV) emax: Maximum energy (TeV) mjdref: Time reference (optional) instrument: Name of Cherenkov Telescope (optional)
If the time reference parametere "mjdref" is not available, the CTA time reference will be assumed.
Definition at line 1056 of file ctool.cpp.
References get_ebounds(), get_gti(), get_pointing(), and get_roi().
Referenced by ctmodel::get_obs(), and get_observations().
|
protected |
Create a CTA event cube from user parameters.
[in] | obs | Observation container. |
Creates an empty CTA event cube from input user parameters. The reference coordinate is extracted from the mean pointing of the CTA observations in the observation container (see get_mean_pointing()). This method will be used if a ctool has the input parameter usepnt=true. The method appends a dummy GTI to the event cube.
The following parameters are read: proj - Coordinate projection coordsys - Coordinate system binsz - Bin size (deg) nxpix - Number of pixels in Right Ascension or longitude nypix - Number of pixels in Declination or latitude ebinalg - Energy binning algorithm emin - Minimum energy (if ebinalg != FILE) emax - Maximum energy (if ebinalg != FILE) enumbins - Number of energy bins (if ebinalg != FILE)
Definition at line 1006 of file ctool.cpp.
References create_ebounds(), and create_map().
Referenced by ctedispcube::get_parameters(), ctpsfcube::get_parameters(), ctexpcube::get_parameters(), ctmodel::get_parameters(), and ctbin::get_parameters().
|
protected |
Create energy boundaries from user parameters.
GException::invalid_value | No valid energy boundary extension found or invalid extension name. |
Get the energy boundaries according to the user parameters. The method supports loading of energy boundary information from the EBOUNDS
or ENERGYBINS
extension, loading of energy value information from the ENERGIES
extension, or setting energy boundaries using a linear or logarithmical spacing.
The following parameters are read:
ebinalg - Energy binning algorithm ebinfile - Name of file with energy binning emin - Minimum energy (if ebinalg != FILE) emax - Maximum energy (if ebinalg != FILE) enumbins - Number of energy bins (if ebinalg != FILE)
Definition at line 612 of file ctool.cpp.
References G_CREATE_EBOUNDS.
Referenced by ctbin::create_cube(), create_cube(), ctmodel::get_obs(), ctmapcube::get_parameters(), and ctbutterfly::get_parameters().
|
protected |
Create energies from user parameters.
GException::invalid_value | No valid energies extension found or invalid extension name. |
Get the energy boundaries according to the user parameters. The method supports loading of energy node information from the ENERGIES
extension, loading energy nodes from energy the boundary extensions EBOUNDS
or ENERGYBINS
extension, or setting energy nodes using a linear or logarithmical spacing.
The following parameters are read:
ebinalg - Energy binning algorithm ebinfile - Name of file with energy binning (if ebinalg == FILE) emin - Minimum energy (if ebinalg != FILE) emax - Maximum energy (if ebinalg != FILE) enumbins - Number of energy bins (if ebinalg != FILE) ebingamma - Power law index (if ebinalg == POW)
Definition at line 776 of file ctool.cpp.
References G_CREATE_ENERGIES.
|
protected |
Create a skymap from user parameters.
[in] | obs | Observation container. |
Creates an empty skymap from input user parameters. The reference coordinate is extracted from the mean pointing of the CTA observations in the observation container (see get_mean_pointing()).
The following parameters are read: usepnt - Use pointing for reference coordinate? xref - Reference in Right Ascension or longitude (if usepnt=no) yref - Reference in Declination or latitude (if usepnt=no) proj - Coordinate projection coordsys - Coordinate system binsz - Bin size (deg) nxpix - Number of pixels in Right Ascension or longitude nypix - Number of pixels in Declination or latitude
Definition at line 937 of file ctool.cpp.
References get_mean_pointing().
Referenced by ctfindvar::create_cube(), create_cube(), ctfindvar::get_parameters(), ctskymap::get_parameters(), cttsmap::get_parameters(), and ctbin::init_sky_dir_cache().
|
protected |
Determine the counts cube layer usage.
[in] | cube_ebounds | Energy boundaries of the counts cube. |
[in] | list_ebounds | Energy boundaries of the event list. |
Determines a vector of counts cube layer usage flags that signal whether an event should actually be filled in the counts cube or not. This makes sure that no partially filled bins will exist in the counts cube.
Definition at line 2194 of file ctool.cpp.
Referenced by ctmodel::fill_cube(), ctbin::fill_cube(), ctbin::process(), and ctbin::set_weights().
|
virtual |
Execute ctool.
This method executes a ctool by calling the process() and save() methods of a ctool. The method signals that some parameters should be read ahead and switches on screen dump in case that the debug parameter is true.
Definition at line 285 of file ctool.cpp.
References m_read_ahead, process(), and save().
Referenced by execute_ctool().
|
protected |
Delete class members.
Definition at line 357 of file ctool.cpp.
Referenced by cterror::clear(), ctlike::clear(), ctool_base::clear(), ctmapcube::clear(), ctool_like::clear(), ctool_obs::clear(), ctedispcube::clear(), ctbkgcube::clear(), ctexpcube::clear(), ctpsfcube::clear(), ctskymap::clear(), ctselect::clear(), ctfindvar::clear(), ctprob::clear(), ctcubemask::clear(), ctphase::clear(), ctulimit::clear(), ctobssim::clear(), ctmodel::clear(), cttsmap::clear(), ctbutterfly::clear(), ctbin::clear(), operator=(), and ~ctool().
|
protected |
|
protected |
Return energy boundaries from User parameters.
Returns energy boundaries from the User parameters emin
and emax
. If one of emin
or emax
is not valid, an empty energy boundaries object is returned. If emin
is not valid, emax
is not queried.
Definition at line 1378 of file ctool.cpp.
Referenced by create_cta_obs(), and ctobssim::simulate_source().
|
protected |
Return Good Time Intervals from User parameter.
[in] | ref | Time reference. |
Returns Good Time Intervals from the User parameters tmin
and tmax
, taking into account the transformation into the CTA reference time system. If one of tmin
or tmax
is not valid, an empty Good Time Interval object is returned. If tmin
is not valid, tmax
is not queried.
Definition at line 1415 of file ctool.cpp.
Referenced by create_cta_obs(), ctselect::get_parameters(), and ctselect::select_events().
|
protected |
Get Good Time Intervals extension name.
[in] | filename | Input file name. |
[in] | evtname | Events extension name. |
Extracts the Good Time Intervals extension name from the event file. We do this by loading the events and accessing the Good Time Intervals extension name using the GCTAEventList::gtiname() method. If the file name is empty, the method returns GTI
.
Definition at line 2352 of file ctool.cpp.
Referenced by ctselect::process(), and ctobservation::save_events_xml().
|
protected |
Derives mean pointing from CTA observations.
[in] | obs | Observation container. |
Computes the mean pointing direction from all CTA observations in the observation container.
Definition at line 1979 of file ctool.cpp.
References G_GET_MEAN_POINTING.
Referenced by create_map().
|
protected |
Return observation header string.
[in] | obs | Pointer to observation. |
Returns a string that contains observation information, including the instrument name, the observation name, and the observation ID. The format of the string is
XXX observation "name" (id=YYYYY)
Definition at line 2090 of file ctool.cpp.
Referenced by ctfindvar::fill_cube(), ctmodel::fill_cube(), ctbin::fill_cube(), ctskymap::fill_maps_acceptance(), ctskymap::fill_maps_counts(), ctfindvar::get_alphas(), ctobservation::next_unbinned_observation(), ctselect::process(), ctcubemask::process(), ctobssim::process(), and ctmodel::process().
|
protected |
Get observation container.
[in] | get_response | Indicates whether response information should be loaded (default: true) |
Get an observation container according to the user parameters. The method supports loading of a individual FITS file or an observation definition file in XML format. If the input filename is empty, parameters are read to build a CTA observation from scratch.
Definition at line 1885 of file ctool.cpp.
References create_cta_obs(), m_use_xml, set_obs_response(), and set_response().
Referenced by ctobssim::get_parameters().
|
protected |
Return CTA pointing from User parameters.
Returns CTA pointing from the User parameters ra
and dec
.
Definition at line 1445 of file ctool.cpp.
References get_skydir().
Referenced by create_cta_obs().
|
protected |
Return RoI from User parameters.
[in] | pnt | Pointing direction. |
Returns Region of Interest (RoI) from the User parameters ra
, dec
and rad
. If any of the parameters ra
, dec
or rad
is not valid an invalid RoI is returned.
If the usepnt
parameter exists and is set to yes
, the RoI centre will be taken from the specified pointing direction instead of the ra
and dec
parameters. Make sure to provide a valid pointing direction in case that you want to use the usepnt
User parameter.
Definition at line 1325 of file ctool.cpp.
References get_skydir().
Referenced by ctcubemask::apply_mask(), create_cta_obs(), ctselect::get_parameters(), ctcubemask::get_parameters(), and ctselect::select_events().
|
protected |
Return sky direction from User parameters.
Returns sky direction from the User parameters ra
and dec
.
Definition at line 1465 of file ctool.cpp.
Referenced by get_pointing(), and get_roi().
|
protected |
Initialise class members.
Definition at line 321 of file ctool.cpp.
References m_read_ahead, and m_use_xml.
Referenced by cterror::clear(), ctlike::clear(), ctool_base::clear(), ctmapcube::clear(), ctool_like::clear(), ctool_obs::clear(), ctedispcube::clear(), ctbkgcube::clear(), ctexpcube::clear(), ctpsfcube::clear(), ctskymap::clear(), ctselect::clear(), ctfindvar::clear(), ctprob::clear(), ctcubemask::clear(), ctphase::clear(), ctulimit::clear(), ctobssim::clear(), ctmodel::clear(), cttsmap::clear(), ctbutterfly::clear(), ctbin::clear(), ctool(), and operator=().
|
protected |
Insert observation energy boundaries into list of energies.
[in] | energies | Energies. |
[in] | obs | Observation container. |
Inserts the energy boundaries of an observation in a list of energies
.
Definition at line 2119 of file ctool.cpp.
Referenced by ctedispcube::init_cube(), ctpsfcube::init_cube(), and ctexpcube::init_cube().
|
protected |
Query user parameters for On/Off analysis.
Queries the parameter "method", and if this is "ONOFF" signal that an On/ Off analysis is requested. In that case, all necessary input parameters of csphagen are queried: "inexclusion", "emin", "emax", "enumbins", "coordsys", "xref", "yref", "srcshape", "rad", "bkgmethod", "bkgregmin", "maxoffset", "etruemin", "etruemax", and "etruebins".
Using this method assures that the parameters are always queried in the same order.
|
protected |
Query user parameters for stacked analysis.
Queries the user parameters emin
, emax
and enumbins
, and if enumbins
is positive, signal that a stacked analysis is requested. In that case, also the coordsys
, proj
, xref
, yref
, nxpix
, nypix
and binsz
parameters are queried.
Using this method assures that the parameters are always queried in the same order.
|
protected |
Log model container.
[in] | chatter | Minimum required chattiness |
[in] | models | Model container |
[in] | what | String specifying the container content |
Log models if chattiness is at least chatter
.
Definition at line 1285 of file ctool.cpp.
Referenced by ctmapcube::process(), ctbkgcube::process(), and ctmodel::process().
|
protected |
Log observation container.
[in] | chatter | Minimum required chattiness |
[in] | obs | Observation container |
[in] | what | String specifying the container content |
Log observations if chattiness is at least chatter
.
Definition at line 1251 of file ctool.cpp.
Referenced by ctskymap::fill_maps(), cterror::process(), ctlike::process(), ctool_like::process(), ctool_obs::process(), ctedispcube::process(), ctbkgcube::process(), ctexpcube::process(), ctpsfcube::process(), ctfindvar::process(), ctprob::process(), ctselect::process(), ctcubemask::process(), ctphase::process(), ctulimit::process(), ctobssim::process(), ctmodel::process(), cttsmap::process(), ctbutterfly::process(), and ctbin::process().
|
protected |
Log application parameters.
[in] | chatter | Minimum required chattiness |
Log all application parameters. If the ctools has an edisp parameter and the edisp parameter is false then log a warning that energy dispersion is not used.
Definition at line 1208 of file ctool.cpp.
Referenced by cterror::get_parameters(), ctool_base::get_parameters(), ctool_like::get_parameters(), ctool_obs::get_parameters(), ctedispcube::get_parameters(), ctpsfcube::get_parameters(), ctlike::get_parameters(), ctmapcube::get_parameters(), ctfindvar::get_parameters(), ctexpcube::get_parameters(), ctselect::get_parameters(), ctprob::get_parameters(), ctcubemask::get_parameters(), ctbkgcube::get_parameters(), ctphase::get_parameters(), ctskymap::get_parameters(), ctulimit::get_parameters(), ctobssim::get_parameters(), ctbutterfly::get_parameters(), ctmodel::get_parameters(), cttsmap::get_parameters(), and ctbin::get_parameters().
Assignment operator.
[in] | app | Application. |
Assigns one ctool application to another.
Definition at line 221 of file ctool.cpp.
References copy_members(), free_members(), and init_members().
Referenced by ctool_base::operator=(), ctmapcube::operator=(), and ctobservation::operator=().
|
pure virtual |
Implemented in ctbin, ctbutterfly, cttsmap, ctmodel, ctobservation, ctobssim, ctulimit, ctlikelihood, ctphase, ctcubemask, ctfindvar, ctprob, ctselect, ctskymap, ctbkgcube, ctedispcube, ctexpcube, ctpsfcube, ctmapcube, ctool_like, ctool_obs, cterror, ctlike, and ctool_base.
|
protected |
Dump help text in the console.
Dumps the help text for the ctool into the console. The help text is located in the folder
$CTOOLS//share/help/
of the ctools installation and the help file has the name "name().txt", where name() stands for the name of the ctool.
Definition at line 2467 of file ctool.cpp.
References G_PROVIDE_HELP.
Referenced by ctool().
|
inlineprotected |
Signal whether parameters should be read ahead.
Ahead reading of parameter is useful in case that some parameters are only required in a late stage of the processing. By reading them ahead it is assured that these parameters will be queried at the beginning of the tool execution.
Definition at line 177 of file ctool.hpp.
References m_read_ahead.
Referenced by cterror::get_parameters(), ctpsfcube::get_parameters(), ctedispcube::get_parameters(), ctfindvar::get_parameters(), ctlike::get_parameters(), ctmapcube::get_parameters(), ctexpcube::get_parameters(), ctselect::get_parameters(), ctprob::get_parameters(), ctbkgcube::get_parameters(), ctcubemask::get_parameters(), ctphase::get_parameters(), ctskymap::get_parameters(), ctobssim::get_parameters(), ctbutterfly::get_parameters(), ctmodel::get_parameters(), cttsmap::get_parameters(), ctbin::get_parameters(), and ctobssim::process().
|
protected |
Throws exception if inobs parameter is not valid.
[in] | method | Method name. |
Throw an exception if the "inobs" parameter is either "NONE" or an empty string.
|
protected |
Throws exception if inobs parameter is a counts cube.
[in] | method | Method name. |
Throw an exception if the inobs parameter is a counts cube.
Definition at line 1149 of file ctool.cpp.
Referenced by ctobssim::get_parameters().
|
protected |
|
protected |
Restore energy dispersion flags of CTA observations.
[in] | obs | Observation container. |
[in] | edisp | Vector of energy dispersion flags. |
Restores energy dispersion flags that have previously been returned by the set_edisp() method. The number of observations between the calls of the set_edisp() and this method has to be the same.
Definition at line 1689 of file ctool.cpp.
References G_RESTORE_EDISP.
Referenced by cterror::process(), ctlike::process(), ctprob::process(), ctobssim::process(), ctulimit::process(), ctmodel::process(), and cttsmap::process().
|
virtual |
Run ctool.
This method runs a ctool by calling the process() method of a ctool. The method switches on screen dump in case that the debug parameter is true.
Definition at line 257 of file ctool.cpp.
References process().
Referenced by cscripts.obsutils::create_counts_cube().
|
pure virtual |
Implemented in ctbin, ctbutterfly, cttsmap, ctmodel, ctobservation, ctobssim, ctulimit, ctlikelihood, ctphase, ctcubemask, ctfindvar, ctprob, ctselect, ctskymap, ctbkgcube, ctedispcube, ctexpcube, ctpsfcube, ctmapcube, ctool_like, ctool_obs, cterror, ctlike, and ctool_base.
Referenced by execute().
|
protected |
Save event list into FITS file.
[in] | obs | Pointer to CTA observation. |
[in] | infile | Input file name. |
[in] | evtname | Event extension name. |
[in] | gtiname | GTI extension name. |
[in] | outfile | Output file name. |
Saves an event list and the corresponding Good Time Intervals into a FITS file and copy all others extensions from the input file to the output file.
If an extension name is specified in the outfile
argument, the events and eventually also the Good Time Intervals will be extracted from the argument and used for writing the events. The format is
<filename>[<event extension name;GTI extension name>]
where <filename> needs to be replaced by the name of the FITS file, and <event extension name;GTI extension name> by the name of the events and Good Time Intervals extensions. For example
myfits.fits[EVENTS1;GTI1]
will write the selected events into the EVENTS1
extension and the Good Time Intervals into the GTI1
extension of the myfits.fits
FITS file. If the Good Time Intervals extension name is skipped, e.g.
myfits.fits[EVENTS1]
the original extension name for the Good Time Intervals will be kept. Analogously, only the Good Time Intervals extension name can be changed by specifying
myfits.fits[;GTI1]
In none of the cases will the original events and Good Time Intervals be copied over to the output file.
Definition at line 2266 of file ctool.cpp.
Referenced by ctobservation::save_events_fits(), ctobservation::save_events_xml(), ctselect::save_fits(), and ctselect::save_xml().
|
protected |
Set energy dispersion to CTA observations.
[in] | obs | Observation container. |
[in] | edisp | Requested energy dispersion flag. |
Applies energy dispersion to all CTA observations. The method returns a vector with the old energy dispersion flags.
Definition at line 1649 of file ctool.cpp.
Referenced by cterror::process(), ctlike::process(), ctprob::process(), ctobssim::process(), ctulimit::process(), ctmodel::process(), and cttsmap::process().
|
protected |
Set response for CTA observation.
[in,out] | obs | CTA observation |
GException::invalid_value | Energy dispersion requested but not energy dispersion cube given |
Set the response for one CTA observation. If the CTA observation contains a counts cube the method first attempts to set the response information using the following user parameters
expcube: Exposure cube file psfcube: Point spread function cube file edispcube: Energy dispersion cube file (optional) bkgcube: Background cube file
If none of the expcube
, psfcube
and bkgcube
parameters is "NONE" or empty, the method will allocate a stacked response for the observation. In case that an energy dispersion cube is provided using the edispcube
parameter, this energy dispersion cube is also loaded and attached to the stacked response function.
In case that any of the expcube
, psfcube
and bkgcube
parameters is "NONE" or empty, the method will assume that a IRF response should be used, and will attempty to set the response information using the following user parameters
caldb: Calibration database irf: Instrument response function
Definition at line 1752 of file ctool.cpp.
References G_SET_OBS_RESPONSE.
Referenced by ctmodel::get_obs(), get_observations(), and set_response().
|
protected |
Set output file name.
[in] | filename | Input file name. |
Converts an input file name into an output filename by prepending the prefix specified by the prefix
parameter to the input file name. Any path as well as extension will be stripped from the input file name. Also a trailing .gz
will be stripped as one cannot write into gzipped files.
Definition at line 1491 of file ctool.cpp.
Referenced by ctobservation::save_events_xml(), and ctselect::save_xml().
|
protected |
Set response for all CTA observations in container.
[in,out] | obs | Observation container |
Set the response for all CTA observations in the container that so far have no response information available. See the set_obs_response() method for more information about the user parameters that are read.
Definition at line 1614 of file ctool.cpp.
References set_obs_response().
Referenced by ctmodel::get_obs(), get_observations(), ctskymap::get_parameters(), and setup_observations().
|
protected |
Setup model container.
[in] | obs | Observation container |
[in] | name | Mandatory model name |
GException::invalid_value | Model definiton XML filename not valid or mandatory model name not found in model container. |
Setup a model container by loading the models from the "inmodel" parameter.
If the model container in the observation container obs
is empty, the method will extract the model container filename from the "inmodel" parameter, load the model container and assign it to the observations container. If the filename is either empty or "NONE" the method will throw an exception.
If a mandatory model name is specified, the method will further check whether a model with the name exists in the model container. If it does not exist, an exception is thrown.
Definition at line 545 of file ctool.cpp.
References G_SETUP_MODELS.
Referenced by cterror::get_parameters(), ctbkgcube::get_parameters(), ctulimit::get_parameters(), ctbutterfly::get_parameters(), and cttsmap::get_parameters().
|
protected |
Setup observation container.
[in] | obs | Observation container |
[in] | response | Require response |
[in] | list | Accept event list as "inobs" parameter |
[in] | cube | Accept counts cube as "inobs" parameter |
GException::invalid_value | Invalid "inobs" parameter encountered. |
Setup an observation container by extracting all required missing information from user parameters.
If the observation container obs
is empty, the method will extract the filename from the "inobs" parameter and load the observation container from the specified file. If the filename is either empty or "NONE" the method will throw an exception.
If the "inobs" file is a FITS file, and depending on the information that is found in the FITS file, the method will append a single CTA observation to the observation container, containing either an event list or a counts cube. It will set the m_use_xml member to false to signal that no observation XML file should be used for saving. The list
and cube
parameters can be used to specify whether the method actually should accept event lists or counts cube. If it shouldn't the method will throw an exception.
If the "inobs" file is not a FITS file, the method assumes that an observation definition XML file has been specified, and will load that file into the observation container. It will set the m_use_xml member to true to signal that an observation XML file should be used for saving. No checking on event list or counts cubes will be done on the observation container.
By default, the method will also setup the response for all CTA observations in the container. In case that no response information is required, the response
argument should be set to false
. See the set_response() method for details.
Definition at line 431 of file ctool.cpp.
References G_SETUP_OBSERVATION, m_use_xml, and set_response().
Referenced by cterror::get_parameters(), ctedispcube::get_parameters(), ctpsfcube::get_parameters(), ctfindvar::get_parameters(), ctlike::get_parameters(), ctexpcube::get_parameters(), ctprob::get_parameters(), ctselect::get_parameters(), ctbkgcube::get_parameters(), ctcubemask::get_parameters(), ctphase::get_parameters(), ctskymap::get_parameters(), ctulimit::get_parameters(), ctobssim::get_parameters(), ctbutterfly::get_parameters(), ctmodel::get_parameters(), cttsmap::get_parameters(), and ctbin::get_parameters().
|
protected |
|
protected |
Set warning string if there are too few energies.
[in] | energies | Energies. |
Sets a warning string if there are too few energies
in the container. For a binned or stacked analysis to be accurate, at least 25 bins per decade are required. If the provided number of energies is less than this number a warning string will be returned. Otherwise an empty string will be returned.
Definition at line 2386 of file ctool.cpp.
Referenced by ctexpcube::process().
|
protected |
Set warning string if file has no .xml suffix.
[in] | filename | Filename. |
Sets a warning string if the filename has not ".xml" suffix.
Definition at line 2427 of file ctool.cpp.
Referenced by ctbin::save(), ctobservation::save_events_xml(), ctcubemask::save_xml(), ctselect::save_xml(), and ctobssim::save_xml().
|
protected |
Read ahead output parameters.
Definition at line 155 of file ctool.hpp.
Referenced by copy_members(), execute(), init_members(), and read_ahead().
|
protected |
Use XML file instead of FITS file for observations.
Definition at line 162 of file ctool.hpp.
Referenced by copy_members(), ctmodel::get_obs(), get_observations(), init_members(), ctobssim::outfile(), ctprob::process(), ctselect::process(), ctcubemask::process(), ctphase::process(), ctobssim::process(), ctselect::publish(), ctprob::publish(), ctphase::publish(), ctobssim::publish(), ctprob::save(), ctselect::save(), ctcubemask::save(), ctphase::save(), ctobssim::save(), and setup_observations().