> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valar.space/llms.txt
> Use this file to discover all available pages before exploring further.

# SP3 (Standard Product 3)

> Working with IGS SP3 orbit and clock format in VALAR

> For the complete documentation index, see [llms.txt](/llms.txt).

The Standard Product 3 (SP3) format is an ASCII standard developed by the International GNSS Service (IGS) for distributing satellite orbit and clock correction data. Originally designed for GPS satellites, SP3-c (the current version) supports multiple GNSS constellations and LEO satellites, making it widely used for precise orbit ephemerides.

## Key Components

An SP3 file contains several distinct sections:

* **Header**: 22 lines of file-level metadata including version, time system, coordinate frame, satellite list, and accuracy information
* **Comments**: 4 optional comment lines for additional documentation
* **Epoch Blocks**: Repeating blocks containing position/clock records and optional velocity/correlation records
* **EOF Marker**: End-of-file indicator

## File Structure Overview

```
Header Lines (1-22)
├── Line 1: Version, start time, epochs, coordinate system, orbit type
├── Line 2: GPS week, seconds of week, epoch interval, MJD
├── Lines 3-7: Satellite identifiers (up to 85 satellites)
├── Lines 8-12: Orbit accuracy exponents
├── Line 13: File type and time system
├── Lines 15-16: Standard deviation base values
└── Lines 19-22: Comments

Data Section
├── Epoch Header (* YYYY MM DD HH MM SS.ssssssss)
├── Position Records (P)
├── Position Correlation Records (EP) [optional]
├── Velocity Records (V) [optional]
└── Velocity Correlation Records (EV) [optional]

EOF
```

## Header Fields

### Line 1: File Identification

| Columns | Field             | Description                                      |
| ------- | ----------------- | ------------------------------------------------ |
| 1-2     | Version           | `#c` for SP3-c format                            |
| 3       | P/V Flag          | `P` = position only, `V` = position and velocity |
| 4-31    | Start Time        | Year, month, day, hour, minute, second           |
| 33-39   | Epochs            | Number of epochs in file                         |
| 41-45   | Data Used         | Measurement type descriptor (e.g., `ORBIT`)      |
| 47-51   | Coordinate System | Reference frame (e.g., `ITR14`, `IGS14`)         |
| 53-55   | Orbit Type        | `FIT`, `EXT`, `BCT`, or `HLM`                    |
| 57-60   | Agency            | Producing agency identifier                      |

### Line 2: Time Reference

| Columns | Field           | Description                   |
| ------- | --------------- | ----------------------------- |
| 4-7     | GPS Week        | GPS week number               |
| 9-23    | Seconds of Week | 0.0 to 604800.0               |
| 25-38   | Epoch Interval  | Time between epochs (seconds) |
| 40-44   | MJD             | Modified Julian Day at start  |
| 46-60   | Fractional Day  | Decimal fraction of day       |

### Lines 3-7: Satellite Identifiers

Up to 85 satellites listed across 5 lines (17 per line). Each satellite uses a system identifier:

| Letter | System         |
| ------ | -------------- |
| G      | GPS            |
| R      | GLONASS        |
| E      | Galileo        |
| C      | BeiDou/COMPASS |
| J      | QZSS           |
| L      | LEO satellites |

### Line 13: File Type and Time System

| Columns | Field       | Values                                                                                     |
| ------- | ----------- | ------------------------------------------------------------------------------------------ |
| 4-5     | File Type   | `G` (GPS), `R` (GLONASS), `M` (mixed), `L` (LEO), `E` (Galileo), `C` (COMPASS), `J` (QZSS) |
| 10-12   | Time System | `GPS`, `GLO`, `GAL`, `TAI`, `UTC`, `QZS`                                                   |

## Data Records

### Position and Clock Record (P)

```
P G01  15000.123456  -5000.654321  20000.987654    123.456789  1  2  3  10
```

