rinex

package
v0.0.0-...-0ddc927 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

rinex

Package rinex contains functions for reading RINEX Version 3 files.

Examples

package main

import (
	"log"

	"github.com/de-bkg/gognss/rinex"
)

func main() {
	r, _ := os.Open("testdata/white/REYK00ISL_R_20192701000_01H_30S_MO.rnx")
	defer r.Close()

	dec, _ := rinex.NewObsDecoder(r)
	for dec.NextEpoch() {
		epoch := dec.Epoch()
		// Do something with epoch
	}
	if err := dec.Err(); err != nil {
		log.Printf("read epochs: %v", err)
	}
}

Fromats see https://kb.igs.org/hc/en-us/articles/201096516-IGS-Formats

Documentation

Overview

Package rinex provides functions for reading RINEX files.

Index

Examples

Constants

View Source
const (
	// TimeOfClockFormat is the time format within RINEX-3 Nav records.
	TimeOfClockFormat string = "2006  1  2 15  4  5"

	// TimeOfClockFormatv2 is the time format within RINEX-2 Nav records.
	TimeOfClockFormatv2 string = "06  1  2 15  4  5.0"
)

Variables

View Source
var (
	// ErrNoHeader is returned when reading RINEX data that does not begin with a RINEX Header.
	ErrNoHeader = errors.New("rinex: no header")

	// ErrParser is returned on any RINEX parsing error.
	ErrParser = errors.New("rinex: parse error")
)

General RINEX errors.

View Source
var (
	// Rnx2FileNamePattern is the regex for RINEX2 filenames.
	Rnx2FileNamePattern = regexp.MustCompile(`(?i)(([a-z0-9]{4})(\d{3})([a-x0])(\d{2})?\.(\d{2})([domnglqfphs]))\.?([a-zA-Z0-9]+)?`)

	// Rnx3FileNamePattern is the regex for RINEX3 filenames.
	Rnx3FileNamePattern = regexp.MustCompile(`(?i)((([A-Z0-9]{4})(\d)(\d)([A-Z]{3})_([RSU])_((\d{4})(\d{3})(\d{2})(\d{2}))_(\d{2}[A-Z])_?(\d{2}[CZSMHDU])?_([GREJCISM][MNO]))\.(rnx|crx))\.?([a-zA-Z0-9]+)?`)
)

Functions

func Crx2rnx

func Crx2rnx(crxFilename string) (string, error)

Crx2rnx decompresses a Hatanaka-compressed RINEX obs file and returns the decompressed filename. The crxFilename must be a valid RINEX filename, RINEX v2 lowercase and RINEX v3 uppercase. see http://terras.gsi.go.jp/ja/crx2rnx.html

func GetCaseSensitiveName

func GetCaseSensitiveName(path string) string

Returns the RINEX filename with the correct case sensitivity. RINEX-3 long filenames must be uppercase except format, whereas RINEX-2 short names have to be lowercase.

func IsHatanakaCompressed

func IsHatanakaCompressed(filename string) bool

Returns true if the file giveb by filename is Hatanaka compressed. This is checked by the filenames' extension.

func ParseDoy

func ParseDoy(year, doy int) time.Time

ParseDoy returns the UTC-Time corresponding to the given year and day of year. Added in Go 1.13 !!!

func Rnx2Filename

func Rnx2Filename(rnx3filepath string) (string, error)

Rnx2Filename returns the filename following the RINEX2 convention.

func Rnx2crx

func Rnx2crx(rnxFilename string) (string, error)

Rnx2crx Hatanaka compresses a RINEX obs file (compact RINEX) and returns the compressed filename. The rnxFilename must be a valid RINEX filename. see http://terras.gsi.go.jp/ja/crx2rnx.html

func Rnx3Filename

func Rnx3Filename(rnx2filepath string, countryCode string) (string, error)

Rnx3Filename returns the RTCM RINEX-3 compliant filename for the given RINEX-2 file. The countryCode must be the 3 char ISO ?? code. Datasource as option!?

Example

Convert a RINEX 2 filename to a RINEX 3 one.

rnx2name, err := Rnx3Filename("testdata/white/brst155h.20o", "FRA")
if err != nil {
	log.Fatalln(err)
}
fmt.Println(rnx2name)
Output:

BRST00FRA_R_20201550700_01H_30S_MO.rnx

Types

type ClockDecoder

type ClockDecoder struct {
	// The Header is valid after NewClockDecoder or Reader.Reset. The header must exist,
	// otherwise ErrNoHeader will be returned.
	Header *ClockHeader
	// contains filtered or unexported fields
}

ClockDecoder reads and decodes from a RINEX Clock input stream.

func NewClockDecoder

func NewClockDecoder(r io.Reader) (*ClockDecoder, error)

