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&)"
49#define G_INSERT_GTIS "GGti::insert_gtis(int&, GTimes&, GTimes&)"
258 return new GGti(*
this);
312 for (; inx <
m_num; ++inx) {
348 for (
int k = i+2; k < num; ++k) {
388 for (
int i = 0; i <
m_num; ++i) {
424 std::string msg =
"Invalid time interval specified. Start time "+
434 for (
int i = 0; i <
m_num; ++i) {
455 for (
int i = 0; i <
m_num; ++i) {
509 std::vector<GTime> tstart_reduced;
510 std::vector<GTime> tstop_reduced;
511 tstart_reduced.reserve(
size);
512 tstop_reduced.reserve(
size);
515 for (
int i = 0; i <
m_num; ++i) {
519 for (
int k = 0; k < gti.
size(); ++k) {
545 tstart_reduced.push_back(
tstart);
546 tstop_reduced.push_back(
tstop);
556 int num = tstart_reduced.size();
564 for (
int i = 0; i < num; ++i) {
565 start[i] = tstart_reduced[i];
566 stop[i] = tstop_reduced[i];
608 #if defined(G_RANGE_CHECK)
610 if (index < 0 || index >=
m_num) {
617 for (
int i = index+1; i <
m_num; ++i) {
657 for (; inx <
m_num; ++inx) {
663 for (
int i = 0; i < gti.
size(); ++i, ++inx) {
705 GFits fits(filename);
787 for (
int i = 0; i <
m_num; ++i) {
822 for (
int i = 0; i <
m_num; ++i) {
884 std::string filename = par->
attribute(
"file");
912 std::string msg =
"Attributes \"file\" or \"tmin\" and \"tmax\" not "
913 "found in XML parameter \"GoodTimeIntervals\". "
914 "Please verify the observation definition XML "
998 #if defined(G_RANGE_CHECK)
1000 if (index < 0 || index >=
m_num) {
1022 #if defined(G_RANGE_CHECK)
1024 if (index < 0 || index >=
m_num) {
1050 for (
int i = 0; i <
m_num; ++i) {
1134 result.append(
"=== GGti ===");
1145 result.append(
" - ");
1147 result.append(
" "+
reference().timeunit());
1148 result.append(
" ("+
reference().timesys()+
")");
1150 result.append(
tstart().utc());
1151 result.append(
" - ");
1152 result.append(
tstop().utc());
1153 result.append(
" "+
reference().timeunit());
1154 result.append(
" ("+
reference().timesys()+
")");
1231 for (
int i = 0; i <
m_num; ++i) {
1280 for (
int i = 1; i <
m_num; ++i) {
1295 for (
int i = 0; i <
m_num; ++i) {
1327 std::string msg =
"Invalid time interval specified. Start time "+
1337 if (inx < 0) inx = 0;
1346 for (
int i = 0; i < inx; ++i) {
1356 for (
int i = inx+1; i < num; ++i) {
1405 " differs from number of stop times "+
1407 "same number of start and stop times.";
1415 if (inx < 0) inx = 0;
1427 for (
int isrc = 0; isrc < inx; ++isrc, ++idst) {
1429 stop[idst] =
m_stop[isrc];
1433 for (
int isrc = 0; isrc <
tstart.size(); ++isrc, ++idst) {
1435 std::string msg =
"Invalid time interval specified at index "+
1439 "Please specify valid time intervals.";
1443 start[idst] =
tstart[isrc];
1444 stop[idst] =
tstop[isrc];
1449 for (
int isrc = inx; isrc <
m_num; ++isrc, ++idst) {
1451 stop[idst] =
m_stop[isrc];
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_gtis(const int &index, const GTimes &tstart, const GTimes &tstop)
Insert Good Time Intervals.
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