SP3 Precise Orbit Files¶
The Extended Standard Product 3 (SP3) format is the exchange format for precise satellite orbits. A file holds a header followed by one block per epoch, with a position record, and optionally a velocity record, for each satellite. Positions are tabulated in an Earth-fixed frame, and the satellite clock correction and its uncertainties can accompany each state. Brahe reads versions a, b, c, and d of the format into an SP3 object and writes version d. The format is defined by the SP3-d specification, the SP3-c description, and the SP3-a description.
Reading a File¶
Output
SP3.from_file reads a plain-text file and SP3.from_str parses text already in memory. Both return the same object and raise a parse error when the file is malformed. sp3.record(satellite, epoch) returns the SP3Record of a satellite at an epoch, or None when the satellite has no usable position at that epoch. The satellite argument is an SP3SatelliteId or, in Python, a string such as "G01". In the example, the second epoch of G01 is None because the file tabulates the position as the format's bad-value marker 0.000000.
Compressed Files¶
IGS products are distributed as gzip files with a .gz suffix. SP3.from_file detects gzip data from the first bytes of the file, so the file name does not matter, and decompresses it before parsing; the result equals the object read from the plain file. SP3.from_bytes takes the contents of a file already held in memory, as plain text or a gzip or Unix compress stream, which is the entry point for data fetched over the network or read from an archive.
Output
to_file writes gzip when the path ends in .gz, in any letter case, and plain text otherwise. Files compressed with the Unix compress utility, which carry a .Z suffix and are common in older IGS archives, are read the same way as gzip files. Brahe does not write them.
Format and Versions¶
An SP3 file starts with a fixed set of header lines: the version, start epoch, epoch count, and coordinate system on the first line; the GPS week, epoch interval, and Modified Julian Day on the second line; the satellite list with per-satellite accuracy exponents; the time system and the standard deviation bases; and free-text comments. Epoch lines starting with * follow, each followed by a P position line per satellite, optional V velocity lines, and for versions c and d optional EP and EV correlation lines. The file ends with EOF. The version is the second character of the first line.
| Version | Satellites | Content |
|---|---|---|
| a | GPS only | Positions, optional velocities, clock corrections; time system fixed to GPS time |
| b | Multi-GNSS | Version a with a system letter on each satellite identifier |
| c | Up to 85 | Adds the time system label, standard deviation bases, the clock event, clock prediction, maneuver, and orbit prediction flags, and EP and EV correlation records; exactly four comment lines of up to 57 characters (columns 4-60) |
| d | Up to 999 | Version c with a three-digit satellite count field, at least five + lines and more above 85 satellites, an unlimited number of comment lines, and comments of up to 77 characters (columns 4-80) |
In version a the %c and %f placeholder lines carry no information, so the time system reads as GPS and a non-zero standard deviation base is an error.
SP3Version, SP3FileType, SP3TimeSystem, SP3OrbitType, and GNSSSystem represent the header labels. SP3FileType is the system letter of the first satellite line (G, R, E, C, J, I, S, L, or M for mixed), SP3OrbitType is FIT, EXT, BCT, or HLM, and any other label, such as BHN, PRO, or UKN, is kept as Other with the raw text. An SP3SatelliteId is a GNSSSystem and a number from 1 to 99 and prints as the three-character identifier, for example G01 or E11. A blank system character in the file is read as GPS.
Data Model and Units¶
An SP3 stores a header, the ascending list of epochs, the satellites in header order, and a dense table of optional records indexed by epoch and then satellite. sp3.header returns an SP3Header holding the fields of the header lines as read, sp3.epochs and sp3.satellite_ids return the two axes, and len(sp3) and satellite in sp3 follow the epoch and satellite axes. A table entry is None when the satellite is not listed at that epoch or when its position is the bad-value marker.
An SP3Record holds the position and, when the file carries them, the velocity, clock correction, clock rate, the standard deviations of each, the four flags (clock_event, clock_predicted, maneuver, orbit_predicted), and the EP and EV correlation records as SP3Correlation objects. A correlation coefficient left blank in the file is unknown and is stored as None, distinct from an explicit 0; the writer leaves it blank. A written coefficient must lie within \(\pm 0.9999999\). Every quantity on these objects is in SI units. The parser converts from the file units when reading and the writer converts back.
| Quantity | File unit | Stored unit |
|---|---|---|
| Position | km | m |
| Velocity | dm/s | m/s |
| Clock correction | \(\mu\)s | s |
| Clock rate | \(10^{-4}\ \mu\)s/s | s/s |
| Position standard deviation | \(b^n\) mm | m |
| Velocity standard deviation | \(b^n \times 10^{-4}\) mm/s | m/s |
| Clock standard deviation | \(b^n\) ps | s |
| Clock rate standard deviation | \(b^n \times 10^{-4}\) ps/s | s/s |
| Satellite accuracy | \(2^n\) mm | m |
A standard deviation is stored in the file as an exponent \(n\) of a base \(b\) declared on the %f header lines, so its value is \(b^n\) in the unit of the column. The header fields position_base and clock_base hold the two bases. An exponent of 99 for a position or velocity component, or 999 for a clock, marks an unbounded value and is stored as infinity. A blank exponent is stored as None. A clock value of 999999.999999 in the file is a missing clock and is stored as None.
The start epoch, epoch count, GPS week, seconds of week, MJD, and fractional day of the header lines follow from the epoch list, so SP3Header does not store them. sp3.start_epoch, sp3.num_epochs, sp3.gps_week, sp3.seconds_of_week, sp3.mjd, and sp3.fractional_day compute them from the first epoch, and the writer does the same. The four time values are None for a file with no epochs.
Time Systems¶
The %c header line names the time system of the epochs. SP3TimeSystem keeps the label, and to_time_system() maps it to the Brahe time scale for the same system.
| SP3 label | Brahe TimeSystem |
|---|---|
GPS | GPS |
GAL | GST |
BDT | BDT |
TAI | TAI |
UTC | UTC |
GLO, QZS, IRN | none |
Parsed epochs are Epoch objects constructed directly in the mapped time system, so no leap-second or scale conversion is applied while reading, and the epoch of a GPS-time file prints with the GPS suffix. A UTC file may carry an epoch inside a leap second, written with seconds from 60 to 61 as in 23:59:60.00000000; a second of 60 or more at any other time, or in any other time system, is rejected. A file whose label has no Brahe equivalent is rejected with an error of the form SP3: line 13: time system 'GLO' is not supported. The writer formats each epoch in the time system of the file and raises the same kind of error when the label has no mapping. Convert epochs to another scale with the Epoch methods after reading.
Coordinate Systems¶
The header stores the coordinate system label as read, for example IGS14, IGS20, WGS84, or ITRF14. Positions and velocities are Earth-fixed in the realization the label names. Brahe does not interpret the label; it is kept in SP3Header.coordinate_system and written back unchanged when it fits the 5-character SP3-d field. A longer label, such as ITRF14, must be shortened in the header before the file is written.
Parsing Details¶
The parser follows the line sequence the specification allows and reports the one-based line number of any error as SP3: line N: <detail>. The first line, the ## line, and the epoch lines are split on whitespace, which accepts files whose columns have shifted. The satellite, record, and flag fields use the specification's fixed columns.
The parser accepts the following deviations found in files from real producers.
| Deviation | Handling |
|---|---|
| Epoch fields of minute 60, hour 24, or day 0 | Carried into the next field |
Seconds with fewer digits than the specification, such as 0.1234 | Accepted |
Satellite identifier padding of 00 in place of 0 | Accepted |
| Coordinate system labels longer than five characters | Accepted, with later fields shifted |
| Empty agency field | Accepted |
Inconsistent ## line, such as GPS week 0 and MJD 0 | Ignored; the first line is authoritative |
136 satellites with exactly eight + lines | Accepted |
| Blank standard deviation exponents | Stored as None |
P and V lines ending before the clock field | Clock stored as None |
| Header declaring more satellites than appear at an epoch | Missing satellites stored as None |
| Orbit type labels outside the specification | Stored as Other |
| More comment lines than the header declares, or comments beyond the length limit | Accepted |
%/* comment lines and blank lines | Skipped |
EOF in any case, with trailing whitespace; content after EOF | Accepted and ignored |
Missing EOF when the epoch count matches the header | Accepted |
When a rollover is carried, a reading without the carry is used instead when it lies within one millisecond of the expected epoch, which covers producers that already carried into the next field.
The parser raises an error in these cases.
| Condition | Example message |
|---|---|
| Truncated record line | SP3: line 27: record truncated in columns 47-60 |
| Epoch count differing from the header | SP3: header declares 192 epochs but the file has 2 |
| Unknown line identifier | SP3: line 13: unrecognized line identifier '@@' |
| Unsupported version | SP3: line 1: unsupported version 'z' |
| Non-zero standard deviation base in a version a file | SP3: line 15: version a file declares a non-zero clock base 1.025 |
| Standard deviation exponent with no declared base in a version c or d file | SP3: line 24: clock standard deviation exponent but the %f line declares no clock base |
| Epoch interval of zero or less | SP3: line 2: epoch interval must be positive, got 0 |
| Epoch off the interval grid by more than one millisecond | SP3: line 37: epoch ... is not on the 900 s grid starting at ... |
| Time system without a Brahe equivalent | SP3: line 13: time system 'GLO' is not supported |
The parser does not enforce the comment count, comment length, or satellite count limits of the declared version listed in the version table. The writer always produces version d and enforces its limits: at most 999 satellites and comments of at most 77 characters.
Per-Satellite Data¶
sp3.satellite(id) extracts one satellite as an SP3Satellite, and sp3.satellites() extracts every satellite that has at least one valid sample, in header order. A sample is valid when the satellite has a record at that epoch with a non-zero position. satellite(id) raises an error for a satellite with no valid sample.
An SP3Satellite stores the epoch and the SP3Record of each valid sample, so the clock values, standard deviations, flags, and correlations of the file stay available. epochs() and records() return them, and positions(), velocities(), clocks(), and clock_rates() return one value per sample in m, m/s, s, and s/s. velocities() returns only the velocity records the file carries and derives nothing from the positions. In Python the positions and velocities are \(N \times 3\) NumPy arrays, and the velocity and clock arrays hold NaN where the file has no value. In Rust those accessors return Option values.
Orbit State Provider¶
An SP3Satellite is an orbit state provider with the same state_* and states_* methods as an OrbitTrajectory, named after its identifier, such as "G01". It can be passed to location_accesses and to any other function that takes an orbit state provider. A state is interpolated in ITRF with a Lagrange polynomial through the samples around the requested epoch, and state_gcrf, state_eci, and state_in_frame apply the Earth-orientation transforms. The velocity is interpolated from the velocity records when the samples of the fit have them, and is the derivative of the position polynomial otherwise.
The polynomial has degree 9, which fits 10 samples, unless another degree is set. sp3.interpolation_degree is the degree given to every satellite taken from the file, and interpolation_degree on an SP3Satellite (set_interpolation_degree and with_interpolation_degree in Rust) changes it for one satellite. A satellite with fewer samples than the degree needs uses all of them.
Output
The example computes access windows over a ground station in Boulder for the three satellites of a CODE final orbit file.
Gaps and Trajectories¶
SP3 files have a constant epoch interval, and a satellite that is absent at an epoch is written with a zero position, so missing data appears as missing samples. gaps() returns them: two consecutive valid samples more than 1.5 epoch intervals apart have a gap between them, reported as the last sample before it and the first sample after it. A satellite with zero positions at 10:15 and 10:30 in a 15-minute file has one gap, from 10:00 to 10:45.
A gap does not stop interpolation. A state inside one is fitted through the samples on both sides and loses accuracy as the gap grows: for a GPS orbit sampled every 15 minutes, the worst position error was 3 mm with one sample missing, 2 cm with two, 0.4 m with four, and 24 m with eight. Check gaps() when that matters. A state request before the first sample or after the last sample raises an error naming the satellite, as does any request to a satellite with a single sample.
to_trajectory() converts the samples to an OrbitTrajectory: a six-element Cartesian trajectory in the ITRF frame, named after the satellite, with Lagrange interpolation of the satellite's degree, or the number of samples less one for a satellite with fewer samples. The trajectory holds every sample and does not mark gaps. Call to_gcrf() on it for an inertial copy.
Interpolation Accuracy¶
The figures below are for a 900 s GPS orbit. The last row compares interpolated positions with the withheld 300 s samples of a real file.
| Samples | Position error | Velocity error |
|---|---|---|
| Exact positions, interior | 0.8 mm | \(2 \times 10^{-6}\) m/s |
| Positions at SP3 file precision (1 mm grid), interior | 1.4 mm | \(2.2 \times 10^{-6}\) m/s |
| Positions at SP3 file precision, within 4 samples of the first or last sample | 1.2 cm | \(1.4 \times 10^{-4}\) m/s |
| CODE final orbit subsampled from 300 s to 900 s, interior | 1.4 mm | Not measured |
Within four samples of the first or last sample the fit is one-sided and less accurate. Chaining the neighboring days around a span of interest places that span in the interior of the fit.
Chaining Files¶
SP3Satellite.from_files(files) builds one SP3Satellite per satellite across several SP3 objects and returns them in ascending identifier order. The files are sorted by start epoch, so they can be passed in any order, and each satellite collects its valid samples from every file that contains it. A file that lacks a satellite leaves a gap in that satellite. The satellites take the interpolation degree of the earliest file.
Output
The example chains three five-minute files. The first two files and the last two files each share a boundary epoch, so every satellite has four samples and no gap. Chaining the first file with a file that starts at 00:20 leaves a 15-minute gap, which gaps() reports.
The files must have the same epoch interval. Two consecutive files may share their boundary epoch, to within 1 ms, and the later file's sample is kept there when it is valid. Files that overlap by more than a shared boundary epoch raise an error naming the agency and span of both files. Time systems, coordinate system labels, agencies, and orbit types do not need to match, because epochs are absolute instants and every label maps to Brahe's single ITRF frame. No agreement check is applied at a boundary: daily fits from the same center can differ by centimeters there, and a change of ITRF realization or of analysis center adds a jump of its own.
Writing a File¶
Output
SP3(satellites, epoch_interval, header) creates an empty file with a fixed epoch grid. The SP3Header sets the agency, time system, coordinate system label, orbit type, data-used label, whether velocity records are written, and the comment lines; a default header is SP3-d in GPS time with agency BRHE, coordinate system IGS20, orbit type EXT, and data used ORBIT. The constructor sets the header's epoch interval and file type from its other arguments. set_record(satellite, epoch, record) stores an SP3Record for one satellite at an epoch, and set_epoch(epoch, records) stores the records of every satellite at an epoch in one call, leaving the satellites it does not list absent. Either call adds the epoch when the file does not hold it, in any order. Every epoch must lie on the grid anchored at the first epoch, to within one millisecond; grid points may be skipped. record(satellite, epoch) reads a record back. A satellite without a record at an epoch is written with the zero position and the missing-clock value that the format defines for absent data, and reads back as None.
to_string returns the file as SP3-d text with \n line endings, and to_file writes it to a path. The writer always produces version d, so a file read as version a, b, or c is upgraded when written. The writer reports an error when the file cannot be represented in SP3-d: a file with no epochs, more than 999 satellites, a satellite number outside 1 to 99, a time system without a Brahe equivalent, an epoch interval that rounds to zero or does not fit the 14-column ## field at eight decimal places, epochs that, rounded to the 1e-8 s resolution of the epoch lines, are out of order or off the grid of the interval as written, a comment longer than 77 characters, a header label longer than its field (agency 4, coordinate system 5, data used 5, and orbit type 3 characters; shorten it in the header before writing), a standard deviation base that is not finite and greater than 1 as written, a clock or clock rate that would read back as the missing-clock value, or a value that does not fit its field width.
Standard deviations are written only when the matching base is set in the header (position_base for position and velocity, clock_base for clock and clock rate). A standard deviation \(\sigma\), expressed in the column unit, is written as the exponent
computed with the base as written in the %f line. An infinite value, or an exponent that reaches 99 for a position or velocity component or 999 for a clock, is written as the unbounded marker, so the written standard deviation is never smaller than the stored one. Satellite accuracies are written as \(\lceil \log_2 \sigma_\mathrm{mm} \rceil\), at least 1, with an unknown accuracy written as 0. The first line of the file written above, #dV2024 11 10 0 0 0.00000000 3 ORBIT IGS20 EXT BRHE, shows the version d, the V flag for a file with velocity records, the start epoch, the epoch count, and the data-used, coordinate system, orbit type, and agency labels.
Building from Trajectories and Setting Clocks¶
SP3.from_trajectories(trajectories, step, header) builds a file from orbit trajectories. The trajectories argument is a list of satellite identifier and OrbitTrajectory pairs. A propagator supplies the trajectory it has propagated (propagator.trajectory), and an SP3Satellite supplies one with to_trajectory(), which resamples an existing file.
Without step, the file holds the epochs the trajectories store. The trajectories must then store the same epochs, to within 1 ms, on a regular grid whose interval is the spacing of the first two epochs. With step, each trajectory is interpolated at start + k * step over the span that all trajectories cover, from the latest first epoch to the earliest last epoch. Pass a step for trajectories from an adaptive-step propagator, whose stored epochs are not evenly spaced.
States are converted to ITRF, and velocities are stored when the header's has_velocity is set. The header argument is the same SP3Header the SP3 constructor takes. The file type follows the satellite systems: the system letter when all identifiers share one system, L for low Earth orbit satellites only, and M for mixed systems.
Output
The example propagates two satellites for an hour before building the file, because a numerical propagator answers state requests from the trajectory it has accumulated. The first ten lines printed are the header of the written file, which lists both satellites and declares 61 epochs at a 60 s interval.
from_trajectories takes no clock input, so clocks and clock rates are absent and are written as the missing-clock value 999999.999999. sp3.set_clocks(satellite, clocks) sets the clock correction of a satellite at every epoch of the file, in seconds, and sp3.set_clock_rates(satellite, rates) sets the clock rate in s/s. Both take one value per epoch, None clears the value at that epoch, and in Python NaN is treated as None, so the clocks() array of an SP3Satellite can be passed back directly. Clock rates are stored on velocity records, so set_clock_rates requires a file with velocity records. A call that fails, for example because the number of values differs from the number of epochs or a value is given where the satellite has no record, leaves the file unchanged.
See Also¶
- SP3 Library API -- Reference for
SP3and the related types - Epoch -- Time scales and epoch construction
- Access Computation -- Access windows for orbit state providers