NewClockDecoder returns a new RINEX clock decoder that reads from r. The RINEX header will be read implicitly. The header must exist.

It is the caller's responsibility to call Close on the underlying reader when done!

func (*ClockDecoder) Err

func (dec *ClockDecoder) Err() error

Err returns the first non-EOF error that was encountered by the decoder.

type ClockHeader

type ClockHeader struct {
	RINEXVersion float32     // RINEX Format version
	RINEXType    string      // RINEX File type
	SatSystem    gnss.System // Satellite System. System is "Mixed" if more than one.

	Pgm   string    // name of program creating this file
	RunBy string    // name of agency creating this file
	Date  time.Time // Date and time of file creation

	TimeSystemID   string     // Time system used for time tags, 3 char (GPS, GAL, UTC, TAI,...)
	AC             string     // Analysis Center as 3-character IGS AC designator
	NumSolnSats    int        // Number of different satellites in the clock data records.
	StaCoordinates []string   // List of stations/receivers with coordinates.
	Sats           []gnss.PRN // List of all satellites reported in this file (PRN LIST).

	Comments []string // comments
	Labels   []string // all Header Labels found
}

A ClockHeader stores the RINEX Clock Header information. That header is exposed as the fields of the Decoder and Encoder structs. TODO Parse all fields.

type ContentType

type ContentType int

The ContentType defines the content of a RINEX file.

const (
	ContentTypeObs ContentType = iota + 1 // Observation content.
	ContentTypeNav                        // Navigation content.
	ContentTypeMet                        // Meteo content.
)

func (ContentType) String

func (c ContentType) String() string

type Coord

type Coord struct {
	X, Y, Z float64
}

Coord defines a XYZ coordinate.

type CoordNEU

type CoordNEU struct {
	N, E, Up float64
}

CoordNEU defines a North-, East-, Up-coordinate or eccentrity

type DiffOptions

type DiffOptions struct {
	SatSys      string // satellite systems GRE...
	CheckHeader bool   // also compare the RINEX header
}

DiffOptions sets options for file comparison.

type Eph

type Eph interface {
	// Validate checks the ephemeris.
	Validate() error

	// Returns the ephemermis' PRN.
	GetPRN() gnss.PRN

	// Returns the ephemermis' time of clock (toc).
	GetTime() time.Time
}

Eph is the interface that wraps some methods for all types of ephemeris.

func NewEph

func NewEph(sys gnss.System) (Eph, error)

NewEph returns a new ephemeris having the concrete type.

type EphBDS

type EphBDS struct {
	PRN         gnss.PRN
	MessageType string // Navigation Message Type.

	// Clock
	TOC            time.Time // Time of Clock, clock reference epoch
	ClockBias      float64   // sc clock bias in seconds
	ClockDrift     float64   // sec/sec
	ClockDriftRate float64   // sec/sec2

	IODE   float64 // Issue of Data, Ephemeris
	Crs    float64 // meters
	DeltaN float64 // radians/sec
	M0     float64 // radians

	Cuc   float64 // radians
	Ecc   float64 // Eccentricity
	Cus   float64 // radians
	SqrtA float64 // sqrt(m)

	Toe    float64 // time of ephemeris (sec of GPS week)
	Cic    float64 // radians
	Omega0 float64 // radians
	Cis    float64 // radians

	I0       float64 // radians
	Crc      float64 // meters
	Omega    float64 // radians
	OmegaDot float64 // radians/sec

	IDOT    float64 // radians/sec
	L2Codes float64
	ToeWeek float64 // GPS week (to go with TOE) Continuous
	L2PFlag float64

	URA    float64 // SV accuracy in meters
	Health float64 // SV health (bits 17-22 w 3 sf 1)
	TGD    float64 // seconds
	IODC   float64 // Issue of Data, clock

	Tom         float64 // transmission time of message, seconds of GPS week
	FitInterval float64 // Fit interval in hours
}

EphBDS describes a chinese BDS ephemeris.

func (*EphBDS) GetPRN

func (eph *EphBDS) GetPRN() gnss.PRN

func (*EphBDS) GetTime

func (eph *EphBDS) GetTime() time.Time

func (EphBDS) Validate

func (EphBDS) Validate() error

type EphGAL

