joshuaferrara / go-satellite Goto Github PK
View Code? Open in Web Editor NEWCalculate orbital information of satellites in GoLang.
License: BSD 2-Clause "Simplified" License
Calculate orbital information of satellites in GoLang.
License: BSD 2-Clause "Simplified" License
https://github.com/joshuaferrara/go-satellite/blob/master/conversions.go
There is a possible error in the LLAToECI function.
The correct calculation would be:
// Convert latitude, longitude and altitude(km) into equivalent Earth Centered Intertial coordinates(km)
// Reference: The 1992 Astronomical Almanac, page K11.
func LLAToECI(obsCoords LatLong, alt, jday float64) (eciObs Vector3) {
re := 6378.137
theta := math.Mod(ThetaG_JD(jday)+obsCoords.Longitude, TWOPI)
r := re * math.Cos(obsCoords.Latitude)
eciObs.X = r * math.Cos(theta)
eciObs.Y = r * math.Sin(theta)
eciObs.Z = (re + alt) * math.Sin(obsCoords.Latitude)
return
}
I hope I've helped.
hello:
the params:
time: 1678701415000
tle1: 1 40961U 15057D 23054.82376164 .00001476 00000-0 22867-3 0 9995
tle2: 2 40961 97.7284 98.3880 0016977 225.3046 134.6760 14.74502360397162
the satellite.js result:
{ lon: 116.5596746430928, lat: 77.78645324386629 }
go-satellite result:
{ lon: 116.70120805642739, lat: 77.75070993817323 }
I am currently utilizing the go-satellite package in a project and have encountered a limitation that is impacting my work. Specifically, my use case requires access to the jdsatepoch field in the Satellite struct. However, this field, along with several others, is not publicly accessible.
type Satellite struct {
Line1 string
Line2 string
}
At present, only the Line1 and Line2 fields of the Satellite struct are publicly accessible. Here is the current definition of the struct:
For the requirements of my project, I kindly request that all fields of the Satellite struct, including jdsatepoch, be made publicly accessible. This would significantly aid in my project and could potentially benefit other users of the package who may have similar needs.
I'm working of cleaning the code with some linters and found this
dspace.go:18:371: SA4009: argument dedt is overwritten before first use (staticcheck)
func dsinit(whichconst GravConst, cosim, emsq, argpo, s1, s2, s3, s4, s5, sinim, ss1, ss2, ss3, ss4, ss5, sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33, t, tc, gsto, mo, mdot, no, nodeo, nodedot, xpidot, z1, z3, z11, z13, z21, z23, z31, z33, ecco, eccsq, em, argpm, inclm, mm, nm, nodem, irez, atime, d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433, dedt, didt, dmdt, dnodt, domdt, del1, del2, del3, xfact, xlamo, xli, xni float64) (res DeepSpaceInitResult) {
^
dspace.go:462:52: SA4009: argument e3 is overwritten before first use (staticcheck)
func dscom(epoch, ep, argpp, tc, inclp, nodep, np, e3, ee2, peo, pgho, pho, pinco, plo, se2, se3, sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4, xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4, zmol, zmos float64) (res DSComResults) {
For example e3 = 2.0 * s1 * s7
is assigned before read
This test
func Test0(t *testing.T) {
// middle of August 2022
jtime := JDay(2022, 8, 15, 12, 0, 0)
// random place near Genoa, Italy
lat := 45.0 * DEG2RAD
lon := 8.0 * DEG2RAD
// on the hill
heightInKm := 0.5
// put in struct
myLatLon := LatLong{lat, lon}
// Go to ECI
posInECI := LLAToECI(myLatLon, heightInKm, jtime)
//t.Log(posInECI)
gmst := ThetaG_JD(jtime)
altitude, _, backToLLA := ECIToLLA(posInECI, gmst)
backToLLADeg := LatLongDeg(backToLLA)
t.Log(LatLongDeg(myLatLon), heightInKm)
t.Log(backToLLADeg, altitude)
}
verifies that conversion back and forth to ECI is problematic. Altitude seems to be ignored (try to change it in 45 or 15 km) and latitude is badly converted. I think (but it is an impression) that the issue is in the forward conversion. Also ECEF conversion appears not perfect.
UPDATE 26/08 : The issue is that latlon in input to LLAToECI is assumed to be SPHERICAL, while the output of ECIToLLA responds in WGS84
Paolo
I made a test program to give me long and lat correctly. They seem to line up with what GPredict shows me. But I fail to convert these to LookAngles.
The test program below should say that the elevation is straight up, but instead the output of this code is:
ISS pos: 51.75 0.15
LookAngles: 1.32 -0.05 2631.53
Any ideas? Is this using jday incorrectly?
package main
import (
"flag"
"fmt"
"log"
"math"
"time"
"github.com/joshuaferrara/go-satellite"
)
func ymd(ts time.Time) (int, int, int, int, int, int) {
y, mm, d := ts.Date()
h, m, s := ts.Hour(), ts.Minute(), ts.Second()
return y, int(mm), d, h, m, s
}
func gstimeFromDate(ts time.Time) float64 {
return satellite.GSTimeFromDate(ymd(ts))
}
func fixLong(in float64) float64 {
for in < 0 {
in += 2 * math.Pi
}
for in > 2*math.Pi {
in -= 2 * math.Pi
}
return in * 180 / math.Pi
}
func main() {
flag.Parse()
// Set up ISS TLE.
tle1 := "1 25544U 98067A 21290.96791059 .00007152 00000-0 13913-3 0 9995"
tle2 := "2 25544 51.6432 95.6210 0004029 117.2302 27.3327 15.48732973307628"
sat := satellite.TLEToSat(tle1, tle2, "wgs84")
// Pick a time when ISS is over London, UK. ts, err := time.Parse("2006-01-02 15:04:05", "2021-10-20 09:51:06")
if err != nil {
log.Fatal(err)
}
y, mm, d, h, m, s := ymd(ts)
// Find ISS pos. pos, _ := satellite.Propagate(sat, y, mm, d, h, m, s)
// Find LLA for ISS. gmst := satellite.GSTimeFromDate(ymd(ts))
_, _, latlong := satellite.ECIToLLA(pos, gmst)
fmt.Printf("ISS pos: %.2f %.2f\n",
latlong.Latitude*180.0/math.Pi,
fixLong(latlong.Longitude))
// Now calculate LookAngles for *exactly* underneath the ISS. jday := satellite.JDay(y, mm, d, h, m, s)
ang := satellite.ECIToLookAngles(pos, satellite.LatLong{
Latitude: latlong.Latitude,
Longitude: latlong.Longitude,
}, 0, jday-2451545.0)
fmt.Printf("LookAngles: %.2f %.2f %.2f\n", ang.Az, ang.El, ang.Rg)
}
A few methods in the API take year/month/day/hour/minute/second
Would you be against changing this to take a time.Time object instead?
We could either bump up major versions (v2) or just add a new set of methods that live side by side.
Thoughts?
Currently, when I run go get
, it upgrades the library to the following version:
go: upgraded github.com/joshuaferrara/go-satellite v0.0.0-20190508041801-c578fe801371 => v0.0.0-20220611180459-512638c64e5b
The version 0.1.0
also does not appear in the docs: https://pkg.go.dev/github.com/joshuaferrara/go-satellite?tab=versions
I believe you need to use v0.1.0
tag to let Go modules pick it up. Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.