Documentation
¶
Overview ¶
Package rinex provides functions for reading and writing RINEX files.
Index ¶
- Constants
- Variables
- func ParseDoy(year, doy int) time.Time
- func UnmarshalEph(data []byte, eph Eph) error
- type Coord
- type CoordNEU
- type DiffOptions
- type Eph
- type EphBDS
- type EphGAL
- type EphGLO
- type EphGPS
- type EphIRNSS
- type EphQZSS
- type EphSBAS
- type Epoch
- type NavDecoder
- type NavFile
- type NavHeader
- type Obs
- type ObsDecoder
- type ObsFil
- type ObsHeader
- type ObsStat
- type Options
- type PRN
- type RnxFil
- type SatObs
- type SatelliteSystem
- type SyncEpochs
Examples ¶
Constants ¶
const ( // TimeOfClockFormat is the time format within RINEX3 Nav records. TimeOfClockFormat string = "2006 1 2 15 4 5" )
Variables ¶
var ( // Rnx2FileNamePattern is the regex for RINEX2 filenames. Rnx2FileNamePattern = regexp.MustCompile(`(([a-z0-9]{4})(\d{3})([a-x0])(\d{2})?\.(\d{2})([domnglqfph]))\.?([a-zA-Z0-9]+)?`) // Rnx3FileNamePattern is the regex for RINEX3 filenames. Rnx3FileNamePattern = regexp.MustCompile(`((([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])?_([GREJCSM][MNO]))\.(rnx|crx))\.?([a-zA-Z0-9]+)?`) )
var ( // ErrNoHeader is returned when reading RINEX data that does not begin with a RINEX Header. ErrNoHeader = errors.New("RINEX: no header") )
errors
Functions ¶
func ParseDoy ¶
ParseDoy returns the UTC-Time corresponding to the given year and day of year. Added in Go 1.13 !!!
func UnmarshalEph ¶
UnmarshalEph parses the RINEX ephemeris given in lines and stores the result in the value pointed to by eph.
Types ¶
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 // contains filtered or unexported methods }
Eph is the interface that wraps some methods for all types of ephemeris.
func NewEph ¶
func NewEph(sys SatelliteSystem) Eph
NewEph returns a new ephemeris having the concrete type.
type EphGPS ¶
type EphGPS struct { PRN PRN // 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.
type NavDecoder ¶
type NavDecoder struct { // 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.
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 (*NavDecoder) Ephemeris ¶
func (dec *NavDecoder) Ephemeris() Eph
Ephemeris returns the most recent ephemeris generated by a call to NextEphemeris.
func (*NavDecoder) Err ¶
func (dec *NavDecoder) Err() error
Err returns the first non-EOF error that was encountered by the decoder.
func (*NavDecoder) NextEphemeris ¶
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.
If there is no header we suppose the format is RINEX3. TODO: read all values
type NavFile ¶
type NavFile struct {}
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 ¶
NewNavFile returns a new Navigation File object.
type NavHeader ¶
type NavHeader struct { // contains filtered or unexported fields }
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 Obs ¶
type Obs struct { Val float64 LLI int8 // loss of lock indicator SNR int8 // signal-to-noise ratio }
Obs specifies a RINEX observation.
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.Println(nEpochs)
Output: 120
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 ObsFil ¶
ObsFil contains fields and methods for RINEX observation files. Use NewObsFil() to instantiate a new ObsFil.
func (*ObsFil) Crx2rnx ¶
Crx2rnx decompresses a Hatanaka-compressed file. Crx2rnx returns the filepath of the decompressed file. see http://terras.gsi.go.jp/ja/crx2rnx.html
func (*ObsFil) IsHatanakaCompressed ¶
IsHatanakaCompressed returns true if the obs file is Hatanaka compressed, otherwise false.
func (*ObsFil) Rnx2crx ¶
Rnx2crx creates a copy of the file that is Hatanaka-compressed (compact RINEX). Rnx2crx returns the filepath of the compressed file. see http://terras.gsi.go.jp/ja/crx2rnx.html
type ObsHeader ¶
type ObsHeader struct { RINEXVersion float32 // RINEX Format version RINEXType string // RINEX File type. O for Obs SatSystem SatelliteSystem // 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 string // date and time of file creation TODO time.Time Comments []string // * comment lines MarkerName, MarkerNumber, MarkerType string // antennas' marker name, *number and type 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] ObsTypes map[string][]string SignalStrengthUnit string Interval float64 // Observation interval in seconds TimeOfFirstObs time.Time TimeOfLastObs time.Time LeapSeconds int // The current number of leap seconds NSatellites int // Number of satellites, for which observations are stored in the file // contains filtered or unexported fields }
A ObsHeader provides the RINEX Observation Header information.
type ObsStat ¶
type ObsStat struct { NumEpochs int `json:"numEpochs"` Sampling int `json:"sampling"` TimeOfFirstObs time.Time `json:"timeOfFirstObs"` TimeOfLastObs time.Time `json:"timeOfLastObs"` }
ObsStat stores observation statistics.
type Options ¶
type Options struct {
SatSys string // satellite systems GRE...
}
Options for global settings.
type PRN ¶
type PRN struct { Sys SatelliteSystem Num int8 // number }
PRN specifies a GNSS satellite.
type RnxFil ¶
type RnxFil struct { Path string FourCharID string MonumentNumber int ReceiverNumber int CountryCode string // ISO 3char StartTime time.Time DataSource string // [RSU] FilePeriod string // 15M, 01D 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, ... }
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) IsMeteoType ¶
IsMeteoType returns true if the file is a RINEX meteo file type.
func (*RnxFil) Rnx2Filename ¶
Rnx2Filename returns the filename following the RINEX2 convention.
Example ¶
Convert a RINEX 3 filename to a RINEX 2 filename.
file, err := NewFile("ALGO00CAN_R_20121601001_15M_01S_GO.rnx") if err != nil { log.Fatalln(err) } rnx2name, err := file.Rnx2Filename() if err != nil { log.Fatalln(err) } fmt.Println(rnx2name)
Output: algo160k00.12o
func (*RnxFil) Rnx3Filename ¶
Rnx3Filename returns the filename following the RINEX3 convention. The file must exist, as we must read the header. The countrycode must come from an external source. DO NOT USE! Must parse header first!
Example ¶
Convert a RINEX 2 filename to a RINEX 3 filename.
file, err := NewFile("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
func (*RnxFil) SetStationName ¶
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.
type SatelliteSystem ¶
type SatelliteSystem int
SatelliteSystem specifies a GNSS.
const ( SatSysGPS SatelliteSystem = iota + 1 SatSysGLO SatSysGAL SatSysQZSS SatSysBDS SatSysIRNSS SatSysSBAS SatSysMIXED )
Available Satellite Systems.
func (SatelliteSystem) Abbr ¶
func (sys SatelliteSystem) Abbr() string
Abbr returns the systems' abbreviation used in RINEX.
func (SatelliteSystem) String ¶
func (sys SatelliteSystem) String() string
type SyncEpochs ¶
SyncEpochs contains two epochs from different files with the same timestamp.