type EphGAL struct {
	PRN         gnss.PRN
	MessageType string // Navigation Message Type.

	// Clock
	TOC            time.Time // Time of Clock, clock reference epoch
	ClockBias      float64   // sc clock bias in seconds
	ClockDrift     float64   // sec/sec
	ClockDriftRate float64   // sec/sec2

	IODE   float64 // Issue of Data, Ephemeris
	Crs    float64 // meters
	DeltaN float64 // radians/sec
	M0     float64 // radians

	Cuc   float64 // radians
	Ecc   float64 // Eccentricity
	Cus   float64 // radians
	SqrtA float64 // sqrt(m)

	Toe    float64 // time of ephemeris (sec of GPS week)
	Cic    float64 // radians
	Omega0 float64 // radians
	Cis    float64 // radians

	I0       float64 // radians
	Crc      float64 // meters
	Omega    float64 // radians
	OmegaDot float64 // radians/sec

	IDOT    float64 // radians/sec
	L2Codes float64
	ToeWeek float64 // GPS week (to go with TOE) Continuous
	L2PFlag float64

	URA    float64 // SV accuracy in meters
	Health float64 // SV health (bits 17-22 w 3 sf 1)
	TGD    float64 // seconds
	IODC   float64 // Issue of Data, clock

	Tom float64 // transmission time of message, seconds of GPS week
}

EphGAL describes a Galileo ephemeris.

func (*EphGAL) GetPRN

func (eph *EphGAL) GetPRN() gnss.PRN

func (*EphGAL) GetTime

func (eph *EphGAL) GetTime() time.Time

func (EphGAL) Validate

func (EphGAL) Validate() error

type EphGLO

type EphGLO struct {
	PRN         gnss.PRN
	MessageType string // Navigation Message Type.
	TOC         time.Time
}

EphGLO describes a GLONASS ephemeris.

func (*EphGLO) GetPRN

func (eph *EphGLO) GetPRN() gnss.PRN

func (*EphGLO) GetTime

func (eph *EphGLO) GetTime() time.Time

func (EphGLO) Validate

func (EphGLO) Validate() error

type EphGPS

type EphGPS struct {
	PRN         gnss.PRN
	MessageType string // Navigation Message Type, LNAV etc., see RINEX 4 spec.

	// Clock
	TOC            time.Time // Time of Clock, clock reference epoch
	ClockBias      float64   // sc clock bias in seconds
	ClockDrift     float64   // sec/sec
	ClockDriftRate float64   // sec/sec2

	IODE   float64 // Issue of Data, Ephemeris
	Crs    float64 // meters
	DeltaN float64 // radians/sec
	M0     float64 // radians

	Cuc   float64 // radians
	Ecc   float64 // Eccentricity
	Cus   float64 // radians
	SqrtA float64 // sqrt(m)

	Toe    float64 // time of ephemeris (sec of GPS week)
	Cic    float64 // radians
	Omega0 float64 // radians
	Cis    float64 // radians

	I0       float64 // radians
	Crc      float64 // meters
	Omega    float64 // radians
	OmegaDot float64 // radians/sec

	IDOT    float64 // radians/sec
	L2Codes float64
	ToeWeek float64 // GPS week (to go with TOE) Continuous
	L2PFlag float64

	URA    float64 // SV accuracy in meters
	Health float64 // SV health (bits 17-22 w 3 sf 1)
	TGD    float64 // seconds
	IODC   float64 // Issue of Data, clock

	Tom         float64 // transmission time of message, seconds of GPS week
	FitInterval float64 // Fit interval in hours
}

EphGPS describes a GPS ephemeris.

func (*EphGPS) GetPRN

func (eph *EphGPS) GetPRN() gnss.PRN

func (*EphGPS) GetTime

func (eph *EphGPS) GetTime() time.Time

func (EphGPS) Validate

func (EphGPS) Validate() error

type EphNavIC

type EphNavIC struct {
	PRN         gnss.PRN
	MessageType string // EPH Navigation Message Type.
	TOC         time.Time
}

EphNavIC describes an indian IRNSS/NavIC ephemeris.

func (*EphNavIC) GetPRN

func (eph *EphNavIC) GetPRN() gnss.PRN

func (*EphNavIC) GetTime

func (eph *EphNavIC) GetTime() time.Time

func (EphNavIC) Validate

func (EphNavIC) Validate() error

type EphQZSS

type EphQZSS struct {
	PRN         gnss.PRN
	MessageType string // Navigation Message Type.

	// Clock
	TOC            time.Time // Time of Clock, clock reference epoch
	ClockBias      float64   // sc clock bias in seconds
	ClockDrift     float64   // sec/sec
	ClockDriftRate float64   // sec/sec2

	IODE   float64 // Issue of Data, Ephemeris
	Crs    float64 // meters
	DeltaN float64 // radians/sec
	M0     float64 // radians

	Cuc   float64 // radians
	Ecc   float64 // Eccentricity
	Cus   float64 // radians
	SqrtA float64 // sqrt(m)

	Toe    float64 // time of ephemeris (sec of GPS week)
	Cic    float64 // radians
	Omega0 float64 // radians
	Cis    float64 // radians

	I0       float64 // radians
	Crc      float64 // meters
	Omega    float64 // radians
	OmegaDot float64 // radians/sec

	IDOT    float64 // radians/sec
	L2Codes float64
	ToeWeek float64 // GPS week (to go with TOE) Continuous
	L2PFlag float64

	URA    float64 // SV accuracy in meters
	Health float64 // SV health (bits 17-22 w 3 sf 1)
	TGD    float64 // seconds
	IODC   float64 // Issue of Data, clock

	Tom         float64 // transmission time of message, seconds of GPS week
	FitInterval float64 // Fit interval in hours
}

