---
lang: zh-tw
tags: NCTU, Notes, Course, GPS
date: 20200501
robots: noindex, nofollow
---
RINEX 格式說明
===
本文是介紹 RINEX version 2.11,有關於更新的RINEX 3.xx,請見 [IGS Formats](https://kb.igs.org/hc/en-us/articles/201096516)。
基本架構
---
Receiver Independent Exchange Format (RINEX) 是一種與 GPS 接收儀廠牌無關的原始 GNSS 數據交換格式。這種格式並非 binary file (i.e., receiver dependent format),而以人類可閱讀的 ASCII code 呈現,因此使用者可以很方便地對數據進行後處理,以產生更精確的結果。
International GNSS Service (IGS) 提供[數種不同](http://www.igs.org/products#GPS)的 satellite ephemerides 和 satellite clocks 資料免費下載運用。有關於精密星曆 (final orbits i.e., '.sp3' file) 的內容與數據意義,在作業一已經做過了,因此就不再此贅述。
廣播星曆 (broadcast orbits and satellite clocks) 基本上可以直接透過 GPS 接收儀獲得,所以也許老師可以考慮把作業增加「架設接收儀並獲取資料」的內容 (笑)。另一種方法,當然就是尋求網路上的 open source data,因此 IGS 提供的 broadcast orbit product 跟直接用 GPS 接收儀觀測衛星訊號是兩件相同的事。
附註[^1] [^2] [^3] [^7]
[^1]: 如果比較想自己研究 RINEX 2.11,歡迎直接下載此 [specification](ftp://igs.org/pub/data/format/rinex211.txt)。
[^2]: 除了自己寫 code 讀資料,也推荐用 GPSTk、RTKLIB 或 GAMIT 來進行更高級的分析。
[^3]: 閱讀 RINEX 需要精確的計數字元數 (# of characters),建議選一個適當的 text editor 來開啟,個人推荐 Sublime Text、Vim、Notepad++,如果堅持使用 Microsoft Word 請承擔一定的風險會數錯,或是被軟體自動忽略某些字元。
[^7]: 有時候英文單字 "satellite" 會縮寫作 SV (i.e., space vehicle)
### RINEX 的組成
有鑑於目前隨便都可以收到幾十顆的導航衛星訊號,RINEX肯定不會只記錄 GPS 衛星訊號,因此 RINEX 2.11 由以下七個部分組成:
> 1. Observation Data
> 2. Navigation Message
> 3. Meteorological Data
> 4. GLONASS Navigation Message
> 5. GEO Navigation Message
> 6. Satellite and Receiver Clock Date
> 7. SBAS[^4] Broadcast Data
其中的 3~7 超出課程範圍,所以不再此敘述,詳細可以參考上面提到的 spec 文件內容。
附註[^5]
[^4]: SBAS a.k.a. space-based augmentation system
[^5]: 因為 RINEX 可能會隨著收到的衛星訊號很多,或是取樣間隔很短,而造成檔案容量爆炸大,所以近期有一些 ftp 會提供經過 Hatanaka compression scheme 壓縮過的 CRINEX。
#### Observation Data
1. 就是上課提到的 .o 檔,裡面包含 code pseudo range、carrier phase 和訊號 SNR 值,所以會看到例如:C1 (C/A code pseudo range) 或 P1、P2 (P code pseudo range) 或 L1、L2 (carrier phase)或S1、S2 (訊號 SNR) 等東西。
2. 下載點:[IGS MGEX Data](http://mgex.igs.org/IGS_MGEX_Data.php)
3. [檔案命名法](#RINEX-檔案命名法)
#### Navigation Message
1. 就是上課提到的 .n 檔,內含衛星向用戶廣播的訊息,包含:衛星時鐘參考時刻、衛星時鐘修正參數、6個克卜勒軌道係數、9個擾動係數等東西。用這些數值,我們可以計算出衛星在發送訊號當下的XYZ座標。
2. 下載點:[GNSS Broadcast ephemeris files](https://kb.igs.org/hc/en-us/articles/115003935351)
3. [檔案命名法](#RINEX-檔案命名法)
### RINEX 數據的定義
- time
- The time of the measurement is **the receiver time of the received signals**.
- It is identical for the phase and range measurements and is identical for all satellites observed at that epoch. It is expressed in GPS time (not UTC).
- pseudo range
- The pseudo range (PR) is **the distance from the receiver antenna to the satellite antenna** including receiver and satellite clock offsets (**and other biases**, such as atmospheric delays)
- $\mathrm{PR}=\mathrm{true\ distance}+\mathrm{c} \times (\mathrm{receiver\ clock\ offset}-\mathrm{satellite\ clock\ offset}+\mathrm{other\ biases})$
- PR reflects the actual behavior of the receiver and satellite clocks.
- PR is stored in units of meters.
- phase
- The phase is **the carrier-phase measured in whole cycles**.
- The half-cycles measured by squaring-type receivers must be converted to whole cycles and flagged by the wavelength factor in the header section (GPS only).
- The phase observations between epochs must be connected by including the integer number of cycles (i.e., integer ambiguity).
- **All of observations above are not corrected** for external effects like atmospheric refraction, satellite clock offsets, etc.
### RINEX 檔案命名法
假設今天我們拿到一個 RINEX 2.11 的檔案,其名稱為:`ssssdddf.yyt`
```
ssssdddf.yyt
| | | | |
| | | | +-- t: file type
| | | | O: Observation data
| | | | N: GPS Navigation message
| | | | M: Meteorological data
| | | | G: GLONASS Navigation message
| | | | L: Future Galileo Navigation
| | | | H: Geostationary GPS payload nav mess file
| | | | B: Geo SBAS broadcast data file (separate documentation)
| | | | C: Clock file (separate documentation)
| | | | S: Summary file (used e.g., by IGS, not a standard!)
| | | |
| | | +--- yy: two-digit year
| | |
| | +----- f: file sequence number/character within day
| | daily file: f = 0
| | hourly files:
| | f = a: 1st hour 00h-01h; f = b: 2nd hour 01h-02h; ...
| | f = x: 24th hour 23h-24h
| |
| +------- ddd: day of the year of first record
|
+----------- ssss: 4-character station name designator
```
- 一般會在 ftp 上面先下載到 `.Z` 結尾的壓縮檔,再使用解壓縮軟體解開即可
- [List of station names](http://www.igs.org/network)
- `cksv` 代表位在成功大學的「成大測量基準站」
- `brdc` 代表 broadcast ephemeris,在 IGN、GSSC 和 CDDIS 的資料庫是特殊保留縮寫
- 實際例子
- 2020/04/30的 observation data 檔案名稱是 `cksv1210.20o`
- 2007/02/05的 navigation message 檔案名稱是 `brdc0360.07n`
數值表示法
---
基本上類似[^6] [FORTRAN format](https://eml.berkeley.edu/sst/fmttop.html),以下舉幾個例子讓大家熟悉一下
- 變數類型的縮寫
- integer:`I`
- float:`F`
- Exponential:`D` (RINEX 用 base = 10,sp3 的 base 會給在其 header)
- Character:`A`
- Empty field:`X`
- 規則的白話文
- 如果有相同類型的變數連續出現,就直接在「變數類型」之前加上一個數字,代表重複幾次
- 如果要限制呈現固定長度的字元數,只需要在「變數類型」之後加上一個數字 (負號佔的位置要計入、正號不佔位置)
- 如果要標明小數點以下幾位,那就使用 `.m` 代表小數點位數 (不足補零)
- General Representation
- `In`:佔據 n 個字元的 integer,不足補空白鍵
- `Fn.m`:佔據 n 個字元的 floating point number,其小數點有 m 位
- `Dn.m`:佔據 n 個字元的科學記號數字,其小數點有 m 位,次方一律佔 2 個字元
- `An`:佔據 n 個字元的ASCII code,空白鍵 ` ` 也要算進去
- `nX`:佔據 n 個字元的空白鍵
- 實際範例 (以下使用 `#` 代表空白鍵方便閱讀)
- `2I6`:重複兩次,每次佔據六個字元的 integer
- 例如:`#12345699873` 代表 12345 和 699873 兩個 integer
- `I3.3`:一個佔據三個字元的 integer,**不足處補零**
- 例如:`023` 代表 23
- `7(4X,A1,A1)`:重複七次,每次為四個空白鍵 + 一個 ASCII code + 一個 ASCII code
- 例如:`####C1####P1####L1####S1####P2####L2####S2`
- `D12.4`:一個佔據十二個字元、具四位小數的 floating point
- 例如:`#−0.1966D+06` 代表 $-0.1966 \times 10^{6}$
[^6]: 這算是我個人困擾最久的部分,只要讀懂之後大概 spec 就沒什麼看不懂的了。除了 RINEX 有用這種表示法之外,精密星曆 `.sp3` 也有用到,再加上 spec 文件以及官方網站都沒有提及它到底是什麼意思,搞得好像某種機密編號之類的一樣,讓我瘋狂猜測到底在寫什麼 (怒)。
Observation Data 欄位與內容
---
資料可以分成兩大段:header、data record,以下用 `cksv1210.20o` 當作範例。
### Header
從 row 1 到 row 26,檔案內容如下:
```
2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE
teqc 2018Mar15 20200501 07:14:31UTCPGM / RUN BY / DATE
Solaris x86 5.10|AMD64|cc SC5.8 -xarch=amd64|=+|=+ COMMENT
teqc 2018Mar15 20200501 07:14:30UTCCOMMENT
teqc 2018Mar15 20200501 00:56:58UTCCOMMENT
Linux2.6.32-573.12.1.el6.x86_64|x86_64|gcc|Win64-MinGW64|=+ COMMENT
2.10 OBSERVATION DATA M (MIXED) COMMENT
TPP 4.1.3 29-APR-20 23:59 COMMENT
COMMENT
COMMENT
COMMENT
CKSV MARKER NAME
23606M002 MARKER NUMBER
geodesy@ga.gov.au Geoscience Australa OBSERVER / AGENCY
5922R40060 TRIMBLE ALLOY 5.44 REC # / TYPE / VERS
383-0108 TPSCR.G3 TPSH ANT # / TYPE
-2956619.1898 5075902.1717 2476625.5462 APPROX POSITION XYZ
0.0000 0.0000 0.0000 ANTENNA: DELTA H/E/N
1 1 WAVELENGTH FACT L1/2
7 C1 P1 L1 S1 P2 L2 S2 # / TYPES OF OBSERV
30.0000 INTERVAL
0 RCV CLOCK OFFS APPL
18 LEAP SECONDS
Forced Modulo Decimation to 30 seconds COMMENT
2020 4 30 0 0 0.0000000 GPS TIME OF FIRST OBS
END OF HEADER
```
針對以上文字分項介紹,並附上原始 spec 定義
- 這是一個 RINEX 2.11 observation data file,包含多種 GNSS 系統的衛星訊號
```
+--------------------+------------------------------------------+------------+
| HEADER LABEL | DESCRIPTION | FORMAT |
| (Columns 61-80) | | |
+--------------------+------------------------------------------+------------+
|RINEX VERSION / TYPE| - Format version (2.11) | F9.2,11X, |
| | - File type ('O' for Observation Data) | A1,19X, |
| | - Satellite System: 'G': GPS | A1,19X |
| | 'R': GLONASS | |
+--------------------+------------------------------------------+------------+
```
- 接收儀在 IGS network 登錄名稱為 `CKSV`
```
+--------------------+------------------------------------------+------------+
|MARKER NAME | Name of antenna marker | A60 |
+--------------------+------------------------------------------+------------+
```
- 接收儀天線的粗略座標值 (WGS84):$(-2956619.1898, 5075902.1717, 2476625.5462)$
```
+--------------------+------------------------------------------+------------+
|APPROX POSITION XYZ | Approximate marker position (WGS84) | 3F14.4 |
+--------------------+------------------------------------------+------------+
```
- 天線接收七種觀測量:C1、P1、P2、L1、L2、S1、S2
```
+--------------------+------------------------------------------+------------+
|# / TYPES OF OBSERV | - Number of different observation types | I6, |
| | stored in the file | |
| | - Observation types | |
| | - Observation code | 9(4X,A1, |
| | - Frequency code | A1)|
| | If more than 9 observation types: | |
| | Use continuation line(s) (including |6X,9(4X,2A1)|
| | the header label in cols. 61-80!) | |
| | | |
| | The following observation types are | |
| | defined in RINEX Version 2.11: | |
| | | |
| | Observation code (use uppercase only): | |
| | C: Pseudorange GPS: C/A, L2C | |
| | Glonass: C/A | |
| | P: Pseudorange GPS and Glonass: P code| |
| | L: Carrier phase | |
| | S: Raw signal strengths or SNR values | |
| | as given by the receiver for the | |
| | respective phase observations | |
| | | |
| | Frequency code | |
| | GPS Glonass | |
| | 1: L1 G1 | |
| | 2: L2 G2 | |
| | 5: L5 -- | |
| | | |
| | Observations collected under Antispoofing| |
| | are converted to "L2" or "P2" and flagged| |
| | with bit 2 of loss of lock indicator | |
| | (see Table A2). | |
| | | |
| | Units : Phase : full cycles | |
| | Pseudorange : meters | |
| | SNR etc : receiver-dependent | |
| | | |
| | The sequence of the types in this record | |
| | has to correspond to the sequence of the | |
| | observations in the observation records | |
+--------------------+------------------------------------------+------------+
```
- 接收儀每 30 秒觀測一次,第一筆觀測資料發生於 2020/04/30 的 00:00:00,整個檔案採用 GPS time
```
+--------------------+------------------------------------------+------------+
*|INTERVAL | Observation interval in seconds | F10.3 |*
+--------------------+------------------------------------------+------------+
|TIME OF FIRST OBS | - Time of first observation record | 5I6,F13.7, |
| | (4-digit-year, month,day,hour,min,sec) | |
| | - Time system: GPS (=GPS time system) | 5X,A3 |
| | GLO (=UTC time system) | |
| | Compulsory in mixed GPS/GLONASS files | |
| | Defaults: GPS for pure GPS files | |
| | GLO for pure GLONASS files | |
+--------------------+------------------------------------------+------------+
```
### Data Record
從 row 27 到 row 46 (1st epoch),檔案內容如下:
```
20 4 30 0 0 0.0000000 0 16G03G14G16G22G26G27G29G31G32R04R05R06
R15R16R17R18
23709244.219 124592893.807 4 38.000 23709253.641
97085442.269 7 31.900
20428084.773 107350280.901 6 46.400 20428091.180
83649605.134 8 37.200
21151619.086 111152487.587 6 45.700 21151625.926
86612360.691 8 34.300
23506532.367 123527613.784 5 40.900 23506537.340
96255335.940 6 22.000
20331612.602 106843279.166 7 48.800 20331622.988
83254583.019 9 51.400
24036964.695 126315097.917 3 35.900 24036976.242
98427398.932 7 30.400
23480386.539 123390171.577 5 39.800 23480394.496
96148290.820 6 22.800
21475315.375 112853524.596 6 46.000 21475322.320
87937846.687 9 46.100
21401519.281 112465772.950 6 46.300 21401528.906
87635691.106 8 37.900
```
針對以上文字分項介紹,並附上原始 spec 定義
- 這筆 epoch 發生在2020/04/30 的 00:00:00,總共偵測到 16 顆衛星訊號
- GPS:3、14、16、22、26、27、29、31、32
- GLONASS:4、5、6、15、16、17、18
```
+-------------+-------------------------------------------------+------------+
| EPOCH/SAT | - Epoch : | |
| or | - year (2 digits, padded with 0 if necessary) | 1X,I2.2, |
| EVENT FLAG | - month,day,hour,min, | 4(1X,I2), |
| | - sec | F11.7, |
| | | |
| | - Epoch flag 0: OK | 2X,I1, |
| | 1: power failure between | |
| | previous and current epoch | |
| | >1: Event flag | |
| | - Number of satellites in current epoch | I3, |
| | - List of PRNs (sat.numbers with system | 12(A1,I2), |
| | identifier, see 5.1) in current epoch | |
| | | |
| | If more than 12 satellites: Use continuation | 32X, |
| | line(s) | 12(A1,I2) |
+-------------+-------------------------------------------------+------------+
```
> 待補:
> 還剩 observation data record 的資料不知道怎麼解讀
Navigation Message 欄位與內容
---
資料可以分成兩大段:header、data record,以下用 `brdc0360.20o` 當作範例。
### Header
從 row 1 到 row 8,檔案內容如下:
```
2 NAVIGATION DATA RINEX VERSION / TYPE
CCRINEXN V1.6.0 UX CDDIS 06-FEB-20 18:31 PGM / RUN BY / DATE
IGS BROADCAST EPHEMERIS FILE COMMENT
0.8382D-08 -0.7451D-08 -0.5960D-07 0.5960D-07 ION ALPHA
0.8806D+05 -0.3277D+05 -0.1966D+06 0.1966D+06 ION BETA
0.931322574615D-09 0.177635683940D-14 503808 2091 DELTA-UTC: A0,A1,T,W
18 LEAP SECONDS
END OF HEADER
```
針對以上文字分項介紹,並附上原始 spec 定義
- 這是一個 RINEX 2.11 navigation message file
```
+--------------------+------------------------------------------+------------+
|RINEX VERSION / TYPE| - Format version (2.11) | F9.2,11X, |
| | - File type ('N' for Navigation data) | A1,19X |
+--------------------+------------------------------------------+------------+
```
- ION alpha 參數
- $A_0=0.8382{\times}10^{-8}$
- $A_1=-0.7451{\times}10^{-8}$
- $A_2=-0.596{\times}10^{-7}$
- $A_3=0.596{\times}10^{-7}$
```
+--------------------+------------------------------------------+------------+
*|ION ALPHA | Ionosphere parameters A0-A3 of almanac | 2X,4D12.4 |*
| | (page 18 of subframe 4) | |
+--------------------+------------------------------------------+------------+
```
- ION beta 參數
- $B_0=0.8806{\times}10^{5}$
- $B_1=-0.3277{\times}10^{5}$
- $B_2=-0.1966{\times}10^{6}$
- $B_3=0.1966{\times}10^{6}$
```
+--------------------+------------------------------------------+------------+
*|ION BETA | Ionosphere parameters B0-B3 of almanac | 2X,4D12.4 |*
+--------------------+------------------------------------------+------------+
```
### Data Record
從 row 9 到 row 16 (1st GPS satellite's 1st epoch),檔案內容如下:
```
1 20 2 5 0 0 0.0-0.284678302705D-03-0.121644916362D-10 0.000000000000D+00
0.940000000000D+02-0.113125000000D+03 0.410231373498D-08-0.218518345412D+00
-0.585429370403D-05 0.935216236394D-02 0.746548175812D-05 0.515364050484D+04
0.259200000000D+06 0.149011611938D-07-0.120496591830D+01 0.121071934700D-06
0.978618724358D+00 0.241875000000D+03 0.754856780232D+00-0.807783647431D-08
-0.192150860998D-09 0.100000000000D+01 0.209100000000D+04 0.000000000000D+00
0.200000000000D+01 0.000000000000D+00 0.558793544769D-08 0.940000000000D+02
0.252018000000D+06 0.400000000000D+01 0.000000000000D+00 0.000000000000D+00
```
針對以上文字分項介紹,並附上原始 spec 定義
- PRN一號的 GPS 衛星在 2020/02/05 的 00:00:00 發送這筆導航訊息
- Time of Clock (a.k.a. time of satellite's clock) 代表衛星上搭載的時鐘的時刻
- clock bias $a_0=-0.284678302705{\times}10^{-3}\ sec$
- clock drift $a_1=-0.121644916362{\times}10^{-10}\ sec/sec$
- clock drift rate $a_2=0\ sec/sec^2$
```
+--------------------+------------------------------------------+------------+
|PRN / EPOCH / SV CLK| - Satellite PRN number | I2, |
| | - Epoch: Toc - Time of Clock | |
| | year (2 digits, padded with 0 | |
| | if necessary) | 1X,I2.2, |
| | month | 1X,I2, |
| | day | 1X,I2, |
| | hour | 1X,I2, |
| | minute | 1X,I2, |
| | second | F5.1, |
| | - SV clock bias (seconds) | 3D19.12 |
| | - SV clock drift (sec/sec) | |
| | - SV clock drift rate (sec/sec2) | *) |
+--------------------+------------------------------------------+------------+
```
- 接下來的五行包含:六個克卜勒軌道係數、九個擾動係數;以下列表表示之,請自行對照原始檔案內容
- IDOE:issue of data, ephemeris
- TOE:time of ephemeris
| Column 1 | Column 2 | Column 3 | Column 4 |
| -------- | ------------------- | ------------- | -------------- |
| IDOE | Crs | $\Delta_n$ | $M_0$ |
| $C_{uc}$ | e | $C_{us}$ | $\sqrt{a}$ |
| TOE | $C_{ic}$ | $\Omega_0$ | $C_{is}$ |
| $i_0$ | $C_{rc}$ | $\omega$ | $\Omega_1$ |
| $i_1$ | codes on L2 channel | # of GPS week | L2 P data flag |
- 第六行、第七行因為與作業無關,所以可以暫且不看