def test_zenith_stationary(self): rho = np.random.uniform(0, 1000) az = 0 el = np.pi/2 drho = 0 daz = 0 dele = 0 rho_sez_expected = np.array([0, 0, rho]) rho_sez, drho_sez = geodetic.rhoazel2sez(rho, az, el, drho, daz, dele) np.testing.assert_array_almost_equal(rho_sez, rho_sez_expected)
def test_horizon_east(self): rho = np.random.uniform(0, 1000) az = np.pi/2 el = 0 drho = 0 daz = 0 dele = 0 rho_sez_expected = np.array([0, rho, 0]) rho_sez, drho_sez = geodetic.rhoazel2sez(rho, az, el, drho, daz, dele) np.testing.assert_array_almost_equal(rho_sez, rho_sez_expected)
def test_horizon_north_receeding(self): rho = np.random.uniform(0, 1000) az = 0 el = 0 drho = np.random.uniform(0, 10) daz = 0 dele = 0 rho_sez_expected = np.array([-rho, 0, 0]) drho_sez_expected = np.array([-drho, 0, 0]) rho_sez, drho_sez = geodetic.rhoazel2sez(rho, az, el, drho, daz, dele) np.testing.assert_array_almost_equal(rho_sez, rho_sez_expected) np.testing.assert_array_almost_equal(drho_sez, drho_sez_expected)
def solution(meas_file='./data/COMFIX_tle_measurement.txt', outfile='./data/COMFIX_tle_solution.txt'): # read in the measurement data fout = open(outfile, 'w') with open(meas_file, 'r') as f: l0 = f.readline().split() l0 = [float(x) for x in l0] while l0: l1 = f.readline().split() l1 = [float(x) for x in l1] latgd, lon, alt, jd = np.deg2rad(l0[0]), np.deg2rad( l0[1]), l0[2] / 1e3, l0[3] satnum, rho, az, el, drho, daz, dele = l1[0], l1[1], np.deg2rad( l1[2]), np.deg2rad(l1[3]), l1[4], np.deg2rad( l1[5]), np.deg2rad(l1[6]) # GST, LST gst, lst = time.gstlst(jd, lon) # find satellite vector in SEZ rho_sez, drho_sez = geodetic.rhoazel2sez(rho, az, el, drho, daz, dele) R_eci2ecef = geodetic.eci2ecef(jd) R_ecef2eci = geodetic.ecef2eci(jd) R_sez2ecef = transform.dcm_sez2ecef(latgd, lon, alt) # find site vector in ECEF/ECI site_ecef = geodetic.lla2ecef(latgd, lon, alt) site_eci = R_ecef2eci.dot(site_ecef) # transform satellite vector from SEZ to ECI rho_ecef = R_sez2ecef.dot(rho_sez) rho_eci = R_ecef2eci.dot(rho_ecef) drho_ecef = R_sez2ecef.dot(drho_sez) drho_eci = R_ecef2eci.dot(drho_ecef) pos_eci = site_eci + rho_eci vel_eci = drho_eci + np.cross( np.array([0, 0, constants.earth.omega]), pos_eci) # find orbital elements p, a, ecc, inc, raan, arg_p, nu, _, _, _, _ = kepler.rv2coe( pos_eci, vel_eci, constants.earth.mu) # compute orbit properties prop_string = kepler.orbit_el(p, ecc, inc, raan, arg_p, nu, constants.earth.mu) l0 = f.readline().split() l0 = [float(x) for x in l0] # output to text file fout.write( '#################### COMFIX SATELLITE {:g} ####################################\n\n' .format(satnum)) fout.write( '------------------------ INPUT DATA -------------------------------------------\n\n' ) fout.write('LAT (deg) LON (deg) ALT (m) JD\n') fout.write( '{:<9.4f} {:<9.4f} {:<9.4f} {:<16.6f}\n\n'.format( np.rad2deg(latgd), np.rad2deg(lon), alt * 1e3, jd)) fout.write( 'RHO (km) AZ (deg) EL (deg) DRHO (km/s) DAZ (deg/s) DEL (deg/s)\n' ) fout.write( '{:<9.4f} {:<6.4f} {:<6.4f} {:<6.4f} {:<6.4f} {:<6.4f}\n' .format(rho, np.rad2deg(az), np.rad2deg(el), drho, np.rad2deg(daz), np.rad2deg(dele))) fout.write( '------------------------- WORKING DATA ----------------------------------------\n\n' ) fout.write('LAT (rad) LON (rad) ALT (m) JD\n') fout.write( '{:<9.4f} {:<9.4f} {:<9.4f} {:<16.6f}\n\n'.format( latgd, lon, alt, jd)) fout.write( 'RHO (km) AZ (rad) EL (rad) DRHO (km/s) DAZ (rad/s) DEL (rad/s)\n' ) fout.write( '{:<9.4f} {:<6.4f} {:<6.4f} {:<6.4f} {:<6.4f} {:<6.4f}\n\n' .format(rho, az, el, drho, daz, dele)) fout.write('GST = {:16.9f} rad = {:16.9f} deg\n'.format( gst, np.rad2deg(gst))) fout.write('LST = {:16.9f} rad = {:16.9f} deg\n\n'.format( lst, np.rad2deg(lst))) fout.write( '---------------------------- VECTORS ------------------------------------------\n' ) fout.write( '{:9s} = {:13.4f} S {:13.4f} E {:13.4f} Z MAG = {:7.4f} km\n'. format('rho_sez', rho_sez[0], rho_sez[1], rho_sez[2], np.linalg.norm(rho_sez))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km\n'. format('rho_ecef', rho_ecef[0], rho_ecef[1], rho_ecef[2], np.linalg.norm(rho_ecef))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km\n'. format('rho_eci', rho_eci[0], rho_eci[1], rho_eci[2], np.linalg.norm(rho_eci))) fout.write( '{:9s} = {:13.4f} S {:13.4f} E {:13.4f} Z MAG = {:7.4f} km/s\n' .format('drho_sez', drho_sez[0], drho_sez[1], drho_sez[2], np.linalg.norm(drho_sez))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km/s\n' .format('drho_ecef', drho_ecef[0], drho_ecef[1], drho_ecef[2], np.linalg.norm(drho_ecef))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km/s\n' .format('drho_eci', drho_eci[0], drho_eci[1], drho_eci[2], np.linalg.norm(drho_eci))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km\n'. format('site_ecef', site_ecef[0], site_ecef[1], site_ecef[2], np.linalg.norm(site_ecef))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km\n'. format('site_eci', site_eci[0], site_eci[1], site_eci[2], np.linalg.norm(site_eci))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km\n'. format('pos_eci', pos_eci[0], pos_eci[1], pos_eci[2], np.linalg.norm(pos_eci))) fout.write( '{:9s} = {:13.4f} I {:13.4f} J {:13.4f} K MAG = {:7.4f} km/s\n' .format('vel_eci', vel_eci[0], vel_eci[1], vel_eci[2], np.linalg.norm(vel_eci))) fout.write(prop_string + '\n') fout.close()
gst, lst = time.gstlst(jd, lon) print('JD : {}'.format(jd)) print('GST : {} rad = {} deg'.format(gst, np.rad2deg(gst))) print('LST : {} rad = {} deg'.format(lst, np.rad2deg(lst))) # site location site_ecef = geodetic.lla2ecef(lat, lon, alt) Recef2eci = transform.dcm_ecef2eci(jd) site_eci = Recef2eci.dot(site_ecef) print('Site ECEF : {} km'.format(site_ecef)) print('ECEF TO ECI : \n{}'.format(Recef2eci)) print('Site ECI : {} km'.format(site_eci)) # convert measurement to SEZ then to ECEF then to ECI rho_sez, drho_sez = geodetic.rhoazel2sez(rho, az, el, rhodot, azdot, eldot) R_sez2ecef = transform.dcm_sez2ecef(lat, lon, alt) # transform satellite vector from SEZ to ECI rho_ecef = R_sez2ecef.dot(rho_sez) rho_eci = Recef2eci.dot(rho_ecef) drho_ecef = R_sez2ecef.dot(drho_sez) drho_eci = Recef2eci.dot(drho_ecef) print('\nRHO SEZ : {} km'.format(rho_sez)) print('DRHO SEZ: {} km/sec'.format(drho_sez)) print('SEZ TO ECEF: \n{}'.format(R_sez2ecef)) print('RHO ECEF: {} km/sec'.format(rho_ecef)) print('DRHO ECEF: {} km/sec'.format(drho_ecef))