GithubHelp home page GithubHelp logo

joshuaferrara / go-satellite Goto Github PK

View Code? Open in Web Editor NEW
78.0 78.0 27.0 193 KB

Calculate orbital information of satellites in GoLang.

License: BSD 2-Clause "Simplified" License

Go 100.00%
altitude golang julian latlong longitude orbital-mechanics orbital-simulation position satellite sgp sgp4 velocity

go-satellite's People

Contributors

ainagarciaes avatar akhenakh avatar danielmorsing avatar hanemile avatar joshuaferrara avatar psykar avatar publicpwd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-satellite's Issues

LLAToECI

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.

diff result with satellite.js

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 }

Make Satelitte Struct Publicy Accessable

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.

suspicious unused argument

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

ECI conversion not precise on LAT and ALTITUDE

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

How do I use ECIToLookAngles correctly?

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)
}

Rework API to take `time.Time`

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.