Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ This repository contains a Python script that converts logs from Google's GNSS
measurement tools to RINEX. It was originally forked from
https://github.com/rokubun/android_rinex but has been substantially modified.

See gnslogger_to_rnx.py for sample usage and a list of command line options
See gnslogger_to_rnx.py for sample usage and a list of command line options.

`rtklibexplorer`'s fork has been modified in `plutonheaven`'s fork to use the code as a package in another project.

To do so, add the following line to your projects `pyproject.toml`:
```
dependencies = [
...
"android_rinex==0.1.0",
]

[tool.uv.sources]
android_rinex = { git = "https://github.com/plutonheaven/android_rinex", branch = "master" }
```
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "android_rinex"
version = "0.1.0"
requires-python = ">=3.8"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
where = ["src"]
Empty file added src/android_rinex/__init__.py
Empty file.
8 changes: 6 additions & 2 deletions src/gnsslogger.py → src/android_rinex/gnsslogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,9 @@ def get_glo_freq_chn_list(batches):

if sat not in freq_chn_list:
freq = get_frequency(measurement)
freq_chn = round((freq -FREQ1_GLO ) / DFREQ1_GLO)
freq_chn_list[sat] = freq_chn
if freq != 1575420000:
freq_chn = round((freq -FREQ1_GLO ) / DFREQ1_GLO)
freq_chn_list[sat] = freq_chn

return freq_chn_list

Expand Down Expand Up @@ -671,6 +672,9 @@ def process(measurement, model, fix_bias=True, timeadj=1e-7, pseudorange_bias=0.
raise ValueError("-- WARNING: Invalid value of TimeNanos or satellite [ {0} ]\n".format(satname))


if fullbiasnanos == "":
return None

# Compute the GPS week number and reception time (i.e. clock epoch)
gpsweek = math.floor(-fullbiasnanos * NS_TO_S / GPS_WEEKSECS)
local_est_GPS_time = timenanos - (fullbiasnanos + biasnanos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
"""
Tool to convert from logfile of GPS-measurements to RINEX format

Usage: gnsslogger_to_rnx logfile <options>
Let us assume the following folder structure:
android_rinex/
├── data/
│ └── gnss_log.txt/
└── src/
└── android_rinex/
├── gnsslogger_to_rnx.py

Usage from the root folder:
> python -m src.android_rinex.gnsslogger_to_rnx logfile <options>

Example using sample data file:

gnsslogger_to_rnx ../data/gnss_log.txt
> python -m src.android_rinex.gnsslogger_to_rnx data/gnss_log.txt

See main() below for a list of command line options
"""

import argparse
import os, sys

import gnsslogger as alogger
import rinex3 as arinex
from . import gnsslogger as alogger
from . import rinex3 as arinex


def convert2rnx(args):
Expand Down Expand Up @@ -76,7 +84,7 @@ def convert2rnx(args):
rec_version=args.receiver_version,
antenna=args.antenna_number,
ant_type=args.antenna_type,
pos=[0.0, 0.0, 0.0],
pos=args.pos,
hen=[0.0, 0.0, 0.0],
glo_slot_freq_chns=glo_freq_chns,
glo_cod_phs_bis=glo_cod_phs_bis)
Expand All @@ -93,7 +101,7 @@ def convert2rnx(args):
fh.write(header + body)
#print(args.output, outFile)

#sys.stderr.close()
sys.stderr.close()


if __name__ == "__main__":
Expand Down
32 changes: 19 additions & 13 deletions src/rinex3.py → src/android_rinex/rinex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def __write_rnx3_header_firstobs__(epoch):
TAIL = "TIME OF FIRST OBS"

res = epoch.strftime(" %Y %m %d %H %M %S.") + \
'{0:06d}0'.format(int(epoch.microsecond))

'{0:06d}'.format(int(epoch.microsecond))
res += " GPS"
res = "{0:60s}{1}\n".format(res, TAIL)
return res

Expand All @@ -191,8 +191,8 @@ def __write_rnx3_header_lastobs__(epoch):
TAIL = "TIME OF LAST OBS"

res = epoch.strftime(" %Y %m %d %H %M %S.") + \
'{0:06d}0'.format(int(epoch.microsecond))

'{0:06d}'.format(int(epoch.microsecond))
res += " GPS"
res = "{0:60s}{1}\n".format(res, TAIL)

return res
Expand All @@ -214,21 +214,27 @@ def __write_rnx3_header_glo_slot_frq_chn__(glo_slot_freq_chns):
# Gets the number of satellites in the list
num_sats = len(glo_slot_freq_chns)

# Number of satellites in list
# list of lines
res_list = []

# First line begins with number of satellites in list
res = "{0:3d} ".format(num_sats)

# Satellite numbers + frequency numbers
# Loop on satellite numbers + frequency numbers
for sat in glo_slot_freq_chns:

res += "{0:3s} {1:2d} ".format(sat, glo_slot_freq_chns[sat])
if len(res) == 60:
res += "{0:60s}{1}\n".format(res, TAIL)
res += " "

# Tail specs
res = "{0:60s}{1}\n".format(res, TAIL)

return res
# add tail and add current line to list
res_list.append("{0:60s}{1}\n".format(res, TAIL))
# start a new line
res = " "

# Add current line to list if not empty
if res != " ":
res_list.append("{0:60s}{1}\n".format(res, TAIL))

return "".join(res_list)

# -----------------------------------------------------------------------------

Expand Down