EphQZSS describes a QZSS ephemeris.

func (*EphQZSS) GetPRN

func (eph *EphQZSS) GetPRN() gnss.PRN

func (*EphQZSS) GetTime

func (eph *EphQZSS) GetTime() time.Time

func (EphQZSS) Validate

func (EphQZSS) Validate() error

type EphSBAS

type EphSBAS struct {
	PRN         gnss.PRN
	MessageType string // EPH Navigation Message Type.
	TOC         time.Time
}

EphSBAS describes a SBAS payload.

func (*EphSBAS) GetPRN

func (eph *EphSBAS) GetPRN() gnss.PRN

func (*EphSBAS) GetTime

func (eph *EphSBAS) GetTime() time.Time

func (EphSBAS) Validate

func (EphSBAS) Validate() error

type Epoch

type Epoch struct {
	Time    time.Time // The epoch time.
	Flag    EpochFlag // The epoch flag 0:OK, 1:power failure between previous and current epoch, >1 : Special event.
	NumSat  uint8     // The number of satellites per epoch.
	ObsList []SatObs  // The list of observations per epoch.

}

Epoch contains a RINEX obs data epoch.

func (*Epoch) Print

func (epo *Epoch) Print()

Print pretty prints the epoch.

func (*Epoch) PrintTab

func (epo *Epoch) PrintTab(opts Options)

PrintTab prints the epoch in a tabular format.

type EpochFlag

type EpochFlag uint8

EpochFlag for indicating special occurrences during the tracking in RINEX observation files.

const (
	EpochFlagOK            EpochFlag = iota // 0: OK
	EpochFlagPowerFailure                   // 1: power failure between previous and current epoch
	EpochFlagMovingAntenna                  // 2: start moving antenna
	EpochFlagNewSite                        // 3: new site occupation (end of kinematic data) (at least MARKER NAME record follows)
	EpochFlagHeaderInfo                     // 4: header information follows
	EpochFlagExternalEvent                  // 5: external event (epoch is significant, same time frame as observation time tags)
	EpochFlagCycleSlip                      // 6: cycle slip records follow to optionally report detected and repaired cycle slips
)

func (EpochFlag) String

func (flag EpochFlag) String() string

type FilePeriod

type FilePeriod string

The FilePeriod specifies the intended (nominal) collection period of a file.

const (
	FilePeriodUnspecified FilePeriod = "00U"
	FilePeriod15Min       FilePeriod = "15M" // 15 minutes, usually for high-rate 1Hz files.
	FilePeriodHourly      FilePeriod = "01H"
	FilePeriodDaily       FilePeriod = "01D"
	FilePeriodYearly      FilePeriod = "01Y"
)

func (FilePeriod) Duration

func (p FilePeriod) Duration() time.Duration

Duration returns the duration of the file period.

type FilerHandler

type FilerHandler interface {

	// Rnx3Filename returns the filename following the RINEX3 convention.
	Rnx3Filename() (string, error)
}

FilerHandler is the interface for RINEX files..

func NewFile

func NewFile(filepath string) (FilerHandler, error)

NewFile returns a new RINEX file object.

type MetDecoder

type MetDecoder struct {
	// The Header is valid after NewMetDecoder or Reader.Reset. The header must exist,
	// otherwise ErrNoHeader will be returned.
	Header MeteoHeader
	// contains filtered or unexported fields
}

MetDecoder reads and decodes header and data records from a RINEX Meteo input stream.

func NewMetDecoder

func NewMetDecoder(r io.Reader) (*MetDecoder, error)

NewMetDecoder creates a new decoder for RINEX Meteo data. The RINEX header will be read implicitly. The header must exist.

It is the caller's responsibility to call Close on the underlying reader when done!

func (*MetDecoder) Epoch

func (dec *MetDecoder) Epoch() *MeteoEpoch

Epoch returns the most recent epoch generated by a call to NextEpoch.

func (*MetDecoder) Err

func (dec *MetDecoder) Err() error

Err returns the first non-EOF error that was encountered by the decoder.

func (*MetDecoder) NextEpoch

func (dec *MetDecoder) NextEpoch() bool

NextEpoch reads the observations for the next epoch. It returns false when the scan stops, either by reaching the end of the input or an error.

type MeteoEpoch

