wx

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const WindHeightOffset = 500

Variables

This section is empty.

Functions

func CheckBasicMETARSOA

func CheckBasicMETARSOA(soa BasicMETARSOA, orig []BasicMETAR) error

func CheckSampleSetConversion

func CheckSampleSetConversion(cell SampleSet, soa SampleSetSOA) error

func DirSpeedToUV

func DirSpeedToUV(dir, speed float32) (float32, float32)

func FetchRadarImage

func FetchRadarImage(center math.Point2LL, radius float32, resolution int) (image.Image, math.Extent2D, error)

func RadarImageToDBZ

func RadarImageToDBZ(img image.Image) []byte

func UVToDirSpeed

func UVToDirSpeed(u, v float32) (float32, float32)

Types

type BasicMETAR

type BasicMETAR struct {
	ICAO        string  `json:"icaoId"`
	ReportTime  string  `json:"reportTime"`
	Temperature float32 `json:"temp"`
	Altimeter   float32 `json:"altim"`
	WindDir     any     `json:"wdir"` // nil or string "VRB" for variable, else number for heading
	WindSpeed   int     `json:"wspd"`
	WindGust    *int    `json:"wgst"`
	Raw         string  `json:"rawOb"`
}

This is as much of the METAR as we need at runtime.

func DecodeBasicMETARSOA

func DecodeBasicMETARSOA(soa BasicMETARSOA) []BasicMETAR

type BasicMETARSOA

type BasicMETARSOA struct {
	// These are all delta coded
	ReportTime  [][]byte
	Temperature []int16 // fixed point, one decimal digit
	Altimeter   []int16 // fixed point, one decimal digit
	WindDir     []int16
	WindSpeed   []int16
	WindGust    []int16

	// This is not; it's not worth delta encoding the raw METAR reports
	// since there's generally not much character alignment between
	// successive reports.
	Raw []string
}

Structure-of-arrays representation of an array of BasicMETAR objects for better compressability.

func MakeBasicMETARSOA

func MakeBasicMETARSOA(recs []BasicMETAR) (BasicMETARSOA, error)

type MBLevelSOA

type MBLevelSOA struct {
	MB float32
	// All of the following are delta encoded
	Heading     []uint8 // degrees/2
	Speed       []uint8 // knots
	Temperature []int8  // Temperature in Celsius
	Height      []uint8 // geopotential height + WindHeightOffset in 100s of feet
}

type METAR

type METAR struct {
	ICAO        string  `json:"icaoId"`
	ReportTime  string  `json:"reportTime"`
	Temperature float32 `json:"temp"` // in Celcius
	Dewpoint    float32 `json:"dewp"` // in Celcius
	Wind        struct {
		Variable  bool
		Direction float32 // Only set/valid if Variable is false.
		Speed     float32 `json:"wspd"` // Wind speed in knots
		Gust      float32 `json:"wgst"` // Wind gusts in knots
	}
	Altimeter float32 `json:"altim"` // in hPa
	RawText   string  `json:"rawOb"` // Raw text of observation

	Latitude  float32 `json:"lat"`
	Longitude float32 `json:"lon"`

	// The JSON comes back sort of wonky; we decode into this but then
	// clean it up into the Wind member above.
	WindDirRaw any `json:"wdir"` // Wind direction in degrees or "VRB" for variable winds

}

func (METAR) Altimeter_inHg

func (m METAR) Altimeter_inHg() float32

func (METAR) Location

func (m METAR) Location() math.Point2LL

func (METAR) ShortString

func (m METAR) ShortString() string

type Sample

type Sample struct {
	MB          float32
	UComponent  float32 // eastward
	VComponent  float32 // northward
	Temperature float32 // Kelvin, evidently
	Height      float32 // geopotential height
}

type SampleSet

type SampleSet map[[2]float32][]Sample

Lat-longs to stack of levels

func SampleSetSOAToAOS

func SampleSetSOAToAOS(s SampleSetSOA) SampleSet

type SampleSetSOA

type SampleSetSOA struct {
	Lat, Long []float32
	Levels    []MBLevelSOA
}

func SampleSetToSOA

func SampleSetToSOA(c SampleSet) (SampleSetSOA, error)

type WeatherModel

type WeatherModel struct {
	METAR              map[string]*METAR
	NmPerLongitude     float32
	MagneticVariation  float32
	WindRoot           *WindTreeNode
	StartTime          time.Time
	CurrentTime        time.Time
	GustStartTime      time.Time
	GustActiveDuration time.Duration
	GustCalmDuration   time.Duration
}

func MakeWeatherModel

func MakeWeatherModel(airports []string, now time.Time, nmPerLongitude float32, magneticVariation float32,
	wind map[math.Point2LL][]WindLayer, lg *log.Logger) *WeatherModel

func (*WeatherModel) GetMETAR

func (w *WeatherModel) GetMETAR(icao string) *METAR

func (*WeatherModel) LookupWX

func (w *WeatherModel) LookupWX(p math.Point2LL, alt float32) WeatherSample

func (*WeatherModel) LookupWind

func (w *WeatherModel) LookupWind(p math.Point2LL, alt float32) WindSample

func (*WeatherModel) UpdateTime

func (w *WeatherModel) UpdateTime(t time.Time)

type WeatherSample

type WeatherSample struct {
	Altimeter   float32
	Temperature float32
	Dewpoint    float32
	Wind        WindSample
}

type WindLayer

type WindLayer struct {
	Altitude        float32
	Direction       float32    // 0 -> variable
	DirectionVector [2]float32 // normalized vector
	Speed           float32
	Gust            float32
}

func BlendWindLayers

func BlendWindLayers(wts []float32, layers []WindLayer) WindLayer

func ParseWindLayers

func ParseWindLayers(str string, e *util.ErrorLogger) []WindLayer

ParseWindLayers parses a string of the form "alt/dir/spd,alt/dir/spd,..." and returns the corresponding WindLayer objects. Errors are logged to the provided ErrorLogger.

type WindSample

type WindSample struct {
	// Vector is the wind vector at the sample time, incorporating
	// gusting, if relevant. Note that it corresponds to the wind's
	// effect on an aircraft (e.g., if the wind heading is 090, the
	// vector will be pointed in the -x direction.)
	Vector    [2]float32
	Direction float32
	Speed     float32 // current speed in knots, including gusting.
	Gust      float32
}

type WindTreeNode

type WindTreeNode struct {
	Children  [2]*WindTreeNode
	Location  math.Point2LL
	SplitAxis int
	Layers    []WindLayer
}

Jump to

Keyboard shortcuts

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