Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 15ab1ec1d7e5
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f3bc21b1ed26
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 19, 2019

  1. GST, BDT

    eggrobin committed Feb 19, 2019
    Copy the full SHA
    53356f5 View commit details
  2. after pleroy's review

    eggrobin committed Feb 19, 2019
    Copy the full SHA
    676aea0 View commit details
  3. more const

    eggrobin committed Feb 19, 2019
    Copy the full SHA
    5ccdc0f View commit details

Commits on Mar 4, 2019

  1. Merge pull request #2083 from eggrobin/gnss-time

    GNSS time scales
    eggrobin authored Mar 4, 2019
    Copy the full SHA
    f3bc21b View commit details
Showing with 107 additions and 9 deletions.
  1. +48 −5 astronomy/time_scales.hpp
  2. +42 −4 astronomy/time_scales_body.hpp
  3. +17 −0 astronomy/time_scales_test.cpp
53 changes: 48 additions & 5 deletions astronomy/time_scales.hpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,16 @@ using quantities::Angle;

constexpr Angle EarthRotationAngle(Instant tt);

// Astronomical time scales:
// — Temps Atomique International;
// — Temps Terrestre;
// — Coordinated Universal Time;
// — Universal Time (UT1).
// |Instant| represents TT; note that the conversion from TAI, UTC, and UT1
// converts to TT(TAI), not TT(BIPM); this may cause issues where long-term
// frequency stability and high frequency accuracy are needed, see
// https://www.bipm.org/en/bipm-services/timescales/time-ftp/ttbipm.html.

constexpr Instant operator""_TAI(char const* str, std::size_t size);
constexpr Instant operator""_TT(char const* str, std::size_t size);
constexpr Instant operator""_UTC(char const* str, std::size_t size);
@@ -33,17 +43,50 @@ Instant ParseTT(std::string const& s);
Instant ParseUTC(std::string const& s);
Instant ParseUT1(std::string const& s);

// GNSS time scales.
// As documented, e.g., in p. 32 of the RINEX specification, v. 3.03, update 1,
// ftp://igs.org/pub/data/format/rinex303_update1.pdf,
// apart from the small errors in the realizations of the different time
// systems,
// TAI - 19 s = GPS Time
// = Galileo System Time (GST)
// = 準天頂衛星 (Quasi-Zenith Satellite) Time (QZST)
// = IRNSS Network Time (IRNWT),
// TAI - 33 s = 北斗 (BeiDou) Time (北斗时, BDT),
// UTC = ГЛОНАСС Time.
// The errors in realization are on the order of nanoseconds (nominally 1 μs for
// GPS, 50 ns for Galileo, 50 ns for 北斗).
// Note that by not distinguishing TT(TAI) from TT(BIPM), we disregard much
// larger errors between TAI and TT; for instance,
// TT(BIPM17) = TAI + 32.184 s + 27661.0 ns
// at the end of 2017.
// Even ignoring the 27.6 μs offset, TT(BIPMyy) varies with respect to TAI on
// the order of nanoseconds over a few weeks.
// Since we disregard small errors in realization, we identify ГЛОНАСС time with
// UTC, and the GNSS time scales other than 北斗 and ГЛОНАСС with GPS time.
// We do not support Julian dates in GNSS time scales.

constexpr Instant operator""_GPS(char const* str, std::size_t size);
constexpr Instant operator""_北斗(char const* str, std::size_t size);

Instant ParseGPSTime(std::string const& s);
Instant Parse北斗Time(std::string const& s);

} // namespace internal_time_scales

using internal_time_scales::EarthRotationAngle;
using internal_time_scales::operator""_TAI;
using internal_time_scales::operator""_TT;
using internal_time_scales::operator""_UTC;
using internal_time_scales::operator""_UT1;
using internal_time_scales::Parse北斗Time;
using internal_time_scales::ParseGPSTime;
using internal_time_scales::ParseTAI;
using internal_time_scales::ParseTT;
using internal_time_scales::ParseUTC;
using internal_time_scales::ParseUT1;
using internal_time_scales::ParseUTC;
using internal_time_scales::operator""_北斗;
using internal_time_scales::operator""_GPS;
using internal_time_scales::operator""_TAI;
using internal_time_scales::operator""_TT;
using internal_time_scales::operator""_UT1;
using internal_time_scales::operator""_UTC;

} // namespace astronomy
} // namespace principia
46 changes: 42 additions & 4 deletions astronomy/time_scales_body.hpp
Original file line number Diff line number Diff line change
@@ -63,6 +63,14 @@ constexpr Instant FromTAI(quantities::Time const& tai) {
return FromTT(tai + 32.184 * Second);
}

constexpr Instant FromGPSTime(quantities::Time const& gps) {
return FromTAI(gps + 19 * Second);
}