| Columns | Field                  | Units               |
| ------- | ---------------------- | ------------------- |
| 1       | Record Type            | `P`                 |
| 2-4     | Satellite ID           | System letter + PRN |
| 5-18    | X Position             | kilometers          |
| 19-32   | Y Position             | kilometers          |
| 33-46   | Z Position             | kilometers          |
| 47-60   | Clock Correction       | microseconds        |
| 62-63   | X Std Dev Exponent     | 2^nn mm             |
| 65-66   | Y Std Dev Exponent     | 2^nn mm             |
| 68-69   | Z Std Dev Exponent     | 2^nn mm             |
| 71-73   | Clock Std Dev Exponent | 2^nn ps             |

<Info>
  Bad or absent position values are set to `0.000000`. Bad or absent clock values are set to `999999.999999`.
</Info>

### Optional Flags (Position Record)

| Column | Flag             | Meaning                              |
| ------ | ---------------- | ------------------------------------ |
| 75     | Clock Event      | `E` = discontinuity, blank = normal  |
| 76     | Clock Prediction | `P` = predicted, blank = observed    |
| 79     | Maneuver         | `M` = orbit maneuver, blank = normal |
| 80     | Orbit Prediction | `P` = predicted, blank = observed    |

### Velocity and Clock Rate Record (V)

Only present when Line 1 P/V flag is `V`:

| Columns | Field        | Units                     |
| ------- | ------------ | ------------------------- |
| 1       | Record Type  | `V`                       |
| 2-4     | Satellite ID | System letter + PRN       |
| 5-18    | X Velocity   | decimeters/second         |
| 19-32   | Y Velocity   | decimeters/second         |
| 33-46   | Z Velocity   | decimeters/second         |
| 47-60   | Clock Rate   | 10^-4 microseconds/second |

### Correlation Records (EP, EV)

Optional high-precision correlation records provide:

* Standard deviations in physical units (mm for position, mm/s for velocity)
* Six correlation coefficients (xy, xz, xc, yz, yc, zc) scaled by 10^7

## Supported Time Systems

| Code | Time System                |
| ---- | -------------------------- |
| GPS  | GPS Time                   |
| GLO  | GLONASS UTC                |
| GAL  | Galileo System Time        |
| TAI  | International Atomic Time  |
| UTC  | Coordinated Universal Time |
| QZS  | QZSS Time                  |

<Warning>
  All times in an SP3 file use the SAME time system, whether expressed as Gregorian dates or Modified Julian Dates.
</Warning>

## Common Use Cases

* **Precise Point Positioning (PPP)**: High-accuracy GNSS positioning using precise orbits
* **Orbit Comparison**: Validating orbit determination results against IGS products
* **LEO Satellite Tracking**: Distributing precise orbits for Earth observation satellites
* **Clock Analysis**: Satellite clock characterization and time transfer
* **Geodetic Research**: Reference frame determination and geophysical studies

## Sample SP3-c File

```
#cP2024 12 15  0  0  0.00000000      96 ORBIT IGS14 FIT  IGS
## 2341 518400.00000000   900.00000000 60658 0.0000000000000
+   32   G01G02G03G04G05G06G07G08G09G10G11G12G13G14G15G16G17
+        G18G19G20G21G22G23G24G25G26G27G28G29G30G31G32  0  0
+          0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
+          0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
+          0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
++         2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2
++         2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  0  0
++         0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
++         0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
++         0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
%c G  cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%f  1.2500000  1.025000000  0.00000000000  0.000000000000000
%f  0.0000000  0.000000000  0.00000000000  0.000000000000000
%i    0    0    0    0      0      0      0      0         0
%i    0    0    0    0      0      0      0      0         0
/* IGS FINAL ORBIT COMBINATION FROM WEIGHTED AVERAGE OF:
/* cod emr esa gfz grg jpl mit ngs sio
/* REFERENCED TO IGS TIME (IGST) AND target/IGS14
/* CLK ANT Z-OFFSET (M): II/IIA 1.023; IIR 0.000
*  2024 12 15  0  0  0.00000000
PG01  15234.123456  -8234.654321  19876.987654    123.456789
PG02  12456.789012   5678.901234  22345.678901    -45.678901
PG03  -8765.432109  18765.432109  14567.890123    234.567890
EOF
```

## Technical References

* [IGS SP3-c Format Specification](https://files.igs.org/pub/data/format/sp3c.txt)
* [IGS Products](https://igs.org/products/)
* [ITRF Reference Frames](https://itrf.ign.fr/)
