observation

package
v0.18.21 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeAvailabilityByWindow added in v0.18.20

func ComputeAvailabilityByWindow(stationID string, epochs []Epoch, cfg AvailabilityConfig) map[time.Duration][]*Availability

ComputeAvailabilityByWindow processes epochs and returns availability per window size.

func FormatFrequencyBand

func FormatFrequencyBand(system gnss.System, freq FrequencyBand) (string, error)

FormatFrequencyBand returns the code representation of the FrequencyBand for the given GNSS system.

func FormatObservationKey

func FormatObservationKey(system gnss.System, signal ObservationKey) (string, error)

FormatObservationKey returns a string representation of the GNSS signal.

Types

type Availability added in v0.18.20

type Availability struct {
	Id                     string
	StartTime              time.Time
	EndTime                time.Time
	FirstEpochTime         time.Time // ✅ NEW: actual first epoch in window
	LastEpochTime          time.Time // ✅ NEW: actual last epoch in window
	EpochCount             int
	ExpectedEpochCount     int
	SatelliteMasks         map[gnss.System]uint64
	UniqueSatellites       map[gnss.System]int
	AvgObsPerEpoch         float64
	ObsCount               int
	MaxGapDuration         time.Duration
	GapsExceedingThreshold int
	// contains filtered or unexported fields
}

Availability contains metrics computed over a time window.

func NewAvailability added in v0.18.20

func NewAvailability(id string, start time.Time, duration time.Duration) *Availability

NewAvailability initializes an Availability instance.

func (*Availability) IsSatelliteAvailable added in v0.18.20

func (a *Availability) IsSatelliteAvailable(system gnss.System, svID int) bool

IsSatelliteAvailable returns true if a satellite was seen in this window.

func (*Availability) ToRecord added in v0.18.20

func (a *Availability) ToRecord() map[string]any

ToRecord flattens availability into a serializable record.

type AvailabilityConfig added in v0.18.20

type AvailabilityConfig struct {
	SampleInterval time.Duration   // Expected epoch interval
	GapTolerance   time.Duration   // Maximum allowed gap before counting it
	WindowSizes    []time.Duration // Multiple aggregation windows
}

AvailabilityConfig defines how availability should be computed.

type Epoch

type Epoch struct {
	Time                   time.Time     `json:"time"`
	ReceiverClockOffset    time.Duration `json:"receiver_clock_offset"`
	ClockSteeringIndicator int           `json:"clock_steering_indicator"`
	ExternalClockIndicator int           `json:"external_clock_indicator"`
	SmoothingIndicator     int           `json:"smoother_indicator"`
	SmoothingInterval      int           `json:"smoother_interval"`
	EpochFlag              EpochFlag     `json:"epoch_flag"`
	Event                  string        `json:"event"`
	Satellites             SatelliteMap  `json:"satellites"`
}

Epoch is a struct containing the observations

func CombineEpochs

func CombineEpochs(epochs ...Epoch) (Epoch, error)

CombineEpochs merges multiple Epoch instances into a single Epoch if their times match. This function checks if all provided epochs have the same time and combines them only if they do. It concatenates the observation slices from all matching epochs.

Parameters:

  • epochs ...Epoch: A variadic slice of Epoch structs to be combined.

Returns:

  • Epoch: A single Epoch struct containing all observations from the input epochs with matching times.
  • error: An error if the epoch times do not match or if no epochs are provided.

Example:

epoch1 := Epoch{Time: time.Now(), Observations: []Observation{{Sys: gnss.SystemGPS, SvID: 1, Code: "1C"}}}
epoch2 := Epoch{Time: epoch1.Time, Observations: []Observation{{Sys: gnss.SystemGPS, SvID: 2, Code: "1C"}}}
combinedEpoch, err := CombineEpochs(epoch1, epoch2)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(len(combinedEpoch.Observations)) // Output: 2
}

Note: Only combines epochs with exactly matching times.

func NewEpoch

func NewEpoch() Epoch

func (*Epoch) AddObservation

func (e *Epoch) AddObservation(o Observation) error

AddObservation adds an observation to the Epoch.

func (Epoch) FindObservation

func (e Epoch) FindObservation(satKey SatelliteKey, obsKey ObservationKey) (Observation, error)

