def test_new_horizontal(timepairs, planets_list): """ Tests of generating a full position in horizontal coordinates. Uses fixtures to iterate through date pairs and planets to generate individual tests. """ jd_tt = timepairs[0] delta_t = timepairs[1] planet_name = planets_list[0] planet_code = planets_list[1] position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = coordinates.Topos('75 W', '45 N', 0.0, temperature=10.0, pressure=1010.0) ggr.earth = emp.earth ggr.ephemeris = emp xp = yp = 0.0 # replaces the for loop obj = c.make_object(0, planet_code, 'planet', None) ra, dec, dis = c.topo_planet(jd_tt, delta_t, obj, position) jd_ut1 = jd_tt - delta_t / 86400.0 (zd, az), (ra, dec) = c.equ2hor( jd_ut1, delta_t, xp, yp, position, ra, dec, ref_option=0) planet = getattr(emp, planet_name) jd = JulianDate(tt=jd_tt, delta_t=delta_t) h = ggr(jd).observe(planet).apparent().horizontal() eq(zd * TAU / 360.0, h.zd, 0.001 * arcsecond) eq(az * TAU / 360.0, h.az, 0.001 * arcsecond) eq(0.25 * TAU - zd * TAU / 360.0, h.alt, 0.001 * arcsecond) eq(dis, h.distance, 0.001 * meter)
def test_altaz(jd, planet_name_and_code): """ Tests of generating a full position in altaz coordinates. Uses fixtures to iterate through date pairs and planets to generate individual tests. """ planet_name, planet_code = planet_name_and_code position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = positionlib.Topos('45 N', '75 W', 0.0, temperature=10.0, pressure=1010.0) ggr.ephemeris = de405 xp = yp = 0.0 obj = c.make_object(0, planet_code, 'planet', None) ra, dec, dis = c.topo_planet(jd.tt, jd.delta_t, obj, position) (zd0, az0), (ra, dec) = c.equ2hor(jd.ut1, jd.delta_t, xp, yp, position, ra, dec) alt0 = 90.0 - zd0 planet = getattr(de405, planet_name) g = ggr(jd) distance = length_of((g - planet(jd)).position.AU) alt, az, d = g.observe(planet).apparent().altaz() eq(az0, az.degrees(), 0.001 * arcsecond_in_degrees) eq(alt0, alt.degrees(), 0.001 * arcsecond_in_degrees) eq(dis, distance, 0.5 * meter)
def _compute_local_coords(self, jd): delta_t = jd.tt_minus_ut jd_tt = jd.as_tt() jd_ut1 = jd.as_ut1() rat, dect, dist = topo_planet(jd_tt, delta_t, ss_body=self._sun, position=self._geo_loc) (zd, az), (rar, decr) = equ2hor(jd_ut1, delta_t, xp=0.0, yp=0.0, location = self._geo_loc, ra = rat, dec = dect, ref_option = 2 ) el = 90 - zd return (el,az)
def test_topo_planet(self): position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = coordinates.Topos('75 W', '45 N', 0.0, temperature=10.0, pressure=1010.0) ggr.earth = self.e.earth ggr.ephemeris = self.e for (jd_tt, delta_t), name in product([P0, PA, PB], planets_to_test): obj = c.make_object(0, planet_codes[name], 'planet', None) ra, dec, dis = c.topo_planet(jd_tt, delta_t, obj, position) planet = getattr(self.e, name) jd = JulianDate(tt=jd_tt, delta_t=delta_t) g = ggr(jd).observe(planet).apparent() self.eq(ra * tau / 24.0, g.ra, 0.001 * arcsecond) self.eq(dec * tau / 360.0, g.dec, 0.001 * arcsecond) self.eq(dis, g.distance, 0.001 * meter)
def test_topo_planet(jd, planet_name_and_code): position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = positionlib.Topos('45 N', '75 W', 0.0, temperature=10.0, pressure=1010.0) ggr.ephemeris = de405 planet_name, planet_code = planet_name_and_code obj = c.make_object(0, planet_code, 'planet', None) ra0, dec0, distance0 = c.topo_planet(jd.tt, jd.delta_t, obj, position) planet = getattr(de405, planet_name) g = ggr(jd) distance = length_of((g - planet(jd)).position.AU) ra, dec, d = g.observe(planet).apparent().radec(epoch=jd) eq(ra0, ra.hours(), 0.001 * arcsecond_in_hours) eq(dec0, dec.degrees(), 0.001 * arcsecond_in_degrees) eq(distance0, distance, 0.5 * meter)
def test_topo_planet(timepairs, planets_list): position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = coordinates.Topos('75 W', '45 N', 0.0, temperature=10.0, pressure=1010.0) ggr.earth = emp.earth ggr.ephemeris = emp jd_tt = timepairs[0] delta_t = timepairs[1] planet_name = planets_list[0] planet_code = planets_list[1] obj = c.make_object(0, planet_code, 'planet', None) ra, dec, dis = c.topo_planet(jd_tt, delta_t, obj, position) planet = getattr(emp, planet_name) jd = JulianDate(tt=jd_tt, delta_t=delta_t) g = ggr(jd).observe(planet).apparent() eq(ra * TAU / 24.0, g.ra, 0.001 * arcsecond) eq(dec * TAU / 360.0, g.dec, 0.001 * arcsecond) eq(dis, g.distance, 0.001 * meter)
def test_horizontal(self): position = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) ggr = coordinates.Topos('75 W', '45 N', 0.0, temperature=10.0, pressure=1010.0) ggr.earth = self.e.earth ggr.ephemeris = self.e xp = yp = 0.0 for (jd_tt, delta_t), name in product([P0, PA, PB], planets_to_test): obj = c.make_object(0, planet_codes[name], 'planet', None) ra, dec, dis = c.topo_planet(jd_tt, delta_t, obj, position) jd_ut1 = jd_tt - delta_t / 86400.0 (zd, az), (ra, dec) = c.equ2hor( jd_ut1, delta_t, xp, yp, position, ra, dec, ref_option=0) planet = getattr(self.e, name) jd = JulianDate(tt=jd_tt, delta_t=delta_t) h = ggr(jd).observe(planet).apparent().horizontal() self.eq(zd * tau / 360.0, h.zd, 0.001 * arcsecond) self.eq(az * tau / 360.0, h.az, 0.001 * arcsecond) self.eq(0.25 * tau - zd * tau / 360.0, h.alt, 0.001 * arcsecond) self.eq(dis, h.distance, 0.001 * meter)
def altaz_maneuver(jd, obj, place): """Simplify a pair of complicated USNO calls to a single callable.""" xp = yp = 0.0 ra, dec, distance = novas.topo_planet(jd, 0.0, obj, place) (zd, az), (ra, dec) = novas.equ2hor(jd, 0.0, xp, yp, place, ra, dec) return 90.0 - zd, az