satellite

package module
v0.0.0-...-6c388a7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: BSD-2-Clause Imports: 6 Imported by: 0

README

satellite

go get github.com/infostellarinc/go-satellite

Intro

Go GoDoc

go-satellite lets you take a TLE and propagate it to a given time utilizing sgp4. It also lets you calculate the look angles to a satellite from a given location.

You should utilize the original repo over this one.

This fork diverges to narrow the focus of the repo/package.

  • removes panics/fatal calls and replaces with errors
    • adds sentinel errors for propagation rather than error codes
  • removes dependencies
  • removes spacetrak/celestrak TLE fetching features, those can be implemented elsewhere
  • reorganizes some code
    • APIs were ambiguous with similar signatures, but different functionality. This was cleaned up to have clearer separation of TLE and Satellite.
  • pulls in some community PR fixes that weren't merged into the original repo
  • adding some cmd utilities

Documentation

Index

Constants

View Source
const DEG2RAD float64 = math.Pi / 180.0
View Source
const EQUATOR_RADIUS float64 = 6378.137
View Source
const GRAVITY_EARTH float64 = 398600.4418
View Source
const JULIAN_CENTURY float64 = 36525.0
View Source
const JULIAN_DAY_JAN_1_2000 float64 = 2451545.0
View Source
const POLAR_RADIUS float64 = 6356.7523142
View Source
const RAD2DEG float64 = 180.0 / math.Pi
View Source
const SECONDS_IN_DAY float64 = 86400.0
View Source
const TWOPI float64 = math.Pi * 2.0
View Source
const XPDOTP float64 = 1440.0 / TWOPI

Variables

View Source
var ErrInvalidLatitude = errors.New("latitude not within bounds -pi/2 to +pi/2")
View Source
var ErrInvalidMeanEccentricity = errors.New("mean eccentricity is not within range 0 <= e < 1")
View Source
var ErrInvalidMeanMotion = errors.New("mean motion is less than 0")
View Source
var ErrInvalidPertubedEccentricity = errors.New("perturbed eccentricity is not within range 0 <= e < 1")
View Source
var ErrInvalidSemilatusRectum = errors.New("semilatus rectum is less than 0")
View Source
var ErrSatelliteDecay = errors.New("mrt is less than 1.0 indicating decay")
View Source
var Now = func() time.Time {
	return time.Now().UTC()
}

Returns the current time in UTC This is a variable so it can be mocked in tests

Functions

func GSTimeFromDate

func GSTimeFromDate(date time.Time) float64

Calc GST given year, month, day, hour, minute and second.

func JDay

func JDay(year, month, day, hour, minute int, second float64) float64

Calc julian date given year, month, day, hour, minute and second the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.

func JDayTime

func JDayTime(date time.Time) float64

func ThetaGJD

func ThetaGJD(jday float64) float64

Calculate GMST from Julian date. Reference: The 1992 Astronomical Almanac, page B6.

Types

type Coordinates

type Coordinates struct {
	Latitude  float64
	Longitude float64
	Altitude  float64
}

Holds latitude and Longitude in either degrees or radians

func ECIToLLA

func ECIToLLA(eciCoords Vector3, gmst float64) (velocity float64, ret Coordinates)

Convert Earth Centered Inertial coordinated into equivalent latitude, longitude, altitude and velocity. Reference: http://celestrak.com/columns/v02n03/

func LatLongDeg

func LatLongDeg(rad Coordinates) (Coordinates, error)

Convert LatLong in radians to LatLong in degrees.

type DSComResults

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

A struct returned from the dscom function

type DeepSpaceInitResult

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

Result of dsinit(...)

type DeepSpaceResult

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

Result of dspace(...)

type DpperResult

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

A struct returned from the dpper function

type GravConst

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

GravConst holds variables that are dependent upon selected gravity model.

type Gravity

type Gravity string
const (
	GravityWGS72Old Gravity = "wgs72old"
	GravityWGS72    Gravity = "wgs72"
	GravityWGS84    Gravity = "wgs84"
)

type LookAngles

type LookAngles struct {
	Azimuth   float64
	Elevation float64
	Range     float64
}

func ECIToLookAngles

func ECIToLookAngles(eciSat Vector3, obsCoords Coordinates, jday float64, grav GravConst) LookAngles

Calculate look angles for given satellite position and observer position obsAlt in km Reference: http://celestrak.com/columns/v02n02/

type Satellite

type Satellite struct {
	Tle TLE

	GravityConst GravConst
	// contains filtered or unexported fields
}

Struct for holding satellite information during and before propagation

func TLEToSat

func TLEToSat(line1, line2 string, gravConst Gravity) (Satellite, error)

Converts a two line element data set into a Satellite struct and runs sgp4init

type TLE

type TLE struct {
	Line1 string `json:"LINE1"`
	Line2 string `json:"LINE2"`

	CatalogNumber string
	EpochYear     int64
	EpochDay      float64

	// aka ndot
	FirstTimeDerivativeOfMeanMotion float64
	// aka nddot
	SecondTimeDerivativeOfMeanMotion float64
	BStar                            float64

	Inclination                   float64
	RightAscensionOfAscendingNode float64
	Eccentricity                  float64
	ArgumentOfPerigee             float64
	MeanAnomaly                   float64
	MeanMotion                    float64

	OrbitNumberAtEpoch int64
}

func ParseTLE

func ParseTLE(line1, line2 string) (TLE, error)

Parses a two line element dataset into a Satellite struct

func (TLE) EpochTime

func (t TLE) EpochTime() time.Time

type Vector3

type Vector3 struct {
	X, Y, Z float64
}

func ECIToECEF

func ECIToECEF(eciCoords Vector3, gmst float64) Vector3

Convert Earth Centered Intertial coordinates into Earth Cenetered Earth Final coordinates Reference: http://ccar.colorado.edu/ASEN5070/handouts/coordsys.doc

func LLAToECI

func LLAToECI(obsCoords Coordinates, jday float64, grav GravConst) Vector3

Convert latitude, longitude and altitude(km) into equivalent Earth Centered Intertial coordinates(km) Reference: The 1992 Astronomical Almanac, page K11.

func Propagate

func Propagate(sat Satellite, date time.Time) (position, velocity Vector3, err error)

Calculates position and velocity vectors for given time

func (Vector3) Equals

func (v Vector3) Equals(v2 Vector3) bool

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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