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) {
404 if (tstart > tstop) {
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) {
522 if (tstop > gti.
m_stop[k]) {
525 if (tstop > tstart) {
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) {
1033 if (
m_stop[i] > tstart) {
1035 overlap += tstop -
tstart;
1042 else if (
m_stop[i] > tstop) {
1044 overlap += tstop -
m_start[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) {
1307 if (tstart > tstop) {
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) {
virtual ~GGti(void)
Destructor.
bool contains(const GTime &time) const
Checks whether Good Time Intervals contains time.
FITS table double column class interface definition.
double m_ontime
Sum of GTIs durations (in seconds)
GFitsTable * table(const int &extno)
Get pointer to table HDU.
int m_last_index
Last index for containment test.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GTimeReference reference(void) const
Returns native time reference.
void insert(const GTime &tstart, const GTime &tstop)
Insert Good Time Interval.
const GTimeReference & reference(void) const
Return time reference for Good Time Intervals.
XML element node class interface definition.
GFilename m_xml_filename
XML filename.
void write(GFitsHDU &hdu) const
Write time reference into FITS header.
void read(const GFitsHDU &hdu)
Read time reference from FITS header.
bool is_empty(void) const
Signal if filename is empty.
void clear(void)
Clear time.
std::string extname(const std::string &defaultname="") const
Return extension name.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
void free_members(void)
Delete class members.
GTimeReference m_reference
Time reference.
const std::string extname_gti
FITS file class interface definition.
void insert_gti(const int &index, const GTime &tstart, const GTime &tstop)
Insert Good Time Interval.
std::string print(const GChatter &chatter=NORMAL) const
Print Good Time Intervals.
GGti * clone(void) const
Clone Good Time Intervals.
void init_members(void)
Initialise class members.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
Good time interval class interface definition.
GGti(void)
Void constructor.
int size(void) const
Return number of Good Time Intervals.
double m_telapse
Time between start of first GTI and stop of last GTI (in seconds)
GGti & operator=(const GGti >i)
Assignment operator.
void save(const GFilename &filename, const bool &clobber=false) const
Save Good Time Intervals into FITS file.
void clear(void)
Clear Good Time Intervals.
int m_num
Number of Good Time Intervals.
void remove(const int &extno)
Remove HDU from FITS file.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
void load(const GFilename &filename)
Load Good Time Intervals from FITS file.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Abstract interface for FITS table.
int integer(const std::string &keyname) const
Return card value as integer.
void remove(const int &index)
Remove Good Time Interval.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Good Time Interval class.
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
const std::string & extname(void) const
Return extension name.
void set_attributes(void)
Set class attributes.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
GTime m_tstart
Start time of Good Time Intervals.
const double & secs(void) const
Return time in seconds in native reference (TT)
void copy_members(const GGti >i)
Copy class members.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
double overlap(const GTime &tstart, const GTime &tstop) const
Computes overlap of time interval with GTIs.
GTime m_tstop
Stop time of Good Time Intervals.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
Implements a time reference.
FITS binary table class definition.
GTime * m_stop
Array of stop times.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const double & telapse(void) const
Returns elapsed time.
bool is_empty(void) const
Signal if there are no Good Time Intervals.
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
GTime * m_start
Array of start times.
void close(void)
Close FITS file.
void set(const double &time, const GTimeReference &ref)
Set time given in specified reference.
void extend(const GGti >i)
Append Good Time Intervals.
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.
const double & ontime(void) const
Returns ontime.
double convert(const GTimeReference &ref) const
Return time in specified reference.
FITS table double column.
void reduce(const GTime &tstart, const GTime &tstop)
Reduce Good Time Intervals to specified interval.
Filename class interface definition.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.
void merge(void)
Merge all overlapping Good Time Intervals.