def test_single_satellite_single_date(single_satellite_single_date_data, benchmark): (line1, line2), epoch, expected_r, expected_v = single_satellite_single_date_data sat = Satellite(PyTle("_", line1, line2), None, PyDateTime(epoch)) def f(): p = sat.eci_pos() return p.loc, p.vel r, v = benchmark(f) assert r == pytest.approx(expected_r) assert v == pytest.approx(expected_v)
def test_multiple_satellites_multiple_dates_large( multiple_satellites_multiple_dates_data_large, benchmark): (tles, epochs, expected_shape) = multiple_satellites_multiple_dates_data_large jd, fr = jday_from_epochs(epochs) mjds = (jd - 2400000.5) + fr tles = np.array([PyTle("_", line1, line2) for (line1, line2) in tles])[..., None] result = benchmark(propagate_many, mjds, tles) r = result["eci_pos"] v = result["eci_vel"] assert r.shape == expected_shape assert v.shape == expected_shape
def test_single_satellite_multiple_dates_large( single_satellite_multiple_dates_data_large, benchmark): ( (line1, line2), epochs, expected_shape, ) = single_satellite_multiple_dates_data_large jd, fr = jday_from_epochs(epochs) mjds = (jd - 2400000.5) + fr tles = np.array([PyTle("_", line1, line2)]) result = benchmark(propagate_many, mjds, tles) r = result["eci_pos"] v = result["eci_vel"] assert r.shape == expected_shape assert v.shape == expected_shape
def test_single_satellite_multiple_dates_medium( single_satellite_multiple_dates_data_medium, benchmark): ( (line1, line2), epochs, expected_rs, expected_vs, ) = single_satellite_multiple_dates_data_medium jd, fr = jday_from_epochs(epochs) mjds = (jd - 2400000.5) + fr tles = np.array([PyTle("_", line1, line2)]) result = benchmark(propagate_many, mjds, tles) r = result["eci_pos"] v = result["eci_vel"] assert_allclose(r, expected_rs, rtol=1e-6) # Default rtol=1e-7 makes test fail assert_allclose(v, expected_vs, rtol=1e-6) # Default rtol=1e-7 makes test fail
# ---------------------------------------------------- # Based on the README at https://github.com/bwinkel/cysgp4 import numpy as np from cysgp4 import PyTle, PyObserver, propagate_many with open('science.txt') as f: text = f.read() all_lines = text.splitlines() # Need to convert them to a list of tuples (each tuple consisting # of the three TLE strings) tle_list = list(zip(*tuple(all_lines[idx::3] for idx in range(3)))) # Create an array of PyTle and PyObserver objects, and MJDs tles = np.array([PyTle(*tle) for tle in tle_list])[np.newaxis, np.newaxis, :20] # use first 20 TLEs mjds = np.linspace( 58805.5, 58806.5, 1000 # 1000 time steps )[:, np.newaxis, np.newaxis] t0 = __import__('time').time() result = propagate_many(mjds, tles, None, do_eci_pos=True, do_eci_vel=True, do_geo=False,
from cysgp4 import PyTle, PyObserver, propagate_many # http://celestrak.com/NORAD/elements/science.txt with open('science.txt') as f: text = f.read() all_lines = text.splitlines() # Need to convert them to a list of tuples (each tuple consisting # of the three TLE strings) tle_list = list(zip(*tuple( all_lines[idx::3] for idx in range(3) ))) # Create an array of PyTle and PyObserver objects, and MJDs tles = np.array([ PyTle(*tle) for tle in tle_list ])[np.newaxis, np.newaxis, :20] # use first 20 TLEs mjds = np.linspace( 58805.5, 58806.5, 1000 # 1000 time steps )[:, np.newaxis, np.newaxis] t0 = __import__('time').time() result = propagate_many( mjds, tles, None, do_eci_pos=True, do_eci_vel=True, do_geo=False, do_topo=False ) print('TIME:', __import__('time').time() - t0) print(result.keys()) print(result['eci_pos'].shape) print(result['eci_pos'][0,:,:10,:])