42#define G_REDUCE "GGti::reduce(GTime&, GTime&)"
43#define G_REMOVE "GGti::remove(int&)"
44#define G_READ_XML "GGti::read(GXmlElement&)"
45#define G_WRITE_XML "GGti::write(GXmlElement&)"
46#define G_TSTART "GGti::tstart(int&)"
47#define G_TSTOP "GGti::tstop(int&)"
48#define G_INSERT_GTI "GGti::insert_gti(int&, GTime&, GTime&)"
257 return new GGti(*
this);
293 for (; inx <
m_num; ++inx) {
329 for (
int k = i+2; k < num; ++k) {
369 for (
int i = 0; i <
m_num; ++i) {
405 std::string msg =
"Invalid time interval specified. Start time "+
415 for (
int i = 0; i <
m_num; ++i) {
436 for (
int i = 0; i <
m_num; ++i) {
490 std::vector<GTime> tstart_reduced;
491 std::vector<GTime> tstop_reduced;
492 tstart_reduced.reserve(
size);
493 tstop_reduced.reserve(
size);
496 for (
int i = 0; i <
m_num; ++i) {
500 for (
int k = 0; k < gti.
size(); ++k) {
526 tstart_reduced.push_back(
tstart);
527 tstop_reduced.push_back(
tstop);
537 int num = tstart_reduced.size();
545 for (
int i = 0; i < num; ++i) {
546 start[i] = tstart_reduced[i];
547 stop[i] = tstop_reduced[i];
589 #if defined(G_RANGE_CHECK)
591 if (index < 0 || index >=
m_num) {
598 for (
int i = index+1; i <
m_num; ++i) {
638 for (; inx <
m_num; ++inx) {
644 for (
int i = 0; i < gti.
size(); ++i, ++inx) {
686 GFits fits(filename);
768 for (
int i = 0; i <
m_num; ++i) {
803 for (
int i = 0; i <
m_num; ++i) {
865 std::string filename = par->
attribute(
"file");
893 std::string msg =
"Attributes \"file\" or \"tmin\" and \"tmax\" not "
894 "found in XML parameter \"GoodTimeIntervals\". "
895 "Please verify the observation definition XML "
979 #if defined(G_RANGE_CHECK)
981 if (index < 0 || index >=
m_num) {
1003 #if defined(G_RANGE_CHECK)
1005 if (index < 0 || index >=
m_num) {
1031 for (
int i = 0; i <
m_num; ++i) {
1115 result.append(
"=== GGti ===");
1126 result.append(
" - ");
1128 result.append(
" "+
reference().timeunit());
1129 result.append(
" ("+
reference().timesys()+
")");
1131 result.append(
tstart().utc());
1132 result.append(
" - ");
1133 result.append(
tstop().utc());
1134 result.append(
" "+
reference().timeunit());
1135 result.append(
" ("+
reference().timesys()+
")");
1212 for (
int i = 0; i <
m_num; ++i) {
1261 for (
int i = 1; i <
m_num; ++i) {
1276 for (
int i = 0; i <
m_num; ++i) {
1308 std::string msg =
"Invalid time interval specified. Start time "+
1318 if (inx < 0) inx = 0;
1327 for (
int i = 0; i < inx; ++i) {
1337 for (
int i = inx+1; i < num; ++i) {
Exception handler interface definition.
Filename class interface definition.
FITS binary table class definition.
FITS table double column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Good time interval class interface definition.
XML element node class interface definition.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
bool is_empty(void) const
Signal if filename is empty.
void clear(void)
Clear file name.
const std::string & extname(void) const
Return extension name.
int integer(const std::string &keyname) const
Return card value as integer.
FITS table double column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Good Time Interval class.
int m_last_index
Last index for containment test.
GGti * clone(void) const
Clone Good Time Intervals.
void set_attributes(void)
Set class attributes.
bool contains(const GTime &time) const
Checks whether Good Time Intervals contains time.
const GTimeReference & reference(void) const
Return time reference for Good Time Intervals.
void insert(const GTime &tstart, const GTime &tstop)
Insert Good Time Interval.
std::string print(const GChatter &chatter=NORMAL) const
Print Good Time Intervals.
const double & telapse(void) const
Returns elapsed time.
void remove(const int &index)
Remove Good Time Interval.
void load(const GFilename &filename)
Load Good Time Intervals from FITS file.
GGti & operator=(const GGti >i)
Assignment operator.
void copy_members(const GGti >i)
Copy class members.
GTime m_tstart
Start time of Good Time Intervals.
GTime * m_stop
Array of stop times.
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
GTime m_tstop
Stop time of Good Time Intervals.
GTime * m_start
Array of start times.
void init_members(void)
Initialise class members.
void insert_gti(const int &index, const GTime &tstart, const GTime &tstop)
Insert Good Time Interval.
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
GTimeReference m_reference
Time reference.
void save(const GFilename &filename, const bool &clobber=false) const
Save Good Time Intervals into FITS file.
void extend(const GGti >i)
Append Good Time Intervals.
double m_telapse
Time between start of first GTI and stop of last GTI (in seconds)
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
bool is_empty(void) const
Signal if there are no Good Time Intervals.
int size(void) const
Return number of Good Time Intervals.
GFilename m_xml_filename
XML filename.
int m_num
Number of Good Time Intervals.
virtual ~GGti(void)
Destructor.
void free_members(void)
Delete class members.
void reduce(const GTime &tstart, const GTime &tstop)
Reduce Good Time Intervals to specified interval.
const double & ontime(void) const
Returns ontime.
GGti(void)
Void constructor.
void merge(void)
Merge all overlapping Good Time Intervals.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
void clear(void)
Clear Good Time Intervals.
double m_ontime
Sum of GTIs durations (in seconds)
double overlap(const GTime &tstart, const GTime &tstop) const
Computes overlap of time interval with GTIs.
Implements a time reference.
void write(GFitsHDU &hdu) const
Write time reference into FITS header.
void read(const GFitsHDU &hdu)
Read time reference from FITS header.
void clear(void)
Clear time.
GTimeReference reference(void) const
Returns native time reference.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
double convert(const GTimeReference &ref) const
Return time in specified reference.
void set(const double &time, const GTimeReference &ref)
Set time given in specified reference.
const double & secs(void) const
Return time in seconds in native reference (TT)
const GXmlAttribute * attribute(const int &index) const
Return attribute.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double todouble(const std::string &arg)
Convert string into double precision value.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
const std::string extname_gti