FindObservation finds an observation in the Epoch.

func (Epoch) FindSatellite

func (e Epoch) FindSatellite(satKey SatelliteKey) (ObservationMap, error)

FindSatellite finds the ObservationMap for a given satellite in the Epoch.

func (*Epoch) GPSTimeOfWeekMs

func (e *Epoch) GPSTimeOfWeekMs() int

GPSTimeOfWeekMs returns the number of milliseconds into the current GPS week

func (*Epoch) GPSTimeOfWeekSec

func (e *Epoch) GPSTimeOfWeekSec() float64

GPSTimeOfWeekSec returns the number of seconds into the current GPS week as float64

func (*Epoch) GetSystems

func (e *Epoch) GetSystems() []gnss.System

func (*Epoch) IsClockSteeringSet

func (e *Epoch) IsClockSteeringSet() bool

func (*Epoch) IsSmoothingSet

func (e *Epoch) IsSmoothingSet() bool

func (Epoch) ToJSON

func (e Epoch) ToJSON(w io.Writer) (err error)

ToJSON writes the epoch as JSON to the provided writer

type EpochFlag

type EpochFlag uint8

EpochFlag enumerates possible RINEX epoch flag cases

const (
	Ok EpochFlag = iota
	PowerFailure
	MovingAntenna
	NewSite
	HeaderInfo
	ExternalEvent
	CycleSlip
)

Note: these will not guard against unassigned integers

func (EpochFlag) String

func (epochFlag EpochFlag) String() string

String strigifies the epoch flag

type FrequencyBand

type FrequencyBand int

FrequencyBand represents the frequency band of a GNSS signal.

const (
	// Unknown frequency band
	FrequencyUnknown FrequencyBand = iota

	// ------------------
	// GPS, SBAS, QZSS
	// ------------------
	GPS_L1 // 1575.42 MHz
	GPS_L2 // 1227.60 MHz
	GPS_L5 // 1176.45 MHz

	// ------------------
	// GLONASS
	// ------------------
	GLONASS_G1  // 1602.00 + k*9/16 MHz
	GLONASS_G1a // 1600.995 MHz
	GLONASS_G2  // 1246.00 + k*7/16 MHz
	GLONASS_G2a // 1248.06 MHz
	GLONASS_G3  // 1202.025 MHz

	// ------------------
	// Galileo
	// ------------------
	Galileo_E1   // 1575.42 MHz
	Galileo_E5a  // 1176.45 MHz
	Galileo_E5b  // 1207.14 MHz
	Galileo_E5ab // 1191.795 MHz (Combined E5a + E5b)
	Galileo_E6   // 1278.75 MHz

	// ------------------
	// SBAS
	// ------------------
	SBAS_L1 // 1575.42 MHz
	SBAS_L5 // 1176.45 MHz

	// ------------------
	// QZSS
	// ------------------
	QZSS_L1 // 1575.42 MHz
	QZSS_L2 // 1227.60 MHz
	QZSS_L5 // 1176.45 MHz
	QZSS_L6 // 1278.75 MHz

	// ------------------
	// BeiDou
	// ------------------
	BeiDou_B1   // 1561.098 MHz
	BeiDou_B1c  // 1575.42 MHz
	BeiDou_B1a  // 1575.42 MHz
	BeiDou_B2a  // 1176.45 MHz
	BeiDou_B2   // 1207.14 MHz
	BeiDou_B2b  // 1207.14 MHz
	BeiDou_B2ab // 1191.795 MHz (Combined B2a + B2b)
	BeiDou_B3   // 1268.52 MHz
	BeiDou_B3a  // 1268.52 MHz

	// ------------------
	// NavIC
	// ------------------
	NavIC_L1 // 1575.42 MHz
	NavIC_L5 // 1176.45 MHz
	NavIC_S  // 2492.028 MHz

)

func ParseFrequencyBand

func ParseFrequencyBand(system gnss.System, code string) (FrequencyBand, error)

ParseFrequencyBand parses the frequency band code based on the GNSS system. It returns the corresponding FrequencyBand or an error if the input is invalid.

func (FrequencyBand) FrequencyForBand

func (band FrequencyBand) FrequencyForBand(k int) (float64, error)

