A Python 3 module to read "Septentrio Binary Format" (SBF) files generated by Septentrio receivers, based on the work pysbf by Jashandeep Sohi.
- A C compiler (GCC preferred).
- Python 3.5+ (Make sure your C compiler can find the Python API
"Python.h"header file) - Cython
This repository is installed by:
pip install git+ssh://git@gitlab.cylab.be/gnss/py3sbf.gitThe repository can also be cloned for further development:
git clone git+ssh://git@gitlab.cylab.be/gnss/py3sbf.gitand installed in the local virtual environment by:
pip install -e .The initial package pysbf developed by Jashandeep Sohi was based on python v2. His release notes state:
- Up to 100x times faster parsing (than pure Python, thanks to Cython). Python module is written in C and complied for C-like speeds.
- All blocks documented in documentation v1.13.0 are now supported.
The basic function of the original package is to parse every block inside an SBF file into a map. Therefore, the dict built-in Python object is used to represent each block.
This py3sbf package updated the original package to be used with python v3, pysbf being a sub-package of py3sbf. It adds python scripts that converts specific SBF blocks to CSV files.
The following examples demonstrate the functioning os py3sbf package:
$ sbf_blocknames -h
usage: sbf_blocknames [-h] [-V] --sbf_ifn SBF_IFN
sbf_blocknames show SBF blocks in a SBF file.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--sbf_ifn SBF_IFN SBF filename
$ sbf_blocknames --sbf_ifn ./data/1342172q.24_
Block Name Counts:
PVTCartesian_v2: 36000
PVTGeodetic_v2: 36000
PosCovCartesian: 36000
PosCovGeodetic: 36000
VelCovCartesian: 36000
VelCovGeodetic: 36000
DOP_v2: 3600
BaseVectorGeod: 36000
BaseVectorCart: 36000
EndOfPVT: 3600
ChannelStatus: 3600
SatVisibility: 3600
AuxAntPositions: 3600
AttEuler: 3600
AttCovEuler: 3600
EndOfAtt: 3600
InputLink: 3600
OutputLink: 3600
ReceiverStatus_v2: 3600
PVTSupport: 3600
Commands: 1
ReceiverSetup: 1
GPSNav: 24
GPSIon: 81
GALNav: 85
GALIon: 1
GLONav: 27
DiffCorrIn: 3639
BaseStation: 118
GALUtc: 311
GALGstGps: 191
GPSUtc: 5$ sbf_azel.py -h
usage: sbf_azel [-h] [-V] --sbf_ifn SBF_IFN
sbf_azel decodes SVID, azimuth & elevation in a SBF file.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--sbf_ifn SBF_IFN SBF filename
$ sbf_azel --sbf_ifn ./data/1342172q.24_
Processing SBF file: ./data/1342172q.24_
Outputting Az/El data to CSV: ./data/1342172q-azel.csvThe pysbf sub-package offers the following function:
load(f_obj, blocknames=set())which returns an iterator/generator of SBF blocks where f_obj should be a file object.
By default, every type of block is generated, however most of the time only certain types of blocks are needed. This can be accomplished by providing a set of block names to the blocknames parameter.
Print the block name of the SBF-blocks:
import pysbf
with open('./dummy.sbf') as sbf_fobj:
for blockName, block in pysbf.load(sbf_fobj):
print blockNamePrint the azimuth & elevation for each visible satellite using the SatInfo sub-block of the SatVisibility block:
import pysbf
with open('./dummy.sbf') as sbf_fobj:
for blockName, block in pysbf.load(sbf_fobj, blocknames={'SatVisibility'}):
for satInfo in block['SatInfo']:
print satInfo['SVID'], satInfo['Azimuth'], satInfo['Elevation']Combine with matplotlib & numpy for plots. A simple plot of CPU load vs time using the first 100 ReceiverStatus blocks:
import matplotlib.pyplot as plt
import numpy as np
import pysbf as sbf
with open('./dummy.sbf') as sbf_fobj:
cpuload = ( '{} {}\n'.format(b['TOW'], b['CPULoad']) for bn, b in sbf.load(sbf_fobj, 100, {'ReceiverStatus_v2'}) )
data = np.loadtxt(cpuload)
plt.xlabel('Time (ms)')
plt.ylabel('CPU Load (%)')
plt.plot(data[:,0], data[:,1])
plt.show()