Commit 3bf67e06cc03c664d1abb2fc76f155e32ad4a341
1 parent
8b30ae91
Add GTime.julian_epoch() methods (#1854)
Showing
4 changed files
with
50 additions
and
11 deletions
NEWS
| 1 | 1 | New Features and Important Changes in GammaLib 1.7.0 |
| 2 | 2 | |
| 3 | -8 November 2019 | |
| 3 | +12 November 2019 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | 1. Introduction |
| ... | ... | @@ -24,6 +24,7 @@ The following classes have been renamed: |
| 24 | 24 | |
| 25 | 25 | The following methods have been added: |
| 26 | 26 | - GTime.datetime() - Datetime conversion in Python interface |
| 27 | +- GTime.julian_epoch() - Returns Julian epoch for time | |
| 27 | 28 | - GGti::overlap(GTime&, GTime&) - Compute overlap with time interval |
| 28 | 29 | - GObservations::npred(string&, string&) - Compute predicted number of events |
| 29 | 30 | - GObservations::npred(GModel&, string&) - Compute predicted number of events |
| ... | ... | @@ -107,6 +108,9 @@ Add GTime.datetime() method to the Python interface to convert times from and |
| 107 | 108 | to datetime.datetime objects. Add an optional precision argument to the GTime.utc() |
| 108 | 109 | to set the number of digits after the comma for the seconds (#2909). |
| 109 | 110 | |
| 111 | +Add GTime.julian_epoch() methods that return the Julian epoch for a given time | |
| 112 | +(#1854). | |
| 113 | + | |
| 110 | 114 | |
| 111 | 115 | 11. Optimization module |
| 112 | 116 | ----------------------- | ... | ... |
include/GTime.hpp
| ... | ... | @@ -92,6 +92,8 @@ public: |
| 92 | 92 | double secs(const std::string& timesys) const; |
| 93 | 93 | double days(void) const; |
| 94 | 94 | double days(const std::string& timesys) const; |
| 95 | + double julian_epoch(void) const; | |
| 96 | + double julian_epoch(const std::string& timesys) const; | |
| 95 | 97 | std::string utc(const int& precision = 0) const; |
| 96 | 98 | double gmst(void) const; |
| 97 | 99 | double gast(void) const; | ... | ... |
pyext/GTime.i
| ... | ... | @@ -62,6 +62,8 @@ public: |
| 62 | 62 | double secs(const std::string& timesys) const; |
| 63 | 63 | double days(void) const; |
| 64 | 64 | double days(const std::string& timesys) const; |
| 65 | + double julian_epoch(void) const; | |
| 66 | + double julian_epoch(const std::string& timesys) const; | |
| 65 | 67 | std::string utc(const int& precision = 0) const; |
| 66 | 68 | double gmst(void) const; |
| 67 | 69 | double gast(void) const; | ... | ... |
src/obs/GTime.cpp
| ... | ... | @@ -291,7 +291,7 @@ double GTime::jd(void) const |
| 291 | 291 | |
| 292 | 292 | |
| 293 | 293 | /***********************************************************************//** |
| 294 | - * @brief Return time in Julian Days for various time system | |
| 294 | + * @brief Return time in Julian Days for time system | |
| 295 | 295 | * |
| 296 | 296 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| 297 | 297 | * @return Time in Julian Days (days). |
| ... | ... | @@ -327,7 +327,7 @@ double GTime::mjd(void) const |
| 327 | 327 | |
| 328 | 328 | |
| 329 | 329 | /***********************************************************************//** |
| 330 | - * @brief Return time in Modified Julian Days for various time system | |
| 330 | + * @brief Return time in Modified Julian Days for time system | |
| 331 | 331 | * |
| 332 | 332 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| 333 | 333 | * @return Time in Modified Julian Days (days). |
| ... | ... | @@ -346,7 +346,7 @@ double GTime::mjd(const std::string& timesys) const |
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | /***********************************************************************//** |
| 349 | - * @brief Return time in seconds in native reference for various time systems | |
| 349 | + * @brief Return time in seconds in native reference for time system | |
| 350 | 350 | * |
| 351 | 351 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| 352 | 352 | * @return Time (seconds). |
| ... | ... | @@ -404,7 +404,7 @@ double GTime::days(void) const |
| 404 | 404 | |
| 405 | 405 | |
| 406 | 406 | /***********************************************************************//** |
| 407 | - * @brief Return time in days in native reference for various time system | |
| 407 | + * @brief Return time in days in native reference for time system | |
| 408 | 408 | * |
| 409 | 409 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| 410 | 410 | * @return Time in native reference (days). |
| ... | ... | @@ -417,6 +417,37 @@ double GTime::days(const std::string& timesys) const |
| 417 | 417 | |
| 418 | 418 | |
| 419 | 419 | /***********************************************************************//** |
| 420 | + * @brief Return Julian epoch in native reference (TT) | |
| 421 | + * | |
| 422 | + * @return Julian epoch (years). | |
| 423 | + ***************************************************************************/ | |
| 424 | +double GTime::julian_epoch(void) const | |
| 425 | +{ | |
| 426 | + // Compute Julian epoch | |
| 427 | + double julian_epoch = 2000.0 + (jd() - 2451545.0) / 365.25; | |
| 428 | + | |
| 429 | + // Return Julian epoch | |
| 430 | + return (julian_epoch); | |
| 431 | +} | |
| 432 | + | |
| 433 | + | |
| 434 | +/***********************************************************************//** | |
| 435 | + * @brief Return Julian epoch in native reference for time system | |
| 436 | + * | |
| 437 | + * @param[in] timesys Time system (one of "TT", "TAI", "UTC") | |
| 438 | + * @return Julian epoch (years). | |
| 439 | + ***************************************************************************/ | |
| 440 | +double GTime::julian_epoch(const std::string& timesys) const | |
| 441 | +{ | |
| 442 | + // Compute Julian epoch | |
| 443 | + double julian_epoch = 2000.0 + (jd(timesys) - 2451545.0) / 365.25; | |
| 444 | + | |
| 445 | + // Return Julian epoch | |
| 446 | + return (julian_epoch); | |
| 447 | +} | |
| 448 | + | |
| 449 | + | |
| 450 | +/***********************************************************************//** | |
| 420 | 451 | * @brief Return time as string in UTC time system |
| 421 | 452 | * |
| 422 | 453 | * @param[in] precision Digits of precision to show in the seconds field |
| ... | ... | @@ -700,7 +731,7 @@ void GTime::jd(const double& time) |
| 700 | 731 | |
| 701 | 732 | |
| 702 | 733 | /***********************************************************************//** |
| 703 | - * @brief Set time in Julian Days in native reference for various time systems | |
| 734 | + * @brief Set time in Julian Days in native reference for time system | |
| 704 | 735 | * |
| 705 | 736 | * @param[in] time Time in Julian Days (days). |
| 706 | 737 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| ... | ... | @@ -734,8 +765,8 @@ void GTime::mjd(const double& time) |
| 734 | 765 | |
| 735 | 766 | |
| 736 | 767 | /***********************************************************************//** |
| 737 | - * @brief Set time in Modified Julian Days in native reference for various | |
| 738 | - * time systems | |
| 768 | + * @brief Set time in Modified Julian Days in native reference for time | |
| 769 | + * system | |
| 739 | 770 | * |
| 740 | 771 | * @param[in] time Time in Modified Julian Days (days). |
| 741 | 772 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| ... | ... | @@ -754,7 +785,7 @@ void GTime::mjd(const double& time, const std::string& timesys) |
| 754 | 785 | |
| 755 | 786 | |
| 756 | 787 | /***********************************************************************//** |
| 757 | - * @brief Set time in seconds in native reference for various time systems | |
| 788 | + * @brief Set time in seconds in native reference for time system | |
| 758 | 789 | * |
| 759 | 790 | * @param[in] seconds Time in native reference (seconds). |
| 760 | 791 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| ... | ... | @@ -807,7 +838,7 @@ void GTime::days(const double& days) |
| 807 | 838 | |
| 808 | 839 | |
| 809 | 840 | /***********************************************************************//** |
| 810 | - * @brief Set time in days in native reference for various time systems | |
| 841 | + * @brief Set time in days in native reference for time system | |
| 811 | 842 | * |
| 812 | 843 | * @param[in] days Time (TT) (days). |
| 813 | 844 | * @param[in] timesys Time system (one of "TT", "TAI", "UTC") |
| ... | ... | @@ -1122,7 +1153,7 @@ GTimeReference GTime::reference(void) const |
| 1122 | 1153 | /***********************************************************************//** |
| 1123 | 1154 | * @brief Print time |
| 1124 | 1155 | * |
| 1125 | - * @param[in] chatter Chattiness (defaults to NORMAL). | |
| 1156 | + * @param[in] chatter Chattiness. | |
| 1126 | 1157 | * @return String containing time in seconds in native reference. |
| 1127 | 1158 | * |
| 1128 | 1159 | * Prints time in seconds in the native reference. | ... | ... |