1 def tle2orb(TLEline1,TLEline2,t_start,t_end,t_interval):
19 from sgp4.api
import Satrec
20 from sgp4.api
import jday
21 from hawknav.jd
import jd
23 OMEGAE = 7.29211585494e-5
25 satellite = Satrec.twoline2rv(TLEline1,TLEline2)
26 time_tuple = time.gmtime(t_start)
27 jd, fr =
jday(time_tuple.tm_year, time_tuple.tm_mon, time_tuple.tm_mday, time_tuple.tm_hour, time_tuple.tm_min, time_tuple.tm_sec)
28 ts = np.arange(t_start,t_end,t_interval)
29 dt_array = (ts-t_start)/86400.0
30 fr_array = fr+dt_array
31 jd_array = jd*np.ones(np.size(fr_array))
32 jd_array = jd_array + np.modf(fr_array)[1]
33 fr_array = np.modf(fr_array)[0]
34 e, r, v = satellite.sgp4_array(jd_array, fr_array)
35 nrec = np.size(jd_array)
38 t = jd_array - 2451545 + fr_array
41 gmst = 100.4606184 + 0.9856473663*t + 2.908e-13*t*t
44 gha = gmst + fr_array*360
48 cogha = np.cos(np.deg2rad(gha))
49 sigha = np.sin(np.deg2rad(gha))
50 posr = np.zeros((nrec,3))
51 posr[:,0] = r[:,0]*cogha + r[:,1]*sigha
52 posr[:,1] = r[:,1]*cogha - r[:,0]*sigha
56 velr = np.zeros((nrec,3))
57 velr[:,0] = v[:,0]*cogha + v[:,1]*sigha + OMEGAE*posr[:,1]
58 velr[:,1] = v[:,1]*cogha - v[:,0]*sigha - OMEGAE*posr[:,0]
61 yd = [datetime.datetime.utcfromtimestamp(t).timetuple().tm_yday
for t
in ts]
64 orb = np.concatenate((tt[:,
None],posr,velr),axis=1)