constexpr Instant From北斗Time(quantities::Time const& 北斗) {
return FromTAI(北斗 + 33 * Second);
}

// Utilities for modern UTC (since 1972).

constexpr std::array<int, (2019 - 1972) * 2 + 1> leap_seconds = {{
@@ -463,6 +471,16 @@ constexpr Instant DateTimeAsTAI(DateTime const& tai) {
return FromTAI(TimeSince20000101T120000Z(tai));
}

constexpr Instant DateTimeAsGPSTime(DateTime const& gps) {
CONSTEXPR_CHECK(!gps.time().is_leap_second());
return FromGPSTime(TimeSince20000101T120000Z(gps));
}

constexpr Instant DateTimeAs北斗Time(DateTime const& 北斗) {
CONSTEXPR_CHECK(!北斗.time().is_leap_second());
return From北斗Time(TimeSince20000101T120000Z(北斗));
}

constexpr Instant DateTimeAsUTC(DateTime const& utc) {
if (utc.time().is_end_of_day()) {
return DateTimeAsUTC(utc.normalized_end_of_day());
@@ -486,34 +504,46 @@ constexpr Instant DateTimeAsUT1(DateTime const& ut1) {

// |Instant| date literals.

constexpr Instant operator""_TAI(char const* str, std::size_t size) {
constexpr Instant operator""_TAI(char const* str, std::size_t const size) {
if (IsJulian(str, size)) {
return FromTAI(TimeSinceJ2000(operator""_Julian(str, size)));
} else {
return DateTimeAsTAI(operator""_DateTime(str, size));
}
}

constexpr Instant operator""_TT(char const* str, std::size_t size) {
constexpr Instant operator""_TT(char const* const str, std::size_t const size) {
if (IsJulian(str, size)) {
return FromTT(TimeSinceJ2000(operator""_Julian(str, size)));
} else {
return DateTimeAsTT(operator""_DateTime(str, size));
}
}

constexpr Instant operator""_UTC(char const* str, std::size_t size) {
constexpr Instant operator""_UTC(char const* const str,
std::size_t const size) {
return DateTimeAsUTC(operator""_DateTime(str, size));
}

constexpr Instant operator""_UT1(char const* str, std::size_t size) {
constexpr Instant operator""_UT1(char const* const str,
std::size_t const size) {
if (IsJulian(str, size)) {
return FromUT1(TimeSinceJ2000(operator""_Julian(str, size)));
} else {
return DateTimeAsUT1(operator""_DateTime(str, size));
}
}

constexpr Instant operator""_GPS(char const* const str,
std::size_t const size) {
return DateTimeAsGPSTime(operator""_DateTime(str, size));
}

constexpr Instant operator""_北斗(char const* const str,
std::size_t const size) {
return DateTimeAs北斗Time(operator""_DateTime(str, size));
}

inline Instant ParseTAI(std::string const& s) {
return operator""_TAI(s.c_str(), s.size());
}
@@ -530,6 +560,14 @@ inline Instant ParseUT1(std::string const& s) {
return operator""_UT1(s.c_str(), s.size());
}

inline Instant ParseGPSTime(std::string const& s) {
return operator""_GPS(s.c_str(), s.size());
}

inline Instant Parse北斗Time(std::string const& s) {
return operator""_北斗(s.c_str(), s.size());
}

} // namespace internal_time_scales
} // namespace astronomy
} // namespace principia
17 changes: 17 additions & 0 deletions astronomy/time_scales_test.cpp
Original file line number Diff line number Diff line change
@@ -458,6 +458,23 @@ TEST_F(TimeScalesTest, EarthRotationAngle) {
IsNear(-0.0000137 * Degree / Day));
}

TEST_F(TimeScalesTest, GNSS) {
// BeiDou Navigation Satellite System
// Signal In Space Interface Control Document
// Open Service Signals B1C and B2a (Test Version),
// 3.3 Time System.
// The start epoch of BDT is 00:00:00 on January 1, 2006 of Coordinated
// Universal Time (UTC).
EXPECT_THAT("2006-01-01T00:00:00"_北斗, Eq("2006-01-01T00:00:00"_UTC));

// Galileo OS SIS ICD, Issue 1.1.
// 5.1.2. Galileo System Time (GST).
// The GST start epoch shall be 00:00 UT on Sunday 22nd August 1999 (midnight
// between 21st and 22nd August). At the start epoch, GST shall be ahead of
// UTC by thirteen (13) leap seconds.
EXPECT_THAT("1999-08-22T00:00:13"_GPS, Eq("1999-08-22T00:00:00"_UTC));
}

} // namespace internal_time_scales
} // namespace astronomy
} // namespace principia