ctools 2.1.0.dev
|
Data selection tool. More...
#include <ctselect.hpp>
Public Member Functions | |
ctselect (void) | |
Void constructor. | |
ctselect (const GObservations &obs) | |
Observations constructor. | |
ctselect (int argc, char *argv[]) | |
Command line constructor. | |
ctselect (const ctselect &app) | |
Copy constructor. | |
virtual | ~ctselect (void) |
Destructor. | |
ctselect & | operator= (const ctselect &app) |
Assignment operator. | |
void | clear (void) |
Clear ctselect tool. | |
void | process (void) |
Select event data. | |
void | save (void) |
Save the selected event list(s) | |
void | publish (const std::string &name="") |
Publish event lists. | |
Public Member Functions inherited from ctobservation | |
ctobservation (const std::string &name, const std::string &version) | |
Name constructor. | |
ctobservation (const std::string &name, const std::string &version, const GApplicationPars &pars) | |
Application parameters constructor. | |
ctobservation (const std::string &name, const std::string &version, int argc, char *argv[]) | |
Command line constructor. | |
ctobservation (const std::string &name, const std::string &version, const GObservations &obs) | |
Observations constructor. | |
ctobservation (const ctobservation &app) | |
Copy constructor. | |
virtual | ~ctobservation (void) |
Destructor. | |
ctobservation & | operator= (const ctobservation &app) |
Assignment operator. | |
void | obs (const GObservations &obs) |
Set observation container. | |
const GObservations & | obs (void) const |
Return observation container. | |
Public Member Functions inherited from ctool | |
ctool (const std::string &name, const std::string &version) | |
Name constructor. | |
ctool (const std::string &name, const std::string &version, const GApplicationPars &pars) | |
Application parameter constructor. | |
ctool (const std::string &name, const std::string &version, int argc, char *argv[]) | |
Command line constructor. | |
ctool (const ctool &app) | |
Copy constructor. | |
virtual | ~ctool (void) |
Destructor. | |
ctool & | operator= (const ctool &app) |
Assignment operator. | |
virtual void | run (void) |
Run ctool. | |
virtual void | execute (void) |
Execute ctool. | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const ctselect &app) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
void | get_parameters (void) |
Get application parameters. | |
void | select_events (GCTAObservation *obs, const std::string &filename, const std::string &evtname, const std::string >iname) |
Select events. | |
GEbounds | set_ebounds (GCTAObservation *obs, const GEbounds &ebounds) const |
Return energy boundaries for a given observation. | |
std::string | check_infile (const std::string &filename, const std::string &evtname) const |
Check input filename. | |
void | save_fits (void) |
Save event list in FITS format. | |
void | save_xml (void) |
Save event list(s) in XML format. | |
Protected Member Functions inherited from ctobservation | |
GCTAObservation * | first_unbinned_observation (void) |
Return first unbinned CTA observation. | |
GCTAObservation * | next_unbinned_observation (void) |
Return next unbinned CTA observation. | |
const GCTAObservation * | first_unbinned_observation (void) const |
Return first unbinned CTA observation (const version) | |
const GCTAObservation * | next_unbinned_observation (void) const |
Return next unbinned CTA observation (const version) | |
void | read_ogip_keywords (GFitsHDU *hdu) const |
Read OGIP keywords from FITS HDU. | |
void | write_ogip_keywords (GFitsHDU *hdu) const |
Write OGIP keywords in FITS HDU. | |
void | set_obs_statistic (const std::string &statistic) |
Set fit statistic for CTA observations. | |
void | set_obs_bounds () |
Set observation boundaries for CTA observations. | |
void | save_events_fits (void) |
Save event list in FITS format. | |
void | save_events_xml (void) |
Save event list(s) in XML format. | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const ctobservation &app) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
Protected Member Functions inherited from ctool | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const ctool &app) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
void | sync_pfiles (void) |
Synchronise parameter files. | |
const bool & | read_ahead (void) const |
Signal whether parameters should be read ahead. | |
void | setup_observations (GObservations &obs, const bool &response=true, const bool &list=true, const bool &cube=true) |
Setup observation container. | |
void | setup_models (GObservations &obs, const std::string &name="") |
Setup model container. | |
GEbounds | create_ebounds (void) |
Create energy boundaries from user parameters. | |
GEnergies | create_energies (void) |
Create energies from user parameters. | |
GSkyMap | create_map (const GObservations &obs) |
Create a skymap from user parameters. | |
GCTAEventCube | create_cube (const GObservations &obs) |
Create a CTA event cube from user parameters. | |
GCTAObservation | create_cta_obs (void) |
Create a CTA observation from User parameters. | |
void | require_inobs (const std::string &method) |
Throws exception if inobs parameter is not valid. | |
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. | |
GCTARoi | get_roi (const GCTAPointing &pnt=GCTAPointing()) |
Return RoI from User parameters. | |
GEbounds | get_ebounds (void) |
Return energy boundaries from User parameters. | |
GGti | get_gti (const GTimeReference &ref) |
Return Good Time Intervals from User parameter. | |
GCTAPointing | get_pointing (void) |
Return CTA pointing from User parameters. | |
GSkyDir | get_skydir (void) |
Return sky direction from User parameters. | |
std::string | set_outfile_name (const std::string &filename) |
Set output file name. | |
bool | is_stacked (void) |
Query user parameters for stacked analysis. | |
bool | is_onoff (void) |
Query user parameters for On/Off analysis. | |
void | log_parameters (const GChatter &chatter) |
Log application parameters. | |
void | log_observations (const GChatter &chatter, const GObservations &obs, const std::string &what="Observation") |
Log observation container. | |
void | log_models (const GChatter &chatter, const GModels &models, const std::string &what="Model") |
Log model container. | |
void | set_response (GObservations &obs) |
Set response for all CTA observations in container. | |
std::vector< bool > | set_edisp (GObservations &obs, const bool &edisp) const |
Set energy dispersion to CTA observations. | |
void | restore_edisp (GObservations &obs, const std::vector< bool > &edisp) const |
Restore energy dispersion flags of CTA observations. | |
void | set_obs_response (GCTAObservation *obs) |
Set response for CTA observation. | |
GObservations | get_observations (const bool &get_response=true) |
Get observation container. | |
GSkyDir | get_mean_pointing (const GObservations &obs) |
Derives mean pointing from CTA observations. | |
size_t | get_current_rss (void) |
Get current resident set size (physical memory use) in Bytes. | |
std::string | get_obs_header (const GObservation *obs) const |
Return observation header string. | |
GEnergies | insert_energy_boundaries (const GEnergies &energies, const GCTAObservation &obs) |
Insert observation energy boundaries into list of energies. | |
std::vector< bool > | cube_layer_usage (const GEbounds &cube_ebounds, const GEbounds &list_ebounds) const |
Determine the counts cube layer usage. | |
std::string | get_gtiname (const std::string &filename, const std::string &evtname) const |
Get Good Time Intervals extension name. | |
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. | |
std::string | warn_too_few_energies (const GEnergies &energies) const |
Set warning string if there are too few energies. | |
std::string | warn_xml_suffix (const GFilename &filename) const |
Set warning string if file has no .xml suffix. | |
void | provide_help (void) const |
Dump help text in the console. | |
Protected Attributes | |
std::string | m_outobs |
Output event list or XML file. | |
double | m_emin |
Lower energy. | |
double | m_emax |
Upper energy. | |
std::string | m_expr |
Selection expression. | |
std::string | m_usethres |
Energy threshold type. | |
GChatter | m_chatter |
Chattiness. | |
bool | m_forcesel |
Enforce RoI selection. | |
std::vector< std::string > | m_infiles |
Input event filenames. | |
std::vector< std::string > | m_evtname |
Event extension names. | |
std::vector< std::string > | m_gtiname |
GTI extension names. | |
GPhases | m_phases |
Phase intervals. | |
bool | m_select_energy |
Perform energy selection. | |
bool | m_select_phase |
Perform phase selection. | |
Protected Attributes inherited from ctobservation | |
GObservations | m_obs |
Observation container. | |
Protected Attributes inherited from ctool | |
bool | m_read_ahead |
Read ahead output parameters. | |
bool | m_use_xml |
Use XML file instead of FITS file for observations. | |
Data selection tool.
Definition at line 46 of file ctselect.hpp.
ctselect::ctselect | ( | void | ) |
|
explicit |
Observations constructor.
param[in] obs Observation container.
Creates an instance of the class that is initialised using the information provided in an observation container.
Definition at line 74 of file ctselect.cpp.
References init_members().
ctselect::ctselect | ( | 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 93 of file ctselect.cpp.
References init_members().
ctselect::ctselect | ( | const ctselect & | app | ) |
Copy constructor.
[in] | app | Application. |
Definition at line 109 of file ctselect.cpp.
References copy_members(), and init_members().
|
virtual |
|
protected |
Check input filename.
[in] | filename | File name. |
[in] | evtname | Event extension name. |
This method checks if the input FITS file is correct.
Definition at line 1234 of file ctselect.cpp.
Referenced by process().
|
virtual |
Clear ctselect tool.
Clears ctselect tool.
Implements ctobservation.
Definition at line 182 of file ctselect.cpp.
References ctobservation::free_members(), ctool::free_members(), free_members(), ctobservation::init_members(), ctool::init_members(), and init_members().
|
protected |
Copy class members.
[in] | app | Application. |
Definition at line 476 of file ctselect.cpp.
References m_chatter, m_emax, m_emin, m_evtname, m_expr, m_forcesel, m_gtiname, m_infiles, m_outobs, m_phases, m_select_energy, m_select_phase, and m_usethres.
Referenced by ctselect(), and operator=().
|
protected |
Delete class members.
Definition at line 503 of file ctselect.cpp.
Referenced by clear(), operator=(), and ~ctselect().
|
protected |
Get application parameters.
Get all user parameters from parameter file or (if required) by querying the user. Times are assumed to be in the native CTA MJD format.
This method also loads observations if no observations are yet allocated. Observations are either loaded from a single CTA even list, or from a XML file using the metadata information that is stored in that file.
Definition at line 520 of file ctselect.cpp.
References G_GET_PARAMETERS, ctool::get_gti(), ctool::get_roi(), ctool::log_parameters(), m_chatter, m_emax, m_emin, m_expr, m_forcesel, ctobservation::m_obs, m_phases, m_select_energy, m_select_phase, m_usethres, ctool::read_ahead(), and ctool::setup_observations().
Referenced by process().
|
protected |
Initialise class members.
Definition at line 447 of file ctselect.cpp.
References m_chatter, m_emax, m_emin, m_evtname, m_expr, m_forcesel, m_gtiname, m_infiles, m_outobs, m_phases, m_select_energy, m_select_phase, and m_usethres.
Referenced by clear(), ctselect(), ctselect(), ctselect(), ctselect(), and operator=().
Assignment operator.
[in] | app | Application. |
Definition at line 147 of file ctselect.cpp.
References copy_members(), free_members(), init_members(), and ctobservation::operator=().
|
virtual |
Select event data.
This method reads in the application parameters and loops over all observations that were found to perform an event selection. Event selection is done by writing each observation to a temporary file and re-opening the temporary file using the cfitsio event filter syntax. The temporary file is deleted after this action so that no disk overflow will occur.
Implements ctobservation.
Definition at line 215 of file ctselect.cpp.
References check_infile(), G_PROCESS, ctool::get_gtiname(), ctool::get_obs_header(), get_parameters(), ctool::log_observations(), m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, ctool::m_use_xml, ctobservation::obs(), publish(), and select_events().
void ctselect::publish | ( | const std::string & | name = "" | ) |
Publish event lists.
[in] | name | Event list name. |
Definition at line 389 of file ctselect.cpp.
References CTSELECT_NAME, ctobservation::m_obs, ctool::m_use_xml, and ctobservation::obs().
Referenced by cscripts.cslightcrv.cslightcrv::process(), cscripts.csphasecrv.csphasecrv::process(), cscripts.csresmap.csresmap::process(), cscripts.csspec.csspec::process(), cscripts.csviscube.csviscube::process(), and process().
|
virtual |
Save the selected event list(s)
This method saves the selected event list(s) into FITS file(s). There are two modes, depending on the m_use_xml flag.
If m_use_xml is true, all selected event list(s) will be saved into FITS files, where the output filenames are constructued from the input filenames by prepending the prefix string to name. Any path information will be stripped form the input name, hence event files will be written into the local working directory (unless some path information is present in the prefix). In addition, an XML file will be created that gathers the filename information for the selected event list(s). If an XML file was present on input, all metadata information will be copied from this input file.
If m_use_xml is false, the selected event list will be saved into a FITS file.
Implements ctobservation.
Definition at line 364 of file ctselect.cpp.
References ctobservation::m_obs, ctool::m_use_xml, save_fits(), and save_xml().
|
protected |
Save event list in FITS format.
Save the event list as a FITS file. The file name of the FITS file is specified by the "outobs" parameter.
Definition at line 1304 of file ctselect.cpp.
References m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, m_outobs, ctobservation::obs(), and ctool::save_event_list().
Referenced by save().
|
protected |
Save event list(s) in XML format.
Save the event list(s) into FITS files and write the file path information into a XML file. The filename of the XML file is specified by the outfile parameter, the filename(s) of the event lists are built by prepending a prefix to the input event list filenames. Any path present in the input filename will be stripped, i.e. the event list(s) will be written in the local working directory (unless a path is specified in the prefix).
Definition at line 1364 of file ctselect.cpp.
References m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, m_outobs, ctobservation::obs(), ctool::save_event_list(), ctool::set_outfile_name(), and ctool::warn_xml_suffix().
Referenced by save().
|
protected |
Select events.
[in,out] | obs | CTA observation. |
[in] | filename | File name. |
[in] | evtname | Event extension name. |
[in] | gtiname | GTI extension name. |
GException::invalid_value | No events extension found in FITS file. |
Select events from a FITS file by making use of the selection possibility of the cfitsio library on loading a file. A selection string is created from the specified criteria that is appended to the filename so that cfitsio will automatically filter the event data. This selection string is then applied when opening the FITS file. The event list in the current observation is replaced by selected event list read from the FITS file.
Good Time Intervals of the observation will be limited to the time interval specified by the User parameters tmin and tmax.
Definition at line 673 of file ctselect.cpp.
References G_PROCESS, G_SELECT_EVENTS, ctool::get_gti(), ctool::get_roi(), m_chatter, m_expr, m_forcesel, m_phases, m_select_energy, m_select_phase, ctobservation::obs(), and set_ebounds().
Referenced by process().
|
protected |
Return energy boundaries for a given observation.
[in] | obs | Pointer to CTA observation. |
[in] | ebounds | Current energy boundaries. |
Returns the energy boundaries for a given observation. Depending on the value of the usethres parameter, the following values will be returned:
NONE: [max(emin,emin_exist),min(emax,emax_exist)] DEFAULT: [max(emin,emin_exist,emin_safe),min(emax,emax_exist,emax_safe)] USER: [max(emin,emin_exist,emin_user),min(emax,emax_exist,emax_user)]
where
emin is the value of the emin parameter emax is the value of the emax parameter emin_exist is the value of any existing minimum boundary emax_exist is the value of any existing maximum boundary emin_safe is the lower safe threshold emax_safe is the upper safe threshold emin_user is the lower user threshold emax_user is the upper user threshold
Any threshold value of 0 will be ignored.
Definition at line 1120 of file ctselect.cpp.
References G_SET_EBOUNDS, m_emax, m_emin, m_usethres, and ctobservation::obs().
Referenced by select_events().
|
protected |
Chattiness.
Definition at line 88 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
Upper energy.
Definition at line 85 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and set_ebounds().
|
protected |
Lower energy.
Definition at line 84 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and set_ebounds().
|
protected |
Event extension names.
Definition at line 93 of file ctselect.hpp.
Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().
|
protected |
Selection expression.
Definition at line 86 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
Enforce RoI selection.
Definition at line 89 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
GTI extension names.
Definition at line 94 of file ctselect.hpp.
Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().
|
protected |
Input event filenames.
Definition at line 92 of file ctselect.hpp.
Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().
|
protected |
Output event list or XML file.
Definition at line 83 of file ctselect.hpp.
Referenced by copy_members(), init_members(), save_fits(), and save_xml().
|
protected |
Phase intervals.
Definition at line 95 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
Perform energy selection.
Definition at line 96 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
Perform phase selection.
Definition at line 97 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and select_events().
|
protected |
Energy threshold type.
Definition at line 87 of file ctselect.hpp.
Referenced by copy_members(), get_parameters(), init_members(), and set_ebounds().