GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GTimeReference Class Reference

Implements a time reference. More...

#include <GTimeReference.hpp>

Inheritance diagram for GTimeReference:
GBase

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 &timesys="TT", const std::string &timeref="LOCAL")
 Time reference constructor. More...
 
 GTimeReference (const int &mjdrefi, const double &mrdreff, const std::string &timeunit, const std::string &timesys="TT", const std::string &timeref="LOCAL")
 Time reference constructor. More...
 
 GTimeReference (const GFitsHDU &hdu)
 FITS header constructor. More...
 
virtual ~GTimeReference (void)
 Destructor. More...
 
GTimeReferenceoperator= (const GTimeReference &ref)
 Assignment operator. More...
 
void clear (void)
 Clear time reference. More...
 
GTimeReferenceclone (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 &timesys="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 &timesys="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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]refTime reference.

Definition at line 77 of file GTimeReference.cpp.

References copy_members(), and init_members().

GTimeReference::GTimeReference ( const double &  mjdref,
const std::string &  timeunit,
const std::string &  timesys = "TT",
const std::string &  timeref = "LOCAL" 
)
explicit

Time reference constructor.

Parameters
[in]mjdrefReference MJD (days).
[in]timeunitTime unit ("sec(s)", "day(s)").
[in]timesysTime system (ignored so far).
[in]timerefTime 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().

GTimeReference::GTimeReference ( const int &  mjdrefi,
const double &  mjdreff,
const std::string &  timeunit,
const std::string &  timesys = "TT",
const std::string &  timeref = "LOCAL" 
)
explicit

Time reference constructor.

Parameters
[in]mjdrefiInteger part of reference MJD (days).
[in]mjdreffFractional part of reference MJD (days).
[in]timeunitTime unit (sec, days).
[in]timesysTime system (TT).
[in]timerefLocal 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().

GTimeReference::GTimeReference ( const GFitsHDU hdu)
explicit

FITS header constructor.

Parameters
[in]hduFITS 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().

GTimeReference::~GTimeReference ( void  )
virtual

Destructor.

Definition at line 170 of file GTimeReference.cpp.

References free_members().

Member Function Documentation

std::string GTimeReference::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GTimeReference").

Implements GBase.

Definition at line 124 of file GTimeReference.hpp.

void GTimeReference::clear ( void  )
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().

GTimeReference * GTimeReference::clone ( void  ) const
virtual

Clone object.

Returns
Pointer to deep copy of time reference.

Implements GBase.

Definition at line 239 of file GTimeReference.cpp.

References GTimeReference().

void GTimeReference::copy_members ( const GTimeReference ref)
protected

Copy class members.

Parameters
[in]refTime reference.

Definition at line 688 of file GTimeReference.cpp.

References m_mjdref, m_timeref, m_timesys, m_timeunit, and m_unit_sec.

Referenced by GTimeReference(), and operator=().

void GTimeReference::free_members ( void  )
protected

Delete class members.

Definition at line 705 of file GTimeReference.cpp.

Referenced by clear(), operator=(), and ~GTimeReference().

void GTimeReference::init_members ( void  )
protected

Initialise class members.

Definition at line 669 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
Modified Julian reference day (days).

Returns the Modified Julian reference day.

Definition at line 534 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
Fractional part of Modified Julian reference day (days).

Returns the fractional part of the Modified Julian reference day.

Definition at line 562 of file GTimeReference.cpp.

References m_mjdref, and mjdrefi().

Referenced by read(), set(), and write().

int GTimeReference::mjdrefi ( void  ) const

Returns integer part of MJD reference (units: days)

Returns
Integer part of Modified Julian reference day (days).

Returns the integer part of the Modified Julian reference day.

Definition at line 548 of file GTimeReference.cpp.

References m_mjdref.

Referenced by mjdreff(), read(), and write().

GTimeReference & GTimeReference::operator= ( const GTimeReference ref)

Assignment operator.

Parameters
[in]refTime reference.

Definition at line 191 of file GTimeReference.cpp.

References copy_members(), free_members(), and init_members().

std::string GTimeReference::print ( const GChatter chatter = NORMAL) const
virtual

Print time reference.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing the time reference.

Implements GBase.

Definition at line 635 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.

Parameters
[in]hduFITS extension.

GException::no_valid_time_ref 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.

Parameters
[in]xmlXML element.
Exceptions
GException::invalid_valueInvalid 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 353 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.

Parameters
[in]mjdrefReference MJD (days).
[in]timeunitTime unit ("s", "d", "sec(s)", "day(s)").
[in]timesysTime system.
[in]timerefTime reference.
Exceptions
GException::time_invalid_unitInvalid time unit specified.

Sets the time reference from a MJD reference day, a time unit, a time system and a time reference.

Todo:
Implement checking of "timesys" and "timeref" parameters.

Definition at line 468 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.

Parameters
[in]mjdrefiInteger part of reference MJD (days).
[in]mjdreffFractional part of reference MJD (days).
[in]timeunitTime unit (sec, days).
[in]timesysTime system (TT).
[in]timerefLocal 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 510 of file GTimeReference.cpp.

References mjdref(), mjdreff(), and set().

const std::string & GTimeReference::timeref ( void  ) const

Return time reference.

Returns
Time reference.

Returns the reference time reference.

Definition at line 604 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
Time system.

Returns the reference time system.

Definition at line 590 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
Time unit.

Returns the reference time unit.

Definition at line 576 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
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 619 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.

Parameters
[in]hduFITS 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 314 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.

Parameters
[in]xmlXML 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 435 of file GTimeReference.cpp.

References GXmlElement::attribute(), G_WRITE_XML, mjdreff(), mjdrefi(), gammalib::str(), timeref(), timesys(), timeunit(), and gammalib::xml_need_par().

Member Data Documentation

double GTimeReference::m_mjdref
protected

Time MJD reference (days)

Definition at line 110 of file GTimeReference.hpp.

Referenced by copy_members(), init_members(), mjdref(), mjdreff(), mjdrefi(), and set().

std::string GTimeReference::m_timeref
protected

Time reference.

Definition at line 113 of file GTimeReference.hpp.

Referenced by copy_members(), init_members(), set(), and timeref().

std::string GTimeReference::m_timesys
protected

Time system.

Definition at line 112 of file GTimeReference.hpp.

Referenced by copy_members(), init_members(), set(), and timesys().

std::string GTimeReference::m_timeunit
protected

Time unit.

Definition at line 111 of file GTimeReference.hpp.

Referenced by copy_members(), init_members(), set(), and timeunit().

bool GTimeReference::m_unit_sec
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().


The documentation for this class was generated from the following files: