Julia now has a native SGP4/SDP4 implementation

@crbinz

I compare the results using Vallado’s implementation in Matlab and SatelliteToolbox.jl for the very same orbit you have considered:

Matlab

>> l1 = '1 23599U 95029B   06171.76535463  .00085586  12891-6  12956-2 0  2905';
>> l2 = '2 23599   6.9327   0.2849 5782022 274.4436  25.2425  4.47796565123555';
>> [~, ~, ~, satrec] = twoline2rv(l1,l2,'c','m','a',84);
>> [satrec, r, v] = sgp4(satrec, 5*24*60);
>> r

r =

   1.0e+04 *

  -0.314979672773600   2.410064502724234   0.289071440453531

>> v

v =

  -2.619571867673193  -0.196802903816630  -0.049489996758654

Julia

julia> tle = read_tle_from_string("1 23599U 95029B   06171.76535463  .00085586  12891-6  12956-2 0  2905",
                                  "2 23599   6.9327   0.2849 5782022 274.4436  25.2425  4.47796565123555");

julia> orbp = init_orbit_propagator(Val{:sgp4}, tle[1]);

julia> r,v = sgp4!(orbp.sgp4d, 5*24*60);

julia> println(r[1], " ", r[2], " ", r[3])
-3149.796727736229 24100.64502724232 2890.7144045353007

julia> println(v[1], " ", v[2], " ", v[3])
-2.6195718676731854 -0.19680290381668744 -0.04948999675866066

I think we are equal to Matlab code up to machine precision.

2 Likes

You’re right - the python library does not use AFSPC mode by default, although I also found a different bug in the wrapper code.

Here are the results using AFSPC mode:

julia> r,v = SGP4.sgp4(satellite, 5*24*60)
([-3149.8, 24100.6, 2890.71], [-2.61957, -0.196803, -0.04949])

julia> println(r[1]," ", r[2], " ", r[3], " ")
-3149.7967277359576 24100.645027242346 2890.714404535306

julia> println(v[1]," ", v[2], " ", v[3], " ")
-2.6195718676731934 -0.19680290381662707 -0.04948999675865344

I also edited my post with the benchmarks to use a different method with less overhead – still much slower.

1 Like