def test_from_oo(): """test from_oo method""" try: import pyoorb except ImportError: return None orbit = Orbit.from_horizons('Ceres') horizons_ephem = Ephem.from_horizons('Ceres', location='500') oo_ephem = Ephem.from_oo(orbit) u.isclose(horizons_ephem['ra'][0], oo_ephem['ra'][0]) u.isclose(horizons_ephem['dec'][0], oo_ephem['dec'][0]) u.isclose(horizons_ephem['RA*cos(Dec)_rate'][0], oo_ephem['RA*cos(Dec)_rate'][0]) u.isclose(horizons_ephem['dec_rate'][0], oo_ephem['dec_rate'][0]) u.isclose(horizons_ephem['alpha'][0], oo_ephem['alpha'][0]) u.isclose(horizons_ephem['r'][0], oo_ephem['r'][0]) u.isclose(horizons_ephem['delta'][0], oo_ephem['delta'][0]) u.isclose(horizons_ephem['V'][0], oo_ephem['V'][0]) u.isclose(horizons_ephem['hlon'][0], oo_ephem['hlon'][0]) u.isclose(horizons_ephem['hlat'][0], oo_ephem['hlat'][0]) u.isclose(horizons_ephem['EL'][0], oo_ephem['EL'][0]) # test manual orbit definition lacking units manorbit = Orbit.from_dict({ 'targetname': orbit['targetname'][0], 'a': orbit['a'].value[0], 'e': orbit['e'][0], 'i': orbit['i'].value[0], 'w': orbit['w'].value[0], 'Omega': orbit['Omega'].value[0], 'datetime_jd': orbit['datetime_jd'][0].value, 'M': orbit['M'].value[0], 'H': orbit['H'].value[0], 'G': orbit['G'][0], 'timescale': orbit['timescale'][0] }) oo_ephem = Ephem.from_oo(manorbit) u.isclose(horizons_ephem['ra'][0], oo_ephem['ra'][0]) u.isclose(horizons_ephem['dec'][0], oo_ephem['dec'][0]) u.isclose(horizons_ephem['RA*cos(Dec)_rate'][0], oo_ephem['RA*cos(Dec)_rate'][0]) u.isclose(horizons_ephem['dec_rate'][0], oo_ephem['dec_rate'][0]) u.isclose(horizons_ephem['alpha'][0], oo_ephem['alpha'][0]) u.isclose(horizons_ephem['r'][0], oo_ephem['r'][0]) u.isclose(horizons_ephem['delta'][0], oo_ephem['delta'][0]) u.isclose(horizons_ephem['V'][0], oo_ephem['V'][0]) u.isclose(horizons_ephem['hlon'][0], oo_ephem['hlon'][0]) u.isclose(horizons_ephem['hlat'][0], oo_ephem['hlat'][0]) u.isclose(horizons_ephem['EL'][0], oo_ephem['EL'][0])
def test_oo_transform(): """ test oo_transform method""" try: import pyoorb except ImportError: return None orbit = Orbit.from_horizons('Ceres') cart_orbit = orbit.oo_transform('CART') kep_orbit = cart_orbit.oo_transform('KEP') u.isclose(orbit['a'][0], kep_orbit['a'][0]) u.isclose(orbit['e'][0], kep_orbit['e'][0]) u.isclose(orbit['i'][0], kep_orbit['i'][0]) u.isclose(orbit['Omega'][0], kep_orbit['Omega'][0]) u.isclose(orbit['w'][0], kep_orbit['w'][0]) u.isclose(orbit['M'][0], kep_orbit['M'][0]) u.isclose(orbit['epoch'][0], kep_orbit['epoch'][0]) com_orbit = orbit.oo_transform('COM') kep_orbit = com_orbit.oo_transform('KEP') u.isclose(orbit['a'][0], kep_orbit['a'][0]) u.isclose(orbit['e'][0], kep_orbit['e'][0]) u.isclose(orbit['i'][0], kep_orbit['i'][0]) u.isclose(orbit['Omega'][0], kep_orbit['Omega'][0]) u.isclose(orbit['w'][0], kep_orbit['w'][0]) u.isclose(orbit['M'][0], kep_orbit['M'][0]) u.isclose(orbit['epoch'][0], kep_orbit['epoch'][0])
def args2orbit(args): try: Tp = float(args.Tp) except ValueError: Tp = args.Tp try: epoch = float(args.epoch) except ValueError: epoch = args.epoch orbit = Orbit.from_dict({ 'M': args.M, 'K': args.K, 'H': 5, 'G': 0.15, 'q': args.q * u.au, 'e': args.e, 'incl': args.i * u.deg, 'Omega': args.node * u.deg, 'w': args.argperi * u.deg, 'Tp_jd': epochs_to_time([Tp], scale='tt').jd * u.day }) orbit['orbittype'] = ['COM'] orbit['epoch'] = epochs_to_time([epoch], scale='tt') return orbit
def test_oo_propagate(): """ test oo_propagate method""" try: import pyoorb except ImportError: return None orbit = Orbit.from_horizons('Ceres') epoch = Time.now().jd + 100 future_orbit = Orbit.from_horizons('Ceres', epochs=epoch) oo_orbit = orbit.oo_propagate(epoch) u.isclose(oo_orbit['a'][0], future_orbit['a'][0]) u.isclose(oo_orbit['e'][0], future_orbit['e'][0]) u.isclose(oo_orbit['i'][0], future_orbit['i'][0]) u.isclose(oo_orbit['Omega'][0], future_orbit['Omega'][0]) u.isclose(oo_orbit['w'][0], future_orbit['w'][0]) u.isclose(oo_orbit['M'][0], future_orbit['M'][0]) u.isclose(oo_orbit['epoch'][0], future_orbit['epoch'][0])
def test_from_horizons(): """ test from_horizons method""" # current epoch now = Time.now() data = Orbit.from_horizons('Ceres') assert_allclose(data['datetime_jd'], now.jd*u.d) # date range - astropy.time.Time objects epochs = {'start': Time('2018-01-02', format='iso'), 'stop': Time('2018-01-05', format='iso'), 'step': '6h'} data = Orbit.from_horizons('Ceres', epochs=epochs) assert len(data.table) == 13 # date range - strings epochs = {'start': '2018-01-02', 'stop': '2018-01-05', 'step': '6h'} data = Orbit.from_horizons('Ceres', epochs=epochs) assert len(data.table) == 13 # discrete epochs - astropy.time.Time objects epochs = [Time('2018-01-02', format='iso'), Time('2018-01-05', format='iso')] data = Orbit.from_horizons('Ceres', epochs=epochs) assert len(data.table) == 2 # discrete epochs - Julian Dates epochs = [Time('2018-01-02', format='iso').jd, Time('2018-01-05', format='iso').jd] data = Orbit.from_horizons('Ceres', epochs=epochs) assert len(data.table) == 2 # query two objects data = Orbit.from_horizons(['Ceres', 'Pallas']) assert len(data.table) == 2 # test bib service with bib.Tracking(): data = Orbit.from_horizons(['Ceres', 'Pallas']) assert 'sbpy.data.Orbit' in bib.to_text() bib.reset()
def test_bib(self): bib.track() orbit = Orbit.from_horizons('Ceres') oo_ephem = Ephem.from_oo(orbit, scope='basic') assert 'sbpy.data.ephem.Ephem.from_oo' in bib.to_text()
def test_timescale(self): orbit = Orbit.from_horizons('Ceres') oo_ephem = Ephem.from_oo(orbit, scope='basic') assert oo_ephem['epoch'].scale == 'tai'
def test_basic(self): orbit = Orbit.from_horizons('Ceres') oo_ephem = Ephem.from_oo(orbit, scope='basic') assert 'dec_rate' not in oo_ephem.field_names