| 1 | #!/usr/bin/env python3
|
|---|
| 2 | """Test data for satellites outside BNC's range (case eph_out_of_range): the
|
|---|
| 3 | first 6 minutes of data/eph_vote_261118_20min.raw, where each GPS ephemeris
|
|---|
| 4 | (1019) of G24 from ASCG00SHN0, KERG00ATF0 and OWMG00NZL0 is followed by a copy
|
|---|
| 5 | with satellite ID 39 (as broadcast by the NTS-3 test signal since 30 Sep 2026).
|
|---|
| 6 |
|
|---|
| 7 | mk_eph_g39.py data/eph_vote_261118_20min.raw data/eph_g39_261118_6min.raw
|
|---|
| 8 | """
|
|---|
| 9 | import sys
|
|---|
| 10 | import bncraw
|
|---|
| 11 |
|
|---|
| 12 | STATIONS = {"ASCG00SHN0", "KERG00ATF0", "OWMG00NZL0"}
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | def with_sv(payload, sv):
|
|---|
| 16 | p = bytearray(payload) # satellite ID: bits 12-17 after the message number
|
|---|
| 17 | p[1] = (p[1] & 0xF0) | (sv >> 2)
|
|---|
| 18 | p[2] = (p[2] & 0x3F) | ((sv & 0x03) << 6)
|
|---|
| 19 | return bytes(p)
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | def main():
|
|---|
| 23 | src, out = sys.argv[1], sys.argv[2]
|
|---|
| 24 | chunks = []
|
|---|
| 25 | framers = {}
|
|---|
| 26 | for t, sta, fmt, data in bncraw.read_chunks(src):
|
|---|
| 27 | if t >= "2026-11-18T17:49":
|
|---|
| 28 | break
|
|---|
| 29 | chunks.append((t, sta, fmt, data))
|
|---|
| 30 | if sta not in STATIONS:
|
|---|
| 31 | continue
|
|---|
| 32 | extra = b""
|
|---|
| 33 | for p in framers.setdefault(sta, bncraw.Rtcm3Framer()).feed(data):
|
|---|
| 34 | if bncraw.msg_type(p) == "1019" and bncraw.BitReader(p).u(18) & 0x3F == 24:
|
|---|
| 35 | extra += bncraw.frame(with_sv(p, 39))
|
|---|
| 36 | if extra:
|
|---|
| 37 | chunks.append((t, sta, fmt, extra))
|
|---|
| 38 | bncraw.write_chunks(out, chunks)
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | if __name__ == "__main__":
|
|---|
| 42 | main()
|
|---|