sinex

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: 8 Imported by: 0

README

Decode SINEX files

SINEX - Solution (Software/technique) INdependent EXchange Format

The format description is available at https://www.iers.org/IERS/EN/Organization/AnalysisCoordinator/SinexFormat/sinex.html.

So far decoding is implemented for the following blocks:

  • FILE/REFERENCE
  • SITE/ID
  • SITE/RECEIVER
  • SITE/ANTENNA
  • SOLUTION/ESTIMATE
Install
$ go get -u github.com/de-bkg/gognss
Decode estimates
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/de-bkg/gognss/pkg/sinex"
)

func main() {
	r, err := os.Open("path/to/sinexfile")
	if err != nil {
		log.Fatal(err)
	}
	defer r.Close()

	dec, err := sinex.NewDecoder(r)
	if err != nil {
		log.Fatal(err)
	}

	// Get the header
	hdr := dec.Header

	// Iterate over blocks.
	for dec.NextBlock() {
		name := dec.CurrentBlock()

		// Decode all SOLUTION/ESTIMATE records.
		if name == sinex.BlockSolEstimate {
			for dec.NextBlockLine() {
				var est Estimate
				if err := dec.Decode(&est); err != nil {
					log.Fatal(err)
				}

				// Do something with est.
				fmt.Printf("%s: %.5f\n", est.SiteCode, est.Value)
			}
		}
	}
}

Documentation

Index

Examples

Constants

View Source
const (
	BlockFileReference     = "FILE/REFERENCE"                  // Information on the Organization, point of contact, etc.
	BlockFileComment       = "FILE/COMMENT"                    // General comments about the SINEX data file.
	BlockInputHistory      = "INPUT/HISTORY"                   // Information about the source of the information used to create the current SINEX file.
	BlockInputFiles        = "INPUT/FILES"                     // Identify the input files.
	BlockInputAck          = "INPUT/ACKNOWLEDGEMENTS"          // Defines the agency codes contributing to the SINEX file.
	BlockNutationData      = "NUTATION/DATA"                   // VLBI: contains the nutation model used in the analysis procedure.
	BlockPrecessionData    = "PRECESSION/DATA"                 // VLBI: contains the precession model used in the analysis procedure.
	BlockSourceID          = "SOURCE/ID"                       // VLBI: contains information about the radio sources estimated in the analysis.
	BlockSiteID            = "SITE/ID"                         // General information for each site containing estimated parameters.
	BlockSiteData          = "SITE/DATA"                       // Relationship between the estimated station parameters and in the input files.
	BlockSiteReceiver      = "SITE/RECEIVER"                   // GNSS: The receiver used at each site during the observation period.
	BlockSiteAntenna       = "SITE/ANTENNA"                    // GNSS: The antennas used at each site during the observation period.
	BlockSiteGPSPhaseCen   = "SITE/GPS_PHASE_CENTER"           // GPS: phase center offsets for the antennas.
	BlockSiteGalPhaseCen   = "SITE/GAL_PHASE_CENTER"           // Galileo: phase center offsets for the antennas.
	BlockSiteEcc           = "SITE/ECCENTRICITY"               // Antenna eccentricities from the Marker to the Antenna Reference Point (ARP).
	BlockSatelliteID       = "SATELLITE/ID"                    // List of GNSS satellites used.
	BlockSatellitePhaseCen = "SATELLITE/PHASE_CENTER"          // GNSS satellite antenna phase center corrections.
	BlockSolEpochs         = "SOLUTION/EPOCHS"                 // List of solution epoch for each Site Code/Point Code/Solution Number/Observation Code (SPNO) combination.
	BlockBiasEpochs        = "BIAS/EPOCHS"                     // List of epochs of bias parameters for each Site Code/Point Code/Solution Number/Bias Type (SPNB) combination
	BlockSolStatistics     = "SOLUTION/STATISTICS"             // Statistical information about the solution.
	BlockSolEstimate       = "SOLUTION/ESTIMATE"               // The Estimated parameters.
	BlockSolApriori        = "SOLUTION/APRIORI"                // Apriori information for estimated parameters.
	BlockSolMatrixEst      = "SOLUTION/MATRIX_ESTIMATE"        // The estimate matrix.
	BlockSolMatrixApr      = "SOLUTION/MATRIX_APRIORI"         // The apriori matrix.
	BlockSolNormalEquVec   = "SOLUTION/NORMAL_EQUATION_VECTOR" // Vector of the right hand side of the unconstrained (reduced) normal equation.
)

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(in string, out Unmarshaler) error

Unmarshal in to out.

Types

type Antenna

type Antenna struct {
	SiteCode  SiteCode             // 4-char site code, e.g. WTZR.
	PointCode string               // A 2-char code identifying physical monument within a site.
	SolID     string               // Solution ID at a Site/Point code for which the parameter is estimated.
	ObsTech   ObservationTechnique // Technique(s) used to generate the SINEX solution.
	*gnss.Antenna
}

Antenna for GNSS.

func (*Antenna) UnmarshalSINEX

func (ant *Antenna) UnmarshalSINEX(in string) error

Unmarshall a SITE/ANTENNA record.

type Decoder

type Decoder struct {
	Header *Header
	// contains filtered or unexported fields
}

Decoder reads and decodes the SINEX input stream.

Example (Estimates)

Loop over the epochs of a observation data input stream.

r, err := os.Open("testdata/igs20P21161.snx")
if err != nil {
	log.Fatal(err)
}
defer r.Close()

dec, err := NewDecoder(r)
if err != nil {
	log.Fatal(err)
}