FrequencyForBand returns the frequency in MHz for a given FrequencyBand. For GLONASS bands, the parameter k is used to adjust the frequency:

  • GLONASS_G1: 1602.00 + k*(9/16) MHz
  • GLONASS_G2: 1246.00 + k*(7/16) MHz

For bands where k is not applicable, it is ignored.

func (FrequencyBand) String

func (band FrequencyBand) String() string

String returns the human-readable name of the FrequencyBand.

type GlonassFcn added in v0.18.5

type GlonassFcn int

type GlonassSatelliteID added in v0.18.5

type GlonassSatelliteID int

type GlonassSatelliteIDs added in v0.18.5

type GlonassSatelliteIDs []GlonassSatelliteID

func (GlonassSatelliteIDs) Sort added in v0.18.5

func (glonassSatelliteIDs GlonassSatelliteIDs) Sort()

type Observation

type Observation struct {
	System                 gnss.System `json:"system"`                    // Satellite System (G:1, R:2, S:3, E:4, C:5, J:6, I:7)
	SatelliteID            int         `json:"satellite_id"`              // Satellite PRN or Slot Number
	Code                   string      `json:"code"`                      // Observation Type Code (e.g 1C, 1W, 2C, 2W, ...)
	Frequency              float64     `json:"frequency"`                 // Frequency [Mhz] (e.g. 1575.42)
	Fcn                    int         `json:"frequency_channel_number"`  // Frequency Channel Number (GLONASS Only)
	Range                  float64     `json:"range"`                     // Pseudorange [m]
	Phase                  float64     `json:"phase"`                     // Phase [cyc]
	Doppler                float64     `json:"doppler"`                   // Doppler [Hz]
	SNR                    float32     `json:"snr"`                       // Signal-to-noise [db-Hz]
	LLI                    uint16      `json:"lli"`                       // Slip count or timer
	Flags                  uint16      `json:"flags"`                     // Flags - bit 0,1,2 same as rinex
	HalfCycleAmbiguity     *uint8      `json:"half_cycle_ambiguity"`      // Half-cycle ambiguity indicator
	LockTimeIndicatorDF407 *uint16     `json:"lock_time_indicator_df407"` // Lock time indicator
	LockTimeIndicatorDF402 *uint8      `json:"lock_time_indicator_df402"` // Lock time indicator
}

Observation - holds GNSS observation data

type ObservationKey

type ObservationKey struct {
	Frequency  FrequencyBand
	SignalType SignalType
}

ObservationKey represents a GNSS signal frequency band, and signal type.

func ParseObservationKey

func ParseObservationKey(system gnss.System, code string) (ObservationKey, error)

ParseObservationKey parses a two-character GNSS signal code (e.g. "1C") and returns the corresponding ObservationKey.

func (ObservationKey) Equals

func (s ObservationKey) Equals(other ObservationKey) bool

Equals checks if two GNSSSignals are equal.

func (ObservationKey) HasPhaseCorrectionNone added in v0.18.5

func (s ObservationKey) HasPhaseCorrectionNone(system gnss.System) bool

Checks whether key in list of Rinex3 A23 references

type ObservationKeys added in v0.18.1

type ObservationKeys []ObservationKey

func (ObservationKeys) Sort added in v0.18.1

func (observationKeys ObservationKeys) Sort()

type ObservationMap

type ObservationMap map[ObservationKey]Observation

ObservationMap is a map of ObservationKeys to Observations

func (*ObservationMap) Add

func (om *ObservationMap) Add(o Observation) error

Add adds an observation to the ObservationMap, overwriting any existing observation with the same key.

func (ObservationMap) Find

Find searches for an observation in the ObservationMap based on the ObservationKey.

func (ObservationMap) MarshalJSON

func (om ObservationMap) MarshalJSON() ([]byte, error)

MarshalJSON for ObservationMap

func (*ObservationMap) UnmarshalJSON

func (om *ObservationMap) UnmarshalJSON(data []byte) error

UnmarshalJSON for ObservationMap

type ObservationSet

type ObservationSet struct {
	// contains filtered or unexported fields
}

ObservationSet encapsulates ordered and unique ObservationKeys.

func NewObservationSet