type MeteoEpoch struct {
	Time time.Time // The epoch time.
	Obs  []float64 // The observations in the same sequence as given in the header.
}

MeteoEpoch contains a RINEX meteo epoch.

type MeteoFile

type MeteoFile struct {
	*RnxFil
	Header *MeteoHeader
	Stats  *MeteoStats // Some Obersavation statistics.
}

MeteoFile contains fields and methods for RINEX Meteo files.

func NewMeteoFile

func NewMeteoFile(filepath string) (*MeteoFile, error)

NewMeteoFile returns a new RINEX Meteo file. The file must exist and the name will be parsed.

func (*MeteoFile) ComputeObsStats

func (f *MeteoFile) ComputeObsStats() (stats MeteoStats, err error)

ComputeObsStats reads the file and computes some statistics on the observations.

func (*MeteoFile) ReadHeader

func (f *MeteoFile) ReadHeader() (MeteoHeader, error)

Parse and return the Header lines.

func (*MeteoFile) Rnx3Filename

func (f *MeteoFile) Rnx3Filename() (string, error)

Rnx3Filename returns the filename following the RINEX3 convention.

type MeteoHeader

type MeteoHeader struct {
	RINEXVersion float32 // RINEX Format version
	RINEXType    string  // RINEX File type. O for Obs

	Pgm   string    // name of program creating this file
	RunBy string    // name of agency creating this file
	Date  time.Time // Date and time of file creation.

	MarkerName, MarkerNumber string // antennas' marker name, *number and type

	DOI          string   // Digital Object Identifier (DOI) for data citation i.e. https://doi.org/<DOI-number>.
	Licenses     []string // Line(s) with the data license of use. Name of the license plus link to the specific version of the license. Using standard data license as from https://creativecommons.org/licenses/
	StationInfos []string // Line(s) with the link(s) to persistent URL with the station metadata (site log, GeodesyML, etc).

	ObsTypes []MeteoObsType // The different observation types stored in the file.
	Sensors  []*MeteoSensor // Description of the meteo sensors.
	Comments []string
	Labels   []string // all Header Labels found.
}

A MeteoHeader provides the RINEX Meteo Header information.

type MeteoObsType

type MeteoObsType string

MeteoObsType is a meteorological observation type abbreviation PR, TD, etc.

type MeteoSensor

type MeteoSensor struct {
	Model           string       // Model (manufacturer).
	Type            string       // The type.
	Accuracy        float64      // Accuracy with same units as obs values.
	ObservationType MeteoObsType // The observation type.
	Position        Coord        // Approx. position of the sensor - Geocentric coordinates X, Y, Z (ITRF or WGS84).
	Height          float64      // Ellipsoidal height.
}

MeteoSensor describes a meteorological seonsor.

type MeteoStats

type MeteoStats struct {
	NumEpochs      int           `json:"numEpochs"`      // The number of epochs in the file.
	Sampling       time.Duration `json:"sampling"`       // The saampling interval derived from the data.
	TimeOfFirstObs time.Time     `json:"timeOfFirstObs"` // Time of the first observation.
	TimeOfLastObs  time.Time     `json:"timeOfLastObs"`  // Time of the last observation.
}

MeteoStats holds some statistics about a RINEX meteo file, derived from the data.

type NavDecoder struct {
	// The Header is valid after NewNavDecoder or Reader.Reset. The header must not necessarily exist,
	// e.g. if you want to read from a stream. Then ErrNoHeader will be returned.
	Header NavHeader
	// contains filtered or unexported fields
}

A NavDecoder reads and decodes header and data records from a RINEX Nav input stream.

Example (Loop)

Loop over the ephemerides of a input stream.

filepath := "testdata/white/AREG00PER_R_20201690000_01D_MN.rnx"
r, err := os.Open(filepath)
if err != nil {
	log.Fatalf("%v", err)
}
defer r.Close()

dec, err := NewNavDecoder(r)
if err != nil {
	log.Fatalf("%v", err)
}

nEph := 0
for dec.NextEphemeris() {
	nEph++
	eph := dec.Ephemeris()

	// Do something with eph
	_ = eph.Validate()
}
if err := dec.Err(); err != nil {
	log.Printf("reading epehmeris: %v", err)
}

fmt.Println(nEph)
Output:

3612

func NewNavDecoder

func NewNavDecoder(r io.Reader) (*NavDecoder, error)

NewNavDecoder creates a new decoder for RINEX Navigation data. The RINEX header will be read implicitly if it exists. The header must not exist, that is usful e.g. for reading from streams.

It is the caller's responsibility to call Close on the underlying reader when done!

func (dec *NavDecoder) Ephemeris() Eph

Ephemeris returns the most recent ephemeris generated by a call to NextEphemeris.