for dec.NextBlock() {
	name := dec.CurrentBlock()
	if name == BlockSolEstimate {
		for dec.NextBlockLine() {
			var est Estimate
			err := dec.Decode(&est)
			if err != nil {
				log.Fatal(err)
			}

			// Do something with est
			//fmt.Printf("%s: %.5f\n", est.SiteCode, est.Value)
		}
	}
}
Output:

func NewDecoder

func NewDecoder(r io.Reader) (*Decoder, error)

NewDecoder returns a new decoder that reads from r. The header line and FILE/REFERENCE block will be read implicitely.

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

func (*Decoder) CurrentBlock

func (dec *Decoder) CurrentBlock() string

Returns the name of the current block.

func (*Decoder) Decode

func (dec *Decoder) Decode(out Unmarshaler) error

Decode the current line into out.

func (*Decoder) GetFileReference

func (dec *Decoder) GetFileReference() FileReference

Return the FILE/REFERENCE data.

func (*Decoder) Line

func (dec *Decoder) Line() string

Line returns the current Line in buffer.

func (*Decoder) NextBlock

func (dec *Decoder) NextBlock() bool

NextBlock reports whether there is another block available and moves the reader to the begin of the this block. Use CurrentBlock() to get the name of the current block.

func (*Decoder) NextBlockLine

func (dec *Decoder) NextBlockLine() bool

NextBlockLine reports whether there is another data line in the current block and reads that line into the buffer. It returns false when reaching the end of the block.

type Estimate

type Estimate struct {
	Idx            int           // Index of estimated parameters, beginning with 1.
	ParType        ParameterType // The type of the parameter.
	SiteCode       SiteCode      // 4-char site code, e.g. WTZR.
	PointCode      string        // A 2-char code identifying physical monument within a site.
	SolID          string        // Solution ID at a Site/Point code for which the parameter is estimated.
	Epoch          time.Time     // Epoch at which the estimated parameter is valid.
	Unit           string        // Units used for the estimates and sigmas.
	ConstraintCode string        // Constraint code applied to the parameter.
	Value          float64       // Estimated value of the parameter.
	Stddev         float64       // Estimated standard deviation for the parameter.
}

Estimate stores the estimated solution parameters.

func (*Estimate) UnmarshalSINEX

func (est *Estimate) UnmarshalSINEX(in string) error

Unmarshall a SOLUTION/ESTIMATE record.

type FileReference

type FileReference struct {
	Description string // Organization(s).
	Output      string // File contents.
	Contact     string // Contact information.
	Software    string // SW used to generate the file.
	Hardware    string // Hardware on which above software was run.
	Input       string // Input used to generate this solution.
}

FileReference provides information on the Organization, point of contact, the software and hardware involved in the creation of the file.

type Header struct {
	Version            string               // Format version.
	Agency             string               // Agency creating the file.
	AgencyDataProvider string               // Agency providing the data in the file.
	CreationTime       time.Time            // Creation time of the file.
	StartTime          time.Time            // Start time of the data.
	EndTime            time.Time            // End time of the data.
	ObsTech            ObservationTechnique // Technique(s) used to generate the SINEX solution.
	NumEstimates       int                  // parameters estimated
	ConstraintCode     int                  // Single digit indicating the constraints:  0-fixed/tight constraints, 1-significant constraints, 2-unconstrained.
	SolutionTypes      []string             // Solution types contained in this SINEX file. Each character in this field may be one of the following:

}

Header containes the information from the SINEX Header line.

func (*Header) UnmarshalSINEX

func (hdr *Header) UnmarshalSINEX(in string) error

Unmarshall the header line.

type ObservationTechnique

type ObservationTechnique int

ObservationTechnique used to arrive at the solutions obtained in this SINEX file, e.g. SLR, GPS, VLBI. It should be consistent with the IERS convention.

const (
	ObsTechCombined ObservationTechnique = iota + 1
	ObsTechDORIS
	ObsTechSLR
	ObsTechLLR
	ObsTechGPS
	ObsTechVLBI
)

Observation techniques.

func (ObservationTechnique) String

func (techn ObservationTechnique) String() string

type ParameterType

type ParameterType string

ParameterType identifies the type of parameter.

const (
	ParameterTypeSTAX ParameterType = "STAX" // Station X coordinate in m.
	ParameterTypeSTAY ParameterType = "STAY" // Station Y coordinate in m.
	ParameterTypeSTAZ ParameterType = "STAZ" // Station Z coordinate in m.

)

type Receiver

type Receiver struct {
	SiteCode  SiteCode             // 4-char site code, e.g. WTZR.
	PointCode string               // A 2-char code identifying physical monument within a site.
	SolID     string               // Solution ID at a Site/Point code for which the parameter is estimated.
	ObsTech   ObservationTechnique // Technique(s) used to generate the SINEX solution.
	*gnss.Receiver
}

Receiver for GNSS.

func (*Receiver) UnmarshalSINEX

func (recv *Receiver) UnmarshalSINEX(in string) error

Unmarshall a SITE/RECEIVER record.

type Site

type Site struct {
	Code        SiteCode // 4-charID site code, e.g. WTZR.
	PointCode   string   // A 2-char code identifying physical monument within a site.
	DOMESNumber string
	ObsTech     ObservationTechnique // Technique(s) used to generate the SINEX solution.
	Description string               // Site description, e.g. city.
	Lon         string               // Longitude
	Lat         string               // Latitude
	Height      float64

	Receivers []*gnss.Receiver
	Antennas  []*gnss.Antenna
}

Site provides general information for each site. See also site.Site{}

func (*Site) UnmarshalSINEX

func (s *Site) UnmarshalSINEX(in string) error

Unmarshall a SITE/ID record.

type SiteCode

type SiteCode string

SiteCode is the site identifier, usually the FourCharID.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalSINEX(string) error
}

Jump to

Keyboard shortcuts

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