Commit 810e8ce5d6dd2f2abfa1f4cf95eedf37d8998cf3
1 parent
64291901
Implement utc2tt() method at the level of the GTime class
Showing
6 changed files
with
36 additions
and
22 deletions
include/GEphemerides.hpp
include/GTime.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTime.hpp - Time class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2019 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2022 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GBase.hpp" |
| 33 | +#include "GTools.hpp" | |
| 33 | 34 | #include "GTimeReference.hpp" |
| 34 | 35 | |
| 35 | 36 | /* __ Forward declarations _______________________________________________ */ |
| ... | ... | @@ -99,6 +100,8 @@ public: |
| 99 | 100 | double gast(void) const; |
| 100 | 101 | double lmst(const double& geolon) const; |
| 101 | 102 | double last(const double& geolon) const; |
| 103 | + double leap_seconds(void) const; | |
| 104 | + double utc2tt(void) const; | |
| 102 | 105 | double convert(const GTimeReference& ref) const; |
| 103 | 106 | void jd(const double& time); |
| 104 | 107 | void jd(const double& time, const std::string& timesys); |
| ... | ... | @@ -170,6 +173,34 @@ void GTime::secs(const double& seconds) |
| 170 | 173 | |
| 171 | 174 | |
| 172 | 175 | /***********************************************************************//** |
| 176 | + * @brief Return number of leap seconds for current time | |
| 177 | + * | |
| 178 | + * @return Number of leap seconds for current time (seconds). | |
| 179 | + ***************************************************************************/ | |
| 180 | +inline | |
| 181 | +double GTime::leap_seconds(void) const | |
| 182 | +{ | |
| 183 | + return (leap_seconds(this->mjd())); | |
| 184 | +} | |
| 185 | + | |
| 186 | + | |
| 187 | +/***********************************************************************//** | |
| 188 | + * @brief Return time difference between UTC and TT (seconds) | |
| 189 | + * | |
| 190 | + * @return Time difference between UTC and TT (seconds). | |
| 191 | + * | |
| 192 | + * Returns the time difference between UTC and TT. The time difference is | |
| 193 | + * a positive number and is given by the sum of 32.184 s and the number | |
| 194 | + * of leap seconds. | |
| 195 | + ***************************************************************************/ | |
| 196 | +inline | |
| 197 | +double GTime::utc2tt(void) const | |
| 198 | +{ | |
| 199 | + return (leap_seconds()+gammalib::tai2tt); | |
| 200 | +} | |
| 201 | + | |
| 202 | + | |
| 203 | +/***********************************************************************//** | |
| 173 | 204 | * @brief Signals if year is a leap year |
| 174 | 205 | * |
| 175 | 206 | * @param[in] year Year (four digits integer). | ... | ... |
pyext/GEphemerides.i
pyext/GTime.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTime.i - Time class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2019 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2022 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -69,6 +69,8 @@ public: |
| 69 | 69 | double gast(void) const; |
| 70 | 70 | double lmst(const double& geolon) const; |
| 71 | 71 | double last(const double& geolon) const; |
| 72 | + double leap_seconds(void) const; | |
| 73 | + double utc2tt(void) const; | |
| 72 | 74 | double convert(const GTimeReference& ref) const; |
| 73 | 75 | void jd(const double& time); |
| 74 | 76 | void jd(const double& time, const std::string& timesys); | ... | ... |
src/obs/GEphemerides.cpp
| ... | ... | @@ -397,23 +397,6 @@ double GEphemerides::geo2ssb(const GTime& time, const GSkyDir& srcdir) const |
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | /***********************************************************************//** |
| 400 | - * @brief Get time difference between UTC and TT (seconds) | |
| 401 | - * | |
| 402 | - * @param[in] time Time. | |
| 403 | - * @return Time difference in seconds. | |
| 404 | - * | |
| 405 | - * Returns the time difference between UTC and TT. The time difference is | |
| 406 | - * a positive number and is given by the sum of 32.184 s and the number | |
| 407 | - * of leap seconds. The number of leap seconds depends on the @p time. | |
| 408 | - ***************************************************************************/ | |
| 409 | -double GEphemerides::utc2tt(const GTime& time) const | |
| 410 | -{ | |
| 411 | - // Return UTC to TT term | |
| 412 | - return (time.secs("TT") - time.secs("UTC")); | |
| 413 | -} | |
| 414 | - | |
| 415 | - | |
| 416 | -/***********************************************************************//** | |
| 417 | 400 | * @brief Print Ephemerides |
| 418 | 401 | * |
| 419 | 402 | * @param[in] chatter Chattiness. | ... | ... |
src/obs/GPulsar.cpp
| ... | ... | @@ -834,7 +834,7 @@ void GPulsar::load_psrtime(const GFilename& filename, const std::string& name) |
| 834 | 834 | // COM-RP-DOL-DRG-065.Note that the phase is negative, see for |
| 835 | 835 | // example Eq. (3) in Yan et al. (2017), ApJ, 845, 119 |
| 836 | 836 | double geo2ssb = ephemerides.geo2ssb(toa, dir); |
| 837 | - double utc2tt = ephemerides.utc2tt(toa); | |
| 837 | + double utc2tt = toa.utc2tt(); | |
| 838 | 838 | double dt = (t0geo - t0nom) * gammalib::sec_in_day + geo2ssb + utc2tt; |
| 839 | 839 | const double c1 = 1.0/2.0; |
| 840 | 840 | const double c2 = 1.0/6.0; | ... | ... |