func (dec *NavDecoder) Err() error

Err returns the first non-EOF error that was encountered by the decoder.

func (dec *NavDecoder) NextEphemeris() bool

NextEphemeris reads the next Ephemeris into the buffer. It returns false when the scan stops, either by reaching the end of the input or an error.

TODO: read all values

type NavFile struct {
	*RnxFil
	Header *NavHeader
	Stats  *NavStats // Some statistics.
}

A NavFile contains fields and methods for RINEX navigation files and includes common methods for handling RINEX Nav files. It is useful e.g. for operations on the RINEX filename. If you do not need these file-related features, use the NavDecoder instead.

func NewNavFile

func NewNavFile(filepath string) (*NavFile, error)

NewNavFile returns a new Navigation File object. The file must exist and the name will be parsed.

func (f *NavFile) GetStats() (stats NavStats, err error)

GetStats reads the file and retuns some statistics.

func (f *NavFile) ReadHeader() (NavHeader, error)

Parse and return the Header lines.

func (f *NavFile) Rnx3Filename() (string, error)

Rnx3Filename returns the filename following the RINEX3 convention. TODO !!!

type NavHeader struct {
	RINEXVersion float32     // RINEX Format version
	RINEXType    string      // RINEX File type. N for Nav, O for Obs
	SatSystem    gnss.System // Satellite System. System is "Mixed" if more than one.

	Pgm   string    // name of program creating this file
	RunBy string    // name of agency creating this file
	Date  time.Time // Date and time of file creation.

	DOI          string   // Digital Object Identifier (DOI) for data citation i.e. https://doi.org/<DOI-number>.
	Licenses     []string // Line(s) with the data license of use. Name of the license plus link to the specific version of the license. Using standard data license as from https://creativecommons.org/licenses/
	StationInfos []string // Line(s) with the link(s) to persistent URL with the station metadata (site log, GeodesyML, etc).

	Comments    []string // Comment lines
	MergedFiles int      // The number of files merged, if any.

	Labels []string // all Header Labels found
}

A NavHeader containes the RINEX Navigation Header information. All header parameters are optional and may comprise different types of ionospheric model parameters and time conversion parameters.

type NavRecordType string

The NavRecordType specifies the Navigation Data Record Type introduced in RINEX Vers 4.

const (
	NavRecordTypeEPH NavRecordType = "EPH" // Ephemerides data including orbit, clock, biases, accuracy and status parameters.
	NavRecordTypeSTO NavRecordType = "STO" // System Time and UTC proxy offset parameters.
	NavRecordTypeEOP NavRecordType = "EOP" // Earth Orientation Parameters.
	NavRecordTypeION NavRecordType = "ION" // Global/Regional ionospheric model parameters.
)

The Navigation Data Record Types.

type NavStats struct {
	NumEphemeris    int          `json:"numEphemeris"`    // The number of epochs in the file.
	SatSystems      gnss.Systems `json:"systems"`         // The satellite systems contained.
	Satellites      []gnss.PRN   `json:"satellites"`      // The ephemeris' satellites.
	EarliestEphTime time.Time    `json:"earliestEphTime"` // Time of the earliest ephemeris.
	LatestEphTime   time.Time    `json:"latestEphTime"`   // Time of the latest ephemeris.
	Errors          error
}

NavStats holds some statistics about a RINEX nav file, derived from the data.

type Obs

type Obs struct {
	Val float64 // The observation itself.
	LLI int8    // LLI is the loss of lock indicator.
	SNR int8    // SNR is the signal-to-noise ratio.
}

Obs specifies a RINEX observation.

type ObsCode

type ObsCode string

ObsCode is the RINEX observation code that specifies frequency, signal and tracking mode like "L1C".

type ObsDecoder

type ObsDecoder struct {
	// The Header is valid after NewObsDecoder or Reader.Reset. The header must exist,
	// otherwise ErrNoHeader will be returned.
	Header ObsHeader
	// contains filtered or unexported fields
}

ObsDecoder reads and decodes header and data records from a RINEX Obs input stream.

Example (Loop)

Loop over the epochs of a observation data input stream.

filepath := "testdata/white/REYK00ISL_R_20192701000_01H_30S_MO.rnx"
r, err := os.Open(filepath)
if err != nil {
	log.Fatalf("%v", err)
}
defer r.Close()

dec, err := NewObsDecoder(r)
if err != nil {
	log.Fatalf("%v", err)
}

nEpochs := 0
for dec.NextEpoch() {
	nEpochs++
	_ = dec.Epoch()
	// Do something with epoch
}
if err := dec.Err(); err != nil {
	log.Printf("reading epochs: %v", err)
}

fmt.Printf("%d epochs found.", nEpochs)
Output:

120 epochs found.

func NewObsDecoder

