Skip to content

alainmuls/py3sbf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module py3sbf

A Python 3 module to read "Septentrio Binary Format" (SBF) files generated by Septentrio receivers, based on the work pysbf by Jashandeep Sohi.

Dependencies

Required:

  • A C compiler (GCC preferred).
  • Python 3.5+ (Make sure your C compiler can find the Python API "Python.h" header file)
  • Cython

Installation

This repository is installed by:

pip install git+ssh://git@gitlab.cylab.be/gnss/py3sbf.git

The repository can also be cloned for further development:

git clone git+ssh://git@gitlab.cylab.be/gnss/py3sbf.git

and installed in the local virtual environment by:

pip install -e .

Release Notes

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.

Functions of py3sbf

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.csv

Functions of original pysbf

The 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.

Examples of original pysbfpackage

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 blockName

Print 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()

About

Parses SBF messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors