3

I am trying to display different subpoint plots for different orbit height of satellites and use the lines for further analysis.

So I wrote myself a satellite create function that computes inclination and mean motion:

def create_sat (a,orbit_type='ISS',e=0.0008835,epoch=26317,number=1):
    a=(a+6378)*1000
    if orbit_type=='ISS':
        i=0.90058989402907
    else:
        i=np.arccos(-(((a)/(12352000))**(7/2)))
    
    mu=3.986004418*(10**14)
    pii=3.14159265359793
    p=np.sqrt((a**3*4*pii**2)/(mu))/60
    mean_motion=((2*pii)/p)
    
    satrec = Satrec()
    satrec.sgp4init(
        WGS84,           # gravity model
        'i',             # 'a' = old AFSPC mode, 'i' = improved mode
        number,          # satnum: Satellite number
        epoch,           # epoch: days since 1949 December 31 00:00 UT
        2.2,             # bstar: drag coefficient (/earth radii)
        6.969196665e-13, # ndot: ballistic coefficient (revs/day)
        0.0,             # nddot: second derivative of mean motion (revs/day^3)
        e,               # ecco: eccentricity
        0,               # argpo: argument of perigee (radians)
        i,         # inclo: inclination (radians)
        0,               # mo: mean anomaly (radians)
        mean_motion,           # no_kozai: mean motion (radians/minute)
        2,               # nodeo: right ascension of ascending node (radians)
    )
    
    print(p)
    print(1/(p/60))
    print(mean_motion)
    print(i)
    ts = load.timescale()
    sat = EarthSatellite.from_satrec(satrec, ts)
    return sat

However when I try to compute the subpoint with the skyfiled package I get an error:

\toposlib.py:232: RuntimeWarning: invalid value encountered in remainder
lon = (arctan2(y, x) - pi) % tau - pi

I figured out that _compute_latitude(self, position) of skyfields toposlib.py returns nan for x, y, and z.

If I choose different values for inclination i and mean_motion it works, but not for the calculated values. (the calculation is correct though)

Why does it return nan and what are the boundaries for the calculation?

Thanks in advance!

Merci
  • 31
  • 2
  • What are the x, y, and z that you are referring to when you say it "returns nan for x, y, and z"? In your `lon` calculation, what are `x`, `y`, and `tau`? – Engineero Jan 19 '22 at 20:24
  • Also, since you are already using numpy, you can just us `np.pi` for pi instead of having to define it as a constant in your code. Generally preferred. – Engineero Jan 19 '22 at 20:27
  • x,y,z and tau are not part of my calculation. They are part of the skyfield package and the "toposlib.py". They are computed with this line: xyz_au = position.frame_xyz(itrs).au x, y, z = xyz_au But that is not my code, that is the package. – Merci Jan 21 '22 at 08:09

1 Answers1

0

You have probably created an invalid satellite and are getting back [nan nan nan] as its position — some versions of NumPy get upset when a NaN value is asked for its remainder with %.

  1. Try printing the raw position before asking for its coordinates. That will help you confirm whether NaN values are the problem.
  2. If they are indeed the problem, try printing the EarthSatellite .message attribute to see what the error was that the SGP4 routine had with your coordinates.
Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147