func NewObsDecoder(r io.Reader) (*ObsDecoder, error)

NewObsDecoder creates a new decoder for RINEX Observation data. The RINEX header will be read implicitly. The header must exist.

It is the caller's responsibility to call Close on the underlying reader when done!

func (*ObsDecoder) Epoch

func (dec *ObsDecoder) Epoch() *Epoch

Epoch returns the most recent epoch generated by a call to NextEpoch.

func (*ObsDecoder) Err

func (dec *ObsDecoder) Err() error

Err returns the first non-EOF error that was encountered by the decoder.

func (*ObsDecoder) NextEpoch

func (dec *ObsDecoder) NextEpoch() bool

NextEpoch reads the observations for the next epoch. It returns false when the scan stops, either by reaching the end of the input or an error. TODO: add phase shifts

func (*ObsDecoder) SyncEpoch

func (dec *ObsDecoder) SyncEpoch() SyncEpochs

SyncEpoch returns the current pair of time-synchronized epochs from two RINEX Obs input streams.

type ObsFile

type ObsFile struct {
	*RnxFil
	Header *ObsHeader
	Opts   *Options
	Stats  *ObsStats // Some Obersavation statistics.
}

ObsFile contains fields and methods for RINEX observation files. Use NewObsFil() to instantiate a new ObsFile.

func NewObsFile

func NewObsFile(filepath string) (*ObsFile, error)

NewObsFile returns a new ObsFile. The file must exist and the name will be parsed.

func (*ObsFile) ComputeObsStats

func (f *ObsFile) ComputeObsStats() (stats ObsStats, err error)

ComputeObsStats reads the file and computes some statistics on the observations.

func (*ObsFile) Diff

func (f *ObsFile) Diff(obsFil2 *ObsFile) error

Diff compares two RINEX obs files.

func (*ObsFile) IsHatanakaCompressed

func (f *ObsFile) IsHatanakaCompressed() bool

IsHatanakaCompressed returns true if the obs file is Hatanaka compressed, otherwise false.

func (*ObsFile) ReadHeader

func (f *ObsFile) ReadHeader() (ObsHeader, error)

Parse and return the Header lines.

func (*ObsFile) Rnx3Filename

func (f *ObsFile) Rnx3Filename() (string, error)

Rnx3Filename returns the filename following the RINEX3 convention. In most cases we must read the read the header. The countrycode must come from an external source.

Example

Convert a filename from RINEX-2 to RINEX-3.

file, err := NewObsFile("testdata/white/brst155h.20o")
if err != nil {
	log.Fatalln(err)
}
file.CountryCode = "FRA"
file.DataSource = "R"

rnx3name, err := file.Rnx3Filename()
if err != nil {
	log.Fatalln(err)
}
fmt.Println(rnx3name)
Output:

BRST00FRA_R_20201550700_01H_30S_MO.rnx

type ObsHeader

type ObsHeader struct {
	RINEXVersion float32 // RINEX Format version
	RINEXType    string  // RINEX File type. O for Obs
	// The header satellite system. Note that system is "Mixed" if more than one. Use SatSystems() to get a list of all used systems.
	SatSystem gnss.System

	Pgm   string    // name of program creating this file
	RunBy string    // name of agency creating this file
	Date  time.Time // Date and time of file creation.

	Comments []string // * comment lines

	MarkerName   string // The name of the antenna marker, usually the 9-character station ID.
	MarkerNumber string // The IERS DOMES number assigned to the station marker is expected.
	MarkerType   string // Type of the marker. See RINEX specification. // TODO: make list.

	Observer, Agency string

	ReceiverNumber, ReceiverType, ReceiverVersion string
	AntennaNumber, AntennaType                    string

	Position     Coord    // Geocentric approximate marker position [m]
	AntennaDelta CoordNEU // North,East,Up deltas in [m]

	DOI          string   // Digital Object Identifier (DOI) for data citation i.e. https://doi.org/<DOI-number>.
	Licenses     []string // Line(s) with the data license of use. Name of the license plus link to the specific version of the license. Using standard data license as from https://creativecommons.org/licenses/
	StationInfos []string // Line(s) with the link(s) to persistent URL with the station metadata (site log, GeodesyML, etc).

	ObsTypes map[gnss.System][]ObsCode // List of all observation types per GNSS.

	SignalStrengthUnit string
	Interval           float64 // Observation interval in seconds
	TimeOfFirstObs     time.Time
	TimeOfLastObs      time.Time
	GloSlots           map[gnss.PRN]int // GLONASS slot and frequency numbers.
	LeapSeconds        int              // The current number of leap seconds
	NSatellites        int              // Number of satellites, for which observations are stored in the file

	Labels []string // all Header Labels found.
}

A ObsHeader provides the RINEX Observation Header information.

