GammaLib
2.0.0
|
Implements a time reference. More...
#include <GTimeReference.hpp>
Public Member Functions | |
GTimeReference (void) | |
Void constructor. More... | |
GTimeReference (const GTimeReference &ref) | |
Copy constructor. More... | |
GTimeReference (const double &mjdref, const std::string &timeunit, const std::string ×ys="TT", const std::string &timeref="LOCAL") | |
Time reference constructor. More... | |
GTimeReference (const int &mjdrefi, const double &mrdreff, const std::string &timeunit, const std::string ×ys="TT", const std::string &timeref="LOCAL") | |
Time reference constructor. More... | |
GTimeReference (const GFitsHDU &hdu) | |
FITS header constructor. More... | |
virtual | ~GTimeReference (void) |
Destructor. More... | |
GTimeReference & | operator= (const GTimeReference &ref) |
Assignment operator. More... | |
void | clear (void) |
Clear time reference. More... | |
GTimeReference * | clone (void) const |
Clone object. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | read (const GFitsHDU &hdu) |
Read time reference from FITS header. More... | |
void | write (GFitsHDU &hdu) const |
Write time reference into FITS header. More... | |
void | read (const GXmlElement &xml) |
Read time reference from XML element. More... | |
void | write (GXmlElement &xml) const |
Write time reference into XML element. More... | |
void | set (const double &mrdref, const std::string &timeunit, const std::string ×ys="TT", const std::string &timeref="LOCAL") |
Set time reference. More... | |
void | set (const int &mjdrefi, const double &mjdreff, const std::string &timeunit, const std::string ×ys="TT", const std::string &timeref="LOCAL") |
Set time reference. More... | |
const double & | mjdref (void) const |
Return MJD reference (units: days) More... | |
int | mjdrefi (void) const |
Returns integer part of MJD reference (units: days) More... | |
double | mjdreff (void) const |
Returns fractional part of MJD reference (units: days) More... | |
const std::string & | timeunit (void) const |
Return time unit. More... | |
const std::string & | timesys (void) const |
Return time system. More... | |
const std::string & | timeref (void) const |
Return time reference. More... | |
double | unitseconds (void) const |
Return the time unit in seconds. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print time reference. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GTimeReference &ref) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
double | m_mjdref |
Time MJD reference (days) More... | |
std::string | m_timeunit |
Time unit. More... | |
std::string | m_timesys |
Time system. More... | |
std::string | m_timeref |
Time reference. More... | |
bool | m_unit_sec |
True: unit is seconds, False: unit is days. More... | |
Implements a time reference.
This class implements the reference of a time with respect to Modified Julian Days. The zero point of the time is specified by the member m_mjdref that is given in Modified Julian Days. A time may be either either given in seconds or in days. Furthermore, the time system needs to be specified. So far, only Terrestrial Time (TT) is supported. Also the reference of the time system needs to be given. So far, only Local is supported.
References: http://aa.usno.navy.mil/publications/docs/Circular_179.php http://hpiers.obspm.fr/eop-pc/index.php?index=TAI-UTC_tab&lang=en
Definition at line 56 of file GTimeReference.hpp.
GTimeReference::GTimeReference | ( | void | ) |
Void constructor.
Definition at line 62 of file GTimeReference.cpp.
References init_members().
Referenced by clone().
GTimeReference::GTimeReference | ( | const GTimeReference & | ref | ) |
Copy constructor.
[in] | ref | Time reference. |
Definition at line 77 of file GTimeReference.cpp.
References copy_members(), and init_members().
|
explicit |
Time reference constructor.
[in] | mjdref | Reference MJD (days). |
[in] | timeunit | Time unit ("sec(s)", "day(s)"). |
[in] | timesys | Time system (ignored so far). |
[in] | timeref | Time reference (ignored so far). |
Sets the time reference from a MJD reference day, a time unit, a time system and a time reference.
Definition at line 101 of file GTimeReference.cpp.
References init_members(), and set().
|
explicit |
Time reference constructor.
[in] | mjdrefi | Integer part of reference MJD (days). |
[in] | mjdreff | Fractional part of reference MJD (days). |
[in] | timeunit | Time unit (sec, days). |
[in] | timesys | Time system (TT). |
[in] | timeref | Local time reference. |
Sets the time reference from a MJD reference day (specified by an integer and a fractional part), a time unit, a time system and a time reference.
Definition at line 129 of file GTimeReference.cpp.
References init_members(), and set().
|
explicit |
FITS header constructor.
[in] | hdu | FITS extension. |
Constructs time reference from the information found in the FITS header. See GTimeReference::read for more information on the expected format.
Definition at line 154 of file GTimeReference.cpp.
References init_members(), and read().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 124 of file GTimeReference.hpp.
|
virtual |
Clear time reference.
Implements GBase.
Definition at line 221 of file GTimeReference.cpp.
References free_members(), and init_members().
Referenced by GModelTemporalLightCurve::init_members(), and read().
|
virtual |
Clone object.
Implements GBase.
Definition at line 239 of file GTimeReference.cpp.
References GTimeReference().
|
protected |
Copy class members.
[in] | ref | Time reference. |
Definition at line 691 of file GTimeReference.cpp.
References m_mjdref, m_timeref, m_timesys, m_timeunit, and m_unit_sec.
Referenced by GTimeReference(), and operator=().
|
protected |
Delete class members.
Definition at line 708 of file GTimeReference.cpp.
Referenced by clear(), operator=(), and ~GTimeReference().
|
protected |
Initialise class members.
Definition at line 672 of file GTimeReference.cpp.
References m_mjdref, m_timeref, m_timesys, m_timeunit, and m_unit_sec.
Referenced by clear(), GTimeReference(), and operator=().
const double & GTimeReference::mjdref | ( | void | ) | const |
Return MJD reference (units: days)
Returns the Modified Julian reference day.
Definition at line 537 of file GTimeReference.cpp.
References m_mjdref.
Referenced by GTime::convert(), GModelTemporalLightCurve::print(), print(), read(), set(), GTime::set(), and write().
double GTimeReference::mjdreff | ( | void | ) | const |
Returns fractional part of MJD reference (units: days)
Returns the fractional part of the Modified Julian reference day.
Definition at line 565 of file GTimeReference.cpp.
int GTimeReference::mjdrefi | ( | void | ) | const |
GTimeReference & GTimeReference::operator= | ( | const GTimeReference & | ref | ) |
Assignment operator.
[in] | ref | Time reference. |
Definition at line 191 of file GTimeReference.cpp.
References copy_members(), free_members(), and init_members().
Print time reference.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 638 of file GTimeReference.cpp.
References mjdref(), gammalib::parformat(), SILENT, gammalib::str(), timeref(), timesys(), and timeunit().
void GTimeReference::read | ( | const GFitsHDU & | hdu | ) |
Read time reference from FITS header.
[in] | hdu | FITS extension. |
GException::invalid_value No valid reference MJD found in header.
Reads the time reference information from a FITS header. The method requires either the keyword "MJDREF" or the pair of keywords "MJDREFI" and "MJDREFF" to be set. The following keywords are optional (the assumed default values in absent of the keywords is given in parentheses):
TIMEUNIT ("s") TIMESYS ("TT") TIMEREF ("LOCAL")
Definition at line 264 of file GTimeReference.cpp.
References G_READ, GFitsHDU::has_card(), GFitsHDU::integer(), mjdref(), mjdreff(), mjdrefi(), GFitsHDU::real(), set(), GFitsHDU::string(), timeref(), timesys(), and timeunit().
Referenced by GTimeReference(), GModelTemporalLightCurve::load_nodes(), and GGti::read().
void GTimeReference::read | ( | const GXmlElement & | xml | ) |
Read time reference from XML element.
[in] | xml | XML element. |
GException::invalid_value | Invalid XML format encountered. |
Reads the time reference from an XML element. The format of the time reference is
<parameter name="TimeReference" mjdrefi="..." mjdreff="..." timeunit="..." timesys="..." timeref="..."/>
Definition at line 355 of file GTimeReference.cpp.
References GXmlElement::attribute(), clear(), G_READ_XML, GXmlElement::has_attribute(), mjdreff(), mjdrefi(), set(), timeref(), timesys(), timeunit(), gammalib::todouble(), gammalib::toint(), and gammalib::xml_get_par().
void GTimeReference::set | ( | const double & | mjdref, |
const std::string & | timeunit, | ||
const std::string & | timesys = "TT" , |
||
const std::string & | timeref = "LOCAL" |
||
) |
Set time reference.
[in] | mjdref | Reference MJD (days). |
[in] | timeunit | Time unit ("s", "d", "sec(s)", "day(s)"). |
[in] | timesys | Time system. |
[in] | timeref | Time reference. |
GException::invalid_argument | Invalid time unit specified. |
Sets the time reference from a MJD reference day, a time unit, a time system and a time reference.
Definition at line 470 of file GTimeReference.cpp.
References G_SET, m_mjdref, m_timeref, m_timesys, m_timeunit, m_unit_sec, mjdref(), gammalib::tolower(), and gammalib::toupper().
Referenced by GTimeReference(), read(), and set().
void GTimeReference::set | ( | const int & | mjdrefi, |
const double & | mjdreff, | ||
const std::string & | timeunit, | ||
const std::string & | timesys = "TT" , |
||
const std::string & | timeref = "LOCAL" |
||
) |
Set time reference.
[in] | mjdrefi | Integer part of reference MJD (days). |
[in] | mjdreff | Fractional part of reference MJD (days). |
[in] | timeunit | Time unit (sec, days). |
[in] | timesys | Time system (TT). |
[in] | timeref | Local time reference. |
Sets the time reference from a MJD reference day (specified by an integer and a fractional part), a time unit, a time system and a time reference.
Definition at line 513 of file GTimeReference.cpp.
const std::string & GTimeReference::timeref | ( | void | ) | const |
Return time reference.
Returns the reference time reference.
Definition at line 607 of file GTimeReference.cpp.
References m_timeref.
Referenced by print(), read(), GTime::set(), and write().
const std::string & GTimeReference::timesys | ( | void | ) | const |
Return time system.
Returns the reference time system.
Definition at line 593 of file GTimeReference.cpp.
References m_timesys.
Referenced by GTime::convert(), GModelTemporalLightCurve::print(), print(), read(), GTime::set(), and write().
const std::string & GTimeReference::timeunit | ( | void | ) | const |
Return time unit.
Returns the reference time unit.
Definition at line 579 of file GTimeReference.cpp.
References m_timeunit.
Referenced by GModelTemporalLightCurve::print(), print(), read(), GTime::set(), and write().
double GTimeReference::unitseconds | ( | void | ) | const |
Return the time unit in seconds.
Returns 1 if the time using is in seconds and 86400 if the time unit is in days.
Definition at line 622 of file GTimeReference.cpp.
References m_unit_sec, and gammalib::sec_in_day.
Referenced by GTime::convert(), and GTime::set().
void GTimeReference::write | ( | GFitsHDU & | hdu | ) | const |
Write time reference into FITS header.
[in] | hdu | FITS extension. |
Writes or updates the time reference information in a FITS header. Depending of whether the keyword "MJDREF" or the pair of keywords "MJDREFI" and "MJDREFF" exist already in the header, the method either writes the reference MJD as floating point value, or split into an integer and a fractional part. If nothing has been written yet, splitting into an integer and fractional part will be used as this preserves the highest possible accuracy.
The following additional keywords are written: TIMEUNIT TIMESYS TIMEREF
Definition at line 316 of file GTimeReference.cpp.
References GFitsHDU::card(), GFitsHDU::has_card(), mjdref(), mjdreff(), mjdrefi(), timeref(), timesys(), and timeunit().
Referenced by GGti::write(), and GCTAObservation::write_attributes().
void GTimeReference::write | ( | GXmlElement & | xml | ) | const |
Write time reference into XML element.
[in] | xml | XML element. |
Writes the time reference into an XML element. The format of the time reference is
<parameter name="TimeReference" mjdrefi="..." mjdreff="..." timeunit="..." timesys="..." timeref="..."/>
Definition at line 437 of file GTimeReference.cpp.
References GXmlElement::attribute(), G_WRITE_XML, mjdreff(), mjdrefi(), gammalib::str(), timeref(), timesys(), timeunit(), and gammalib::xml_need_par().
|
protected |
Time MJD reference (days)
Definition at line 110 of file GTimeReference.hpp.
Referenced by copy_members(), init_members(), mjdref(), mjdreff(), mjdrefi(), and set().
|
protected |
Time reference.
Definition at line 113 of file GTimeReference.hpp.
Referenced by copy_members(), init_members(), set(), and timeref().
|
protected |
Time system.
Definition at line 112 of file GTimeReference.hpp.
Referenced by copy_members(), init_members(), set(), and timesys().
|
protected |
Time unit.
Definition at line 111 of file GTimeReference.hpp.
Referenced by copy_members(), init_members(), set(), and timeunit().
|
protected |
True: unit is seconds, False: unit is days.
Definition at line 114 of file GTimeReference.hpp.
Referenced by copy_members(), init_members(), set(), and unitseconds().