def _propagate(sat, dt): ''' True equator mean equinox (TEME) position from `sgp4` at given time. Then converted to ITRS Parameters ---------- sat : `sgp4.io.Satellite` instance Satellite object filled from TLE dt : `~datetime.datetime` Time Returns ------- xs, ys, zs : float TEME (=True equator mean equinox) position of satellite [km] ''' # pos [km], vel [km/s] position, velocity = sat.propagate(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second + dt.microsecond / 1e6) if position is None: raise ValueError('Satellite propagation error') # I _think_ this is supposed to take time since J2000 in days? # looking at https://space.stackexchange.com/questions/25988/sgp4-teme-frame-to-j2000-conversion jd_ut1 = dt - time_J2000 jd_ut1 = jd_ut1.days + jd_ut1.seconds / (3600. * 24) new_position, new_velocity = sgp4lib.TEME_to_ITRF( jd_ut1, np.array(position), np.array(velocity) * 86400) return tuple(new_position.tolist())
def sgp4Predict(s, t, jd, fr): satellite = Satrec.twoline2rv(s, t) jd += 0.5 # get the position and velocity vectors in TEME frame e, r, v = satellite.sgp4(jd, fr) # Conversion from TEME to ITRS r, v = sgp4lib.TEME_to_ITRF(jd + fr, np.asarray(r), np.asarray(v) * 86400) v = v / 86400 return r * 1000, v * 1000
def plot_sat(Xi, sat, start_time, stop_time, delta, MEOLUT, freq0): satellite = TLE_read( sat) #,'sarsat3.txt') - use optional argument to read different TLE curr = start_time timelist = list() posilist = list() velolist = list() Rig_list = list() Ri_list = list() f_ig_prime_list = list() f_i_prime_list = list() f_inv_prime_list = list() f_inv_ig_list = list() f_ig_list = list() while curr < stop_time: curr += delta timelist.append(curr) for times in timelist: position, velocity = satellite.propagate(times.year, times.month, times.day, times.hour, times.minute, times.second) V_i_TE = [ x * 86400 for x in velocity ] # conversion because sgp4lib.TEME_to_ITRF function expects V in km/day datetime1 = jday.JD(times) X_i_ECEF, V_i_ECEF = sgp4lib.TEME_to_ITRF( datetime1, array(position), array(V_i_TE)) # get satellite pos and vel posilist.append(X_i_ECEF) V_i_ECEF = [x / 86400 for x in V_i_ECEF] # convert back to #km/sec velolist.append(V_i_ECEF) Rig = (MEOLUTLocDict[MEOLUT] - X_i_ECEF ) # Rig is vector from MEOLUT to satellite Rig_list.append(Rig) Rig_dot = dot(V_i_ECEF, (Rig / norm(Rig))) Ri = ( Xi - X_i_ECEF ) # Xi is the beacon location, Ri is the vector from beacon to satellite Ri_list.append(Ri) Ri_dot = dot(V_i_ECEF, (Ri / norm(Ri))) inverted = True if str(sat)[0] == '3' else False freq_down = freq_sband if inverted == True else freq_lband ### this works here #dF_ig = (Rig_dot/c)*freq_down #dF_i = -(Ri_dot/c)*freq0 if inverted == True else (Ri_dot/c)*freq0 # testing here dF_ig = -(Rig_dot / c) * freq0 if inverted == True else (Rig_dot / c) * freq0 dF_i = (Ri_dot / c) * (freq_down - dF_ig ) #if inverted == True else (Ri_dot/c)*freq0 f_ig_prime = freq0 + dF_i + dF_ig #f_ig_prime_list.append(f_ig_prime) #f_i_prime = freq0 + dF_ig # not inverted f_inv_ig = freq_inv - (f_ig_prime - freq_inv) + freq_shift #f_inv_ig = f_ig_prime #-freq_inv +freq_shift f_ig = f_inv_ig if inverted == True else f_ig_prime f_ig_list.append(f_ig) alt = [norm(x) for x in posilist] rangelist = [norm(MEOLUTLocDict[MEOLUT] - x) for x in posilist] #plotting TLE positional difference below #fig, ax = plt.subplots() #plt.plot(timelist, f_i_prime_list, 'g') #plt.plot(timelist, f_ig_prime_list, 'b-') #plt.plot(timelist, f_inv_prime_list,c='orange', linestyle = '-', linewidth = 3) plt.plot(timelist, f_ig_list, c='purple', linewidth=3) plt.axhline(y=freq0, color='g') plt.legend(['f_ig']) #plt.axhspan(406.04e6, 406.05e6) plt.axhline(y=freq_inv, color='r', linestyle='--') plt.grid(True)