-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
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)
}
Metadata
Metadata
Assignees
Labels
No labels