func NewObservationSet() *ObservationSet

func (*ObservationSet) Add

func (os *ObservationSet) Add(key ObservationKey)

func (*ObservationSet) Keys

func (os *ObservationSet) Keys() []ObservationKey

type ObservationsBySystem

type ObservationsBySystem struct {
	Observations map[gnss.System]*ObservationSet
	GlonassSlots map[GlonassSatelliteID]GlonassFcn
}

ObservationsBySystem manages observations across multiple GNSS systems. It also holds the GLONASS slots/frequency channel numbers

func NewObservationsBySystem

func NewObservationsBySystem() *ObservationsBySystem

func (*ObservationsBySystem) AddEpoch

func (o *ObservationsBySystem) AddEpoch(epoch Epoch)

func (*ObservationsBySystem) AddGlonassSlot added in v0.18.5

func (o *ObservationsBySystem) AddGlonassSlot(obs *Observation)

func (*ObservationsBySystem) AddObservation

func (o *ObservationsBySystem) AddObservation(system gnss.System, key ObservationKey)

func (*ObservationsBySystem) GetObservations

func (o *ObservationsBySystem) GetObservations(system gnss.System) (*ObservationSet, error)

func (*ObservationsBySystem) GetSystems

func (o *ObservationsBySystem) GetSystems() []gnss.System

func (*ObservationsBySystem) MarshalJSON

func (o *ObservationsBySystem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ObservationsBySystem.

func (*ObservationsBySystem) UnmarshalJSON

func (o *ObservationsBySystem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ObservationsBySystem.

type SatelliteKey

type SatelliteKey struct {
	System      gnss.System `json:"system"`
	SatelliteID int         `json:"satellite_id"`
}

SatelliteKey is a struct containing the satellite system and satellite ID

func ParseSatelliteKey

func ParseSatelliteKey(s string) (SatelliteKey, error)

ParseSatelliteKey parses a string into a SatelliteKey

func (SatelliteKey) String

func (s SatelliteKey) String() string

Stringer for SatelliteKey

type SatelliteKeys added in v0.18.1

type SatelliteKeys []SatelliteKey

func (SatelliteKeys) Sort added in v0.18.1

func (satKeys SatelliteKeys) Sort()

type SatelliteMap

type SatelliteMap map[SatelliteKey]ObservationMap

SatelliteMap is a map of SatelliteKeys to ObservationMaps

func (*SatelliteMap) AddObservation

func (sm *SatelliteMap) AddObservation(o Observation) error

addObservation adds an observation to the SatelliteMap, creating the necessary nested maps if they don't exist.

func (SatelliteMap) FindObservation

func (sm SatelliteMap) FindObservation(satKey SatelliteKey, obsKey ObservationKey) (Observation, error)

findObservation finds an observation in the SatelliteMap based on the satellite key and observation key.

func (SatelliteMap) FindSatellite

func (sm SatelliteMap) FindSatellite(satKey SatelliteKey) (ObservationMap, error)

FindSatellite finds the ObservationMap for a given satellite in the SatelliteMap.

func (SatelliteMap) MarshalJSON

func (sm SatelliteMap) MarshalJSON() ([]byte, error)

MarshalJSON for SatelliteMap

func (*SatelliteMap) UnmarshalJSON

func (sm *SatelliteMap) UnmarshalJSON(data []byte) error

UnmarshalJSON for SatelliteMap

type SignalType

type SignalType int

SignalType represents the tracking mode or channel for a given GNSS signal.

const (
	SignalTypeUnknown SignalType = iota // 0: Unknown or unspecified attribute
	A
	B
	C
	D
	E
	I
	L
	M
	N
	P
	Q
	R
	S
	W
	X
	Y
	Z
)

The following signal types are defined in the RINEX 4.02 specification: https://files.igs.org/pub/data/format/rinex_4.02.pdf

func ParseSignalType

func ParseSignalType(code string) (SignalType, error)

ParseSignalType parses a two-character GNSS signal type code (e.g. "1C") and returns the corresponding SignalType. It extracts the second character to determine the signal type.

func (SignalType) String

func (s SignalType) String() string

String returns the string representation (third character) of the SignalType.

Jump to

Keyboard shortcuts

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