nyx-space / hifitime

A high fidelity time management library in Rust
Mozilla Public License 2.0
358 stars 18 forks source link

Add support for QZSS and IRNSS time scale #210

Open ljbade opened 1 year ago

ljbade commented 1 year ago

The two time scales from RINEX 4.0 used in https://github.com/gwbres/rinex/ that is not supported by TimeScale is the QZSS and IRNSS System Time. I would like to make a feature request to add it.

The QZSS System Time has the same offset from TAI as the GPS Time Scale, however technically it is its own time scale as they have their own set of master clocks. Per the QZSS ICD https://qzss.go.jp/en/technical/download/pdf/ps-is-qzss/is-qzss-pnt-004.pdf

5.1. Time System The PNT time system shall is the QZSS time system (QZSST) shown below. (1) Definitions (a) Length of 1 second The length of 1 second in QZSST shall be identical to the International Atomic Time (TAI). (b) Offset between QZSST and TAI QZSST shall be delayed from TAI by 19 seconds. (c) Starting point of week number for QZSST The starting point of the week number for QZSST shall be the same as the GPS time system (GPST), which is 0:00 am (UTC) on January 6, 1980. (2) Navigation message reference time The parameters relating to time such as the SV clock parameter, mean motion and UTC parameters shall all be based on QZSST.

The IRNSS System Time has a 13 second offset from UTC. Per the IRNSS ICD https://www.isro.gov.in/media_isro/pdf/Publications/Vispdf/Pdf2017/irnss_sps_icd_version1.1-2017.pdf

5.7 IRNSS SYSTEM TIME The IRNSS system time is given as 27-bit binary number composed of two parameters as follows: The Week Number is an integer counter that gives the sequential week number from the origin of the IRNSS time. This parameter is coded on 10 bits appearing in the first subframe, which covers 1024 weeks (about 19 years). The Time of Week Count (TOWC) indicates the number of 12 second counts at which the next subframe will begin. It is represented in 17 bits. The TOW count value ranges from 1 to 50400 to cover one entire week. The Time Of Week (TOW) in seconds is obtained by multiplying TOWC with 12. The TOWC will have a value of 1 at 00:00:00 Sunday (Changeover from Saturday to Sunday). The IRNSS System Time start epoch shall be 00:00 UT on Sunday August 22 nd 1999 (midnight between August 21 st and 22 nd ). At the start epoch, IRNSS System Time shall be ahead of UTC by 13 leap seconds. (i.e. IRNSS time, August 22 nd 1999, 00:00:00 corresponds to UTC time August 21 st 1999, 23:59:47) The epoch denoted in the navigation messages by TOWC and WN will be measured relative to the leading edge of the first chip of the first code sequence of the first subframe symbol. The transmission timing of the navigation message provided through the TOWC is synchronized to IRNSS System Time.

ChristopherRabotin commented 1 year ago

QZSS seems pretty straightforward: it seems like a new variant could be added and every operation on that time system would just use the same path as GPST. Is that correct?

IRNSS time is definitely a bit more complicated, especially for the week calculations.

I'll note that this change will require adding non_exhaustive to the time system enum to prevent future breaking changes for users who match on all variants of the enums. Adding a new enum variant is considered a breaking change because the time scale isn't yet defined as a non_exhaustive.

ljbade commented 1 year ago

Yeah QZSS should have some operations as GPST.

Good idea on non_exhaustive as in the future there might be newer GNSS.