The TLE reader in src/sgpsdp/sgp_in.c gets a great deal right. I compiled the sgpsdp module on its own (with a two-line stand-in for GLib, since the module only uses g_ascii_strtod) behind a small harness that prints the tle_t it fills, and fed it 604 current CelesTrak element sets: the checksums and layout checks reject what they should, and the epoch, eccentricity, inclination, RAAN, argument of perigee, mean anomaly, both derivatives with their implied exponents, BSTAR including negative values and the +0 exponent form, the element set number and the revolution number all came back exactly as printed. [tested]
One field does not. The mean motion occupies columns 53-63 of line 2, eleven characters with eight decimals, but Convert_Satellite_Data copies ten of them (sgp_in.c lines 221-223 at v2.6: the strncpy count and the terminator index are both 10), so the last decimal is dropped on every element set. Your own test data shows it: test-001.tle carries 16.05824518 and tle->xno comes back as 16.0582451. [tested]
The lost digit is worth up to 9e-8 rev/day, and it feeds SGP4 directly. Measured on a current ISS set with its last digit dropped (15.49196792 read as 15.4919679, a change of 2e-8): 0.04 m after 1 h, 0.86 m after 24 h, 6.0 m after 7 days; the worst case, a dropped 9, is 4.5 times that. Nothing an antenna will notice, but a printed digit lost silently before the propagator sees it. [measured]
The fix is two numbers on lines 221 and 222: copy eleven characters and terminate at index eleven (buff is fifteen bytes, so there is room). With that change, the same 604 sets read the mean motion exactly, and test-001 still builds and runs; its printed deltas against the Spacetrack Report #3 vectors move by a few millimetres at t = 0 and a few metres at 1440 minutes, within the port's other small differences. The neighbouring copy for the revolution number starts at the right index, so nothing else moves. [tested]
The line is inherited: the module's README credits Hari Nair's version of Neoklis Kyriazis's sgp4sdp4-0.3, and Xplanet's src/libsgp4sdp4/sgp_in.c (line 154 in Debian's 1.3.1-5 source) carries the same ten-character copy. I will mention it there separately. [read]
Happy to open a pull request with the two-number change and an assertion in test-001 on the parsed mean motion.
The TLE reader in
src/sgpsdp/sgp_in.cgets a great deal right. I compiled thesgpsdpmodule on its own (with a two-line stand-in for GLib, since the module only usesg_ascii_strtod) behind a small harness that prints thetle_tit fills, and fed it 604 current CelesTrak element sets: the checksums and layout checks reject what they should, and the epoch, eccentricity, inclination, RAAN, argument of perigee, mean anomaly, both derivatives with their implied exponents, BSTAR including negative values and the+0exponent form, the element set number and the revolution number all came back exactly as printed. [tested]One field does not. The mean motion occupies columns 53-63 of line 2, eleven characters with eight decimals, but
Convert_Satellite_Datacopies ten of them (sgp_in.clines 221-223 at v2.6: thestrncpycount and the terminator index are both 10), so the last decimal is dropped on every element set. Your own test data shows it:test-001.tlecarries16.05824518andtle->xnocomes back as16.0582451. [tested]The lost digit is worth up to 9e-8 rev/day, and it feeds SGP4 directly. Measured on a current ISS set with its last digit dropped (
15.49196792read as15.4919679, a change of 2e-8): 0.04 m after 1 h, 0.86 m after 24 h, 6.0 m after 7 days; the worst case, a dropped 9, is 4.5 times that. Nothing an antenna will notice, but a printed digit lost silently before the propagator sees it. [measured]The fix is two numbers on lines 221 and 222: copy eleven characters and terminate at index eleven (
buffis fifteen bytes, so there is room). With that change, the same 604 sets read the mean motion exactly, andtest-001still builds and runs; its printed deltas against the Spacetrack Report #3 vectors move by a few millimetres at t = 0 and a few metres at 1440 minutes, within the port's other small differences. The neighbouring copy for the revolution number starts at the right index, so nothing else moves. [tested]The line is inherited: the module's README credits Hari Nair's version of Neoklis Kyriazis's sgp4sdp4-0.3, and Xplanet's
src/libsgp4sdp4/sgp_in.c(line 154 in Debian's 1.3.1-5 source) carries the same ten-character copy. I will mention it there separately. [read]Happy to open a pull request with the two-number change and an assertion in
test-001on the parsed mean motion.