func (*ObsHeader) SatSystems

func (hdr *ObsHeader) SatSystems() []gnss.System

SatSystems returns all used satellite systems. The header must have been read before. For RINEX-2 files use SatSystem().

func (*ObsHeader) Write

func (hdr *ObsHeader) Write(w io.Writer) error

Write the header to w.

type ObsStats

type ObsStats struct {
	NumEpochs      int                          `json:"numEpochs"`      // The number of epochs in the file.
	NumSatellites  int                          `json:"numSatellites"`  // The number of satellites derived from the header.
	Sampling       time.Duration                `json:"sampling"`       // The sampling interval derived from the data.
	TimeOfFirstObs time.Time                    `json:"timeOfFirstObs"` // Time of the first observation.
	TimeOfLastObs  time.Time                    `json:"timeOfLastObs"`  // Time of the last observation.
	ObsPerSat      map[gnss.PRN]map[ObsCode]int `json:"obsstats"`       // Number of observations per PRN and observation-type.
}

ObsStats holds some statistics about a RINEX obs file, derived from the data.

type Options

type Options struct {
	SatSys string // satellite systems GRE... Why not gnss.System?
}

Options for global settings.

type RinexError

type RinexError struct {
	Err error

	// Additional information. This can have any type, mainly used struct, map or string.
	Meta any
}

A RinexError holds a warning or error that may occur during the processing a RINEX file. RinexError implements the error interface.

func (*RinexError) Error

func (e *RinexError) Error() string

RinexError implements the error interface.

func (*RinexError) Unwrap

func (e *RinexError) Unwrap() error

Unwrap returns the wrapped error, to allow interoperability with errors.Is(), errors.As() and errors.Unwrap()

type RnxFil

type RnxFil struct {
	Path string

	FourCharID     string     // The 4char ID of the file or site.
	MonumentNumber int        // The site monument number.
	ReceiverNumber int        // The site receiver number.
	CountryCode    string     // ISO 3char
	StartTime      time.Time  // StartTime is the nominal start time derived from the filename.
	DataSource     string     // [RSU]
	FilePeriod     FilePeriod // The intended collection period of the file.
	DataFreq       string     // 30S, not for nav files // TODO make type frequency!!
	DataType       string     // The data type abbreviations GO, RO, MN, MM, ...
	Format         string     // rnx, crx, etc. Attention: Format and Hatanaka are dependent!
	Compression    string     // gz, ...

	Warnings []string // List of warnings that might occur when reading the file.
}

RnxFil contains fields and methods that can be used by all RINEX file types. Usually you won't instantiate a RnxFil directly and use NewObsFil() and NewNavFileReader() instead. Both ObsFil and NavFile embed RnxFil.

func (*RnxFil) IsDaily

func (f *RnxFil) IsDaily() bool

Returns true if it is a daily file.

func (*RnxFil) IsHourly

func (f *RnxFil) IsHourly() bool

Returns true if it is a hourly file.

func (*RnxFil) IsMeteoType

func (f *RnxFil) IsMeteoType() bool

IsMeteoType returns true if the file is a RINEX meteo file type.

func (*RnxFil) IsNavType

func (f *RnxFil) IsNavType() bool

IsNavType returns true if the file is a RINEX navigation file type.

func (*RnxFil) IsObsType

func (f *RnxFil) IsObsType() bool

IsObsType returns true if the file is a RINEX observation file type.

func (*RnxFil) ParseFilename

func (f *RnxFil) ParseFilename() error

ParseFilename parses the specified filename, which must be a valid RINEX filename, and fills its fields.

func (*RnxFil) Rnx2Filename

func (f *RnxFil) Rnx2Filename() (string, error)

Rnx2Filename returns the filename following the RINEX2 convention.

func (*RnxFil) SetStationName

func (f *RnxFil) SetStationName(name string) error

SetStationName sets the station or project name. IGS users should follow XXXXMRCCC (9 char) site and station naming convention described above. GNSS industry users could use the 9 characters to indicate the project name and/or number.

func (*RnxFil) StationName

func (f *RnxFil) StationName() string

StationName returns the long 9-char station name if possible, otherwiese - mainly for RINEX-2 files - it returns the fourCharID. The returned name is uppercase.

type SatObs

type SatObs struct {
	Prn  gnss.PRN        // The satellite number or PRN.
	Obss map[ObsCode]Obs // A map of observations with the obs-code as key. L1C: Obs{Val:0, LLI:0, SNR:0}, L2C: Obs{Val:...},...
}

SatObs contains all observations for a satellite per epoch.

type SyncEpochs

type SyncEpochs struct {
	Epo1 *Epoch
	Epo2 *Epoch
}

SyncEpochs contains two epochs from different files with the same timestamp.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL