def output_topocentric_tests(dates): usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) for (planet, code), (i, jd) in product(planets, enumerate(dates)): obj = novas.make_object(0, code, 'planet{}'.format(code), None) ra1, dec1, distance1 = call(novas.local_planet, jd, 0.0, obj, usno) ra2, dec2, distance2 = call(novas.topo_planet, jd, 0.0, obj, usno) alt, az = call(altaz_maneuver, jd, obj, usno) output(locals(), """\ def test_{planet}_topocentric_date{i}(): jd = JulianDate(tt={jd!r}) usno = de405.earth.topos('38.9215 N', '77.0669 W', elevation_m=92.0) apparent = usno(jd).observe(de405.{planet}).apparent() ra, dec, distance = apparent.radec() compare(ra.hours, {ra1!r}, 0.001 * ra_arcsecond) compare(dec.degrees, {dec1!r}, 0.001 * arcsecond) ra, dec, distance = apparent.radec(epoch='date') compare(ra.hours, {ra2!r}, 0.001 * ra_arcsecond) compare(dec.degrees, {dec2!r}, 0.001 * arcsecond) alt, az, distance = apparent.altaz() compare(alt.degrees, {alt!r}, 0.001 * arcsecond) compare(az.degrees, {az!r}, 0.001 * arcsecond) """)
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 _update_geo_loc(self): self._geo_loc = make_on_surface(self._latitude, self._longitude, self._height, self._temperature, self._pressure )
def test_setup_LSST_location(): test_site = make_on_surface(10.0, 10.0, 10.0, 10.0, 10.0) lsst = lsst_visibility_calculator.setup_LSST_location() assert type(lsst) == type(test_site) assert lsst.height == 2663.0 assert lsst.latitude == -30.244639 assert lsst.longitude == -70.749417
def setup_LSST_location(): """Function to build a NOVAS-compatible observatory descriptor for the LSST site""" height = 2663.0 latitude = -30.244639 longitude = -70.749417 temperature = 10.0 pressure = 750.0 lsst = make_on_surface(latitude, longitude, height, temperature, pressure) return lsst
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 output_topocentric_tests(dates): usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) for (planet, code), (i, jd) in product(planets, enumerate(dates)): slug = slugify(planet) obj = novas.make_object(0, code, 'planet{0}'.format(code), None) ra1, dec1, distance1 = call(novas.local_planet, jd, 0.0, obj, usno) ra2, dec2, distance2 = call(novas.topo_planet, jd, 0.0, obj, usno) alt, az = call(altaz_maneuver, jd, usno, ra2, dec2) alt2, az2 = call(altaz_maneuver, jd, usno, ra2, dec2, 1) alt3, az3 = call(altaz_maneuver, jd, usno, ra2, dec2, 2) output( locals(), """\ def test_{slug}_topocentric_date{i}(de405): t = load.timescale(delta_t=0.0).tt_jd({jd!r}) earth = de405['earth'] usno = earth + Topos('38.9215 N', '77.0669 W', elevation_m=92.0) apparent = usno.at(t).observe(de405[{planet!r}]).apparent() ra, dec, distance = apparent.radec() compare(ra.hours, {ra1!r}, 0.0005 * ra_arcsecond) compare(dec.degrees, {dec1!r}, 0.0005 * arcsecond) ra, dec, distance = apparent.radec(epoch='date') compare(ra.hours, {ra2!r}, 0.0005 * ra_arcsecond) compare(dec.degrees, {dec2!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz() compare(alt.degrees, {alt!r}, 0.0005 * arcsecond) compare(az.degrees, {az!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz('standard') compare(alt.degrees, {alt2!r}, 0.0005 * arcsecond) compare(az.degrees, {az2!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz(10.0, 1010.0) compare(alt.degrees, {alt3!r}, 0.0005 * arcsecond) compare(az.degrees, {az3!r}, 0.0005 * arcsecond) """)
def output_topocentric_tests(dates): usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) for (planet, code), (i, jd) in product(planets, enumerate(dates)): slug = slugify(planet) obj = novas.make_object(0, code, 'planet{0}'.format(code), None) ra1, dec1, distance1 = call(novas.local_planet, jd, 0.0, obj, usno) ra2, dec2, distance2 = call(novas.topo_planet, jd, 0.0, obj, usno) alt, az = call(altaz_maneuver, jd, usno, ra2, dec2) alt2, az2 = call(altaz_maneuver, jd, usno, ra2, dec2, 1) alt3, az3 = call(altaz_maneuver, jd, usno, ra2, dec2, 2) output(locals(), """\ def test_{slug}_topocentric_date{i}(de405): t = load.timescale(delta_t=0.0).tt(jd={jd!r}) earth = de405['earth'] usno = earth.topos('38.9215 N', '77.0669 W', elevation_m=92.0) apparent = usno.at(t).observe(de405[{planet!r}]).apparent() ra, dec, distance = apparent.radec() compare(ra.hours, {ra1!r}, 0.0005 * ra_arcsecond) compare(dec.degrees, {dec1!r}, 0.0005 * arcsecond) ra, dec, distance = apparent.radec(epoch='date') compare(ra.hours, {ra2!r}, 0.0005 * ra_arcsecond) compare(dec.degrees, {dec2!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz() compare(alt.degrees, {alt!r}, 0.0005 * arcsecond) compare(az.degrees, {az!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz('standard') compare(alt.degrees, {alt2!r}, 0.0005 * arcsecond) compare(az.degrees, {az2!r}, 0.0005 * arcsecond) alt, az, distance = apparent.altaz(10.0, 1010.0) compare(alt.degrees, {alt3!r}, 0.0005 * arcsecond) compare(az.degrees, {az3!r}, 0.0005 * arcsecond) """)
def test_terra(): epsilon = 1e-18 observer = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) class Topos(object): latitude = 45.0 * DEG2RAD longitude = -75.0 * DEG2RAD elevation = 0.0 topos = Topos() pos0, vel0 = array(c.terra(observer, 11.0)) pos1, vel1 = array(c.terra(observer, 23.9)) posn, veln = earthlib.terra(topos, array([11.0, 23.9])) eq(pos0, posn[:,0], epsilon) eq(pos1, posn[:,1], epsilon) eq(vel0, veln[:,0], epsilon) eq(vel1, veln[:,1], epsilon)
def output_topocentric_tests(dates): usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) for (planet, code), (i, jd) in product(planets, enumerate(dates)): obj = novas.make_object(0, code, 'planet{}'.format(code), None) ra1, dec1, distance1 = call(novas.local_planet, jd, 0.0, obj, usno) ra2, dec2, distance2 = call(novas.topo_planet, jd, 0.0, obj, usno) alt, az = call(altaz_maneuver, jd, usno, ra2, dec2) alt2, az2 = call(altaz_maneuver, jd, usno, ra2, dec2, 1) alt3, az3 = call(altaz_maneuver, jd, usno, ra2, dec2, 2) output( locals(), """\ def test_{planet}_topocentric_date{i}(): jd = JulianDate(tt={jd!r}) usno = de405.earth.topos('38.9215 N', '77.0669 W', elevation_m=92.0) apparent = usno(jd).observe(de405.{planet}).apparent() ra, dec, distance = apparent.radec() compare(ra.hours, {ra1!r}, 0.001 * ra_arcsecond) compare(dec.degrees, {dec1!r}, 0.001 * arcsecond) ra, dec, distance = apparent.radec(epoch='date') compare(ra.hours, {ra2!r}, 0.001 * ra_arcsecond) compare(dec.degrees, {dec2!r}, 0.001 * arcsecond) alt, az, distance = apparent.altaz() compare(alt.degrees, {alt!r}, 0.001 * arcsecond) compare(az.degrees, {az!r}, 0.001 * arcsecond) alt, az, distance = apparent.altaz('standard') compare(alt.degrees, {alt2!r}, 0.001 * arcsecond) compare(az.degrees, {az2!r}, 0.001 * arcsecond) alt, az, distance = apparent.altaz(10.0, 1010.0) compare(alt.degrees, {alt3!r}, 0.001 * arcsecond) compare(az.degrees, {az3!r}, 0.001 * arcsecond) """)
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_terra(): observer = c.make_on_surface(45.0, -75.0, 0.0, 10.0, 1010.0) # Note that this class stands in for a NOVAS Topos structure, but # not for our own Topos class! class Topos(object): latitude = 45.0 * DEG2RAD longitude = -75.0 * DEG2RAD elevation = 0.0 topos = Topos() pos0, vel0 = array(c.terra(observer, 11.0)) pos1, vel1 = array(c.terra(observer, 23.9)) posn, veln = earthlib.terra(topos, array([11.0, 23.9])) epsilon = 1e-8 * meter # 14 digits of agreement eq(pos0, posn[:,0], epsilon) eq(pos1, posn[:,1], epsilon) eq(vel0, veln[:,0], epsilon) eq(vel1, veln[:,1], epsilon)
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 output_subroutine_tests(dates): date_floats = [d for d in dates if not isinstance(d, list)] delta_t_floats = [+39.707, +57.1136, +63.8285, +66.7846] def shorter_cal_date(jd): y, m, d, h = novas.cal_date(jd) return y, m, d + h / 24.0 - 0.5 for i, jd in enumerate(date_floats): cal_date = call(shorter_cal_date, jd) output( locals(), """\ def test_calendar_date_{i}(): compare(timelib.calendar_date({jd!r}), array({cal_date}), 0.0) """) for i, jd in enumerate(date_floats): angle = novas.era(jd) output( locals(), """\ def test_earth_rotation_angle_date{i}(): compare(earthlib.earth_rotation_angle({jd!r}) * 360.0, {angle!r}, 0.000001 * arcsecond) """) for i, jd in enumerate(date_floats): angles = novas.e_tilt(jd) output( locals(), """\ def test_earth_tilt_date{i}(ts): compare(nutationlib.earth_tilt(ts.tdb_jd({jd!r})), array({angles}), 0.00001 * arcsecond) """) for i, jd in enumerate(date_floats): terms = novas.ee_ct(jd, 0.0, 0) output( locals(), """\ def test_equation_of_the_equinoxes_complimentary_terms_date{i}(): compare(nutationlib.equation_of_the_equinoxes_complimentary_terms({jd!r}), array({terms!r}), 0.0000000000000001 * arcsecond) """) vector = (1.1, 1.2, 1.3) tie1 = novas.frame_tie(vector, 0) tie2 = novas.frame_tie(vector, -1) output( locals(), """\ def test_forward_frame_tie(): compare(framelib.ICRS_to_J2000.dot({vector}), {tie1}, 1e-15) def test_reverse_frame_tie(): compare(framelib.ICRS_to_J2000.T.dot({vector}), {tie2}, 1e-15) """) for i, jd in enumerate(date_floats): jcentury = (jd - T0) / 36525.0 arguments = novas.fund_args(jcentury) output( locals(), """\ def test_fundamental_arguments_date{i}(): compare(nutationlib.fundamental_arguments({jcentury!r}), array({arguments}), 0.000000002 * arcsecond) """) for i, jd in enumerate(date_floats): psi, eps = nutation_module.iau2000a(jd, 0.0) psi *= 1e7 / ASEC2RAD eps *= 1e7 / ASEC2RAD output( locals(), """\ def test_iau2000a_date{i}(): compare(nutationlib.iau2000a({jd!r}), array([{psi!r}, {eps!r}]), 0.001) """) for i, jd in enumerate(date_floats): psi, eps = nutation_module.iau2000b(jd, 0.0) psi *= 1e7 / ASEC2RAD eps *= 1e7 / ASEC2RAD output( locals(), """\ def test_iau2000b_date{i}(): compare(nutationlib.iau2000b({jd!r}), array([{psi!r}, {eps!r}]), 0.001) """) for i, args in enumerate([ (-4712, 1, 1, 0.0), (-4712, 3, 1, 0.0), (-4712, 12, 31, 0.5), (-241, 3, 25, 19.0), (530, 9, 27, 23.5), (1976, 3, 7, 12.5), (2000, 1, 1, 0.0), ]): jd = novas.julian_date(*args) output( locals(), """\ def test_julian_date_function_date{i}(): compare(timelib.julian_date{args}, {jd!r}, 0.0) """) for i, jd in enumerate(date_floats): angle = novas.mean_obliq(jd) output( locals(), """\ def test_mean_obliquity_date{i}(): compare(nutationlib.mean_obliquity({jd!r}), {angle!r}, 0.0) # arcseconds """) for i, jd in enumerate(date_floats): vector = [1.1, 1.2, 1.3] result = nutation_function(jd, vector) output( locals(), """\ def test_nutation_date{i}(ts): matrix = nutationlib.compute_nutation(ts.tdb_jd({jd!r})) result = einsum('ij...,j...->i...', matrix, [1.1, 1.2, 1.3]) compare({result}, result, 1e-14) """) for i, jd in enumerate(date_floats): vector = [1.1, 1.2, 1.3] result = novas.precession(T0, vector, jd) output( locals(), """\ def test_precession_date{i}(): matrix = precessionlib.compute_precession({jd!r}) result = einsum('ij...,j...->i...', matrix, [1.1, 1.2, 1.3]) compare({result}, result, 1e-15) """) for i, jd in enumerate(date_floats): result1 = novas.sidereal_time(jd, 0.0, 0.0, False, True) result2 = novas.sidereal_time(jd, 0.0, 99.9, False, True) output( locals(), """\ def test_sidereal_time_on_date{i}(): jd = load.timescale(delta_t=0.0).tt_jd({jd!r}) compare(earthlib.sidereal_time(jd), {result1!r}, 1e-13) def test_sidereal_time_with_nonzero_delta_t_on_date{i}(): jd = load.timescale(delta_t=99.9).tt_jd({jd!r} + 99.9 * one_second) compare(earthlib.sidereal_time(jd), {result2!r}, 1e-13) """) p, v = novas.starvectors( novas.make_cat_entry('POLARIS', 'HIP', 0, 2.530301028, 89.264109444, 44.22, -11.75, 7.56, -17.4)) output( locals(), """\ def test_star_vector(): star = starlib.Star(ra_hours=2.530301028, dec_degrees=89.264109444, ra_mas_per_year=44.22, dec_mas_per_year=-11.75, parallax_mas=7.56, radial_km_per_s=-17.4) star.au_km = OLD_AU_KM star._compute_vectors() compare(star._position_au, {p!r}, 1e3 * meter) compare(star._velocity_au_per_d, {v!r}, 1e-3 * meter) # TODO: was 1e-6 before switch to modern au """) atp = product([-5, -1, 15, 89.95], [10, 25], [1010, 1013.25]) for i, (angle, temperature, pressure) in enumerate(atp): location = novas.make_on_surface(0.0, 0.0, 0, temperature, pressure) r = novas.refract(location, 90 - angle, 2) output( locals(), """\ def test_refraction{i}(): r = earthlib.refraction({angle}, {temperature}, {pressure}) compare(r, {r!r}, 1e-9 * arcsecond) """) northpole = novas.make_on_surface(90.0, 0.0, 0.0, 10.0, 1010.0) for i, angle in enumerate([-90, -2, -1, 0, 1, 3, 9, 90]): alt, az = altaz_maneuver(T0, northpole, 0.0, angle, ref=2) output( locals(), """\ def test_refract{i}(): alt = earthlib.refract({angle!r}, 10.0, 1010.0) compare(alt, {alt!r}, 1e-9 * arcsecond) """) usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) ra = 12.34 for i, (tt, dec) in enumerate(product(date_floats, [56.78, -67.89])): alt, az = altaz_maneuver(tt, usno, ra, dec, ref=0) output( locals(), """\ def test_from_altaz_{i}(earth): jd = load.timescale(delta_t=0.0).tt_jd({tt!r}) usno = earth + Topos( '38.9215 N', '77.0669 W', elevation_m=92.0) a = usno.at(jd).from_altaz(alt_degrees={alt!r}, az_degrees={az!r}) ra, dec, distance = a.radec(epoch=jd) compare(ra.hours, {ra!r}, 1e-9 * arcsecond) compare(dec.degrees, {dec!r}, 1e-9 * arcsecond) """) for i, (tt, delta_t) in enumerate(zip(date_floats, delta_t_floats)): jd_low = xp = yp = 0.0 vector = [1.1, 1.2, 1.3] ut1 = tt - delta_t * one_second result = novas.ter2cel(ut1, jd_low, delta_t, xp, yp, vector) output( locals(), """\ def test_ITRF_to_GCRS_conversion_on_date{i}(): jd = load.timescale(delta_t={delta_t!r}).tt_jd({tt!r}) position = positionlib.ITRF_to_GCRS(jd, {vector!r}) compare(position, {result!r}, 1e-13) """) for i, jd_tdb in enumerate(date_floats): result = novas.tdb2tt(jd_tdb)[1] output( locals(), """\ def test_tdb_minus_tt_on_date{i}(): result = timelib.tdb_minus_tt({jd_tdb!r}) compare(result, {result!r}, 1e-16) """)
def output_subroutine_tests(dates): date_floats = [d for d in dates if not isinstance(d, list)] delta_t_floats = [+39.707, +57.1136, +63.8285, +66.7846] def shorter_cal_date(jd): y, m, d, h = novas.cal_date(jd) return y, m, d + h / 24.0 - 0.5 for i, jd in enumerate(date_floats): cal_date = call(shorter_cal_date, jd) output(locals(), """\ def test_calendar_date_{i}(): compare(timelib.calendar_date({jd!r}), array({cal_date}), 0.0) """) for i, jd in enumerate(date_floats): angle = novas.era(jd) output(locals(), """\ def test_earth_rotation_angle_date{i}(): compare(earthlib.earth_rotation_angle({jd!r}) * 360.0, {angle}, 0.000001 * arcsecond) """) for i, jd in enumerate(date_floats): angles = novas.e_tilt(jd) output(locals(), """\ def test_earth_tilt_date{i}(): compare(nutationlib.earth_tilt(JulianDate(tdb={jd!r})), array({angles}), 0.00001 * arcsecond) """) for i, jd in enumerate(date_floats): terms = novas.ee_ct(jd, 0.0, 0) output(locals(), """\ def test_equation_of_the_equinoxes_complimentary_terms_date{i}(): compare(nutationlib.equation_of_the_equinoxes_complimentary_terms({jd!r}), array({terms}), 0.0000000000000001 * arcsecond) """) vector = (1.1, 1.2, 1.3) tie1 = novas.frame_tie(vector, 0) tie2 = novas.frame_tie(vector, -1) output(locals(), """\ def test_forward_frame_tie(): compare(framelib.ICRS_to_J2000.dot({vector}), {tie1}, 1e-15) def test_reverse_frame_tie(): compare(framelib.ICRS_to_J2000.T.dot({vector}), {tie2}, 1e-15) """) for i, jd in enumerate(date_floats): jcentury = (jd - T0) / 36525.0 arguments = novas.fund_args(jcentury) output(locals(), """\ def test_fundamental_arguments_date{i}(): compare(nutationlib.fundamental_arguments({jcentury!r}), array({arguments}), 0.000000002 * arcsecond) """) for i, jd in enumerate(date_floats): psi, eps = nutation_module.iau2000a(jd, 0.0) psi *= 1e7 / ASEC2RAD eps *= 1e7 / ASEC2RAD output(locals(), """\ def test_iau2000a_date{i}(): compare(nutationlib.iau2000a({jd!r}), array([{psi}, {eps}]), 0.001) """) for i, args in enumerate([ (-4712, 1, 1, 0.0), (-4712, 3, 1, 0.0), (-4712, 12, 31, 0.5), (-241, 3, 25, 19.0), (530, 9, 27, 23.5), (1976, 3, 7, 12.5), (2000, 1, 1, 0.0), ]): jd = novas.julian_date(*args) output(locals(), """\ def test_julian_date_function_date{i}(): compare(timelib.julian_date{args}, {jd!r}, 0.0) """) for i, jd in enumerate(date_floats): angle = novas.mean_obliq(jd) output(locals(), """\ def test_mean_obliquity_date{i}(): compare(nutationlib.mean_obliquity({jd!r}), {angle!r}, 0.0) # arcseconds """) for i, jd in enumerate(date_floats): vector = [1.1, 1.2, 1.3] result = nutation_function(jd, vector) output(locals(), """\ def test_nutation_date{i}(): matrix = nutationlib.compute_nutation(JulianDate(tdb={jd!r})) result = einsum('ij...,j...->i...', matrix, [1.1, 1.2, 1.3]) compare({result}, result, 1e-14) """) for i, jd in enumerate(date_floats): vector = [1.1, 1.2, 1.3] result = novas.precession(T0, vector, jd) output(locals(), """\ def test_precession_date{i}(): matrix = precessionlib.compute_precession({jd!r}) result = einsum('ij...,j...->i...', matrix, [1.1, 1.2, 1.3]) compare({result}, result, 1e-15) """) for i, jd in enumerate(date_floats): result1 = novas.sidereal_time(jd, 0.0, 0.0, False, True) result2 = novas.sidereal_time(jd, 0.0, 99.9, False, True) output(locals(), """\ def test_sidereal_time_on_date{i}(): jd = JulianDate(tt={jd!r}) compare(earthlib.sidereal_time(jd), {result1!r}, 1e-13) def test_sidereal_time_with_nonzero_delta_t_on_date{i}(): jd = JulianDate(tt={jd!r} + 99.9 * one_second, delta_t=99.9) compare(earthlib.sidereal_time(jd), {result2!r}, 1e-13) """) p, v = novas.starvectors(novas.make_cat_entry( 'POLARIS', 'HIP', 0, 2.530301028, 89.264109444, 44.22, -11.75, 7.56, -17.4)) output(locals(), """\ def test_star_vector(): star = starlib.Star(ra_hours=2.530301028, dec_degrees=89.264109444, ra_mas_per_year=44.22, dec_mas_per_year=-11.75, parallax_mas=7.56, radial_km_per_s=-17.4) star.au_km = de405.jplephemeris.AU star._compute_vectors() compare(star._position_au, {p!r}, 1e3 * meter) compare(star._velocity_au_per_d, {v!r}, 1e-3 * meter) # TODO: was 1e-6 before switch to modern au """) atp = product([-5, -1, 15, 89.95], [10, 25], [1010, 1013.25]) for i, (angle, temperature, pressure) in enumerate(atp): location = novas.make_on_surface(0.0, 0.0, 0, temperature, pressure) r = novas.refract(location, 90 - angle, 2) output(locals(), """\ def test_refraction{i}(): r = earthlib.refraction({angle}, {temperature}, {pressure}) compare(r, {r}, 0.001 * arcsecond) """) northpole = novas.make_on_surface(90.0, 0.0, 0.0, 10.0, 1010.0) for i, angle in enumerate([-90, -2, -1, 0, 1, 3, 9, 90]): alt, az = altaz_maneuver(T0, northpole, 0.0, angle, ref=2) output(locals(), """\ def test_refract{i}(): alt = earthlib.refract({angle!r}, 10.0, 1010.0) compare(alt, {alt!r}, 0.000000001 * arcsecond) """) usno = novas.make_on_surface(38.9215, -77.0669, 92.0, 10.0, 1010.0) ra = 12.34 for i, (tt, dec) in enumerate(product(date_floats, [56.78, -67.89])): alt, az = altaz_maneuver(tt, usno, ra, dec, ref=0) output(locals(), """\ def test_from_altaz_{i}(): jd = JulianDate(tt={tt!r}) usno = de405.earth.topos( '38.9215 N', '77.0669 W', elevation_m=92.0) a = usno(jd).from_altaz(alt_degrees={alt!r}, az_degrees={az!r}) ra, dec, distance = a.radec(epoch=jd) compare(ra.hours, {ra!r}, 0.000000001 * arcsecond) compare(dec.degrees, {dec!r}, 0.000000001 * arcsecond) """) for i, (tt, delta_t) in enumerate(zip(date_floats, delta_t_floats)): jd_low = xp = yp = 0.0 vector = [1.1, 1.2, 1.3] ut1 = tt - delta_t * one_second result = novas.ter2cel(ut1, jd_low, delta_t, xp, yp, vector) output(locals(), """\ def test_ITRF_to_GCRS_conversion_on_date{i}(): jd = JulianDate(tt={tt!r}, delta_t={delta_t!r}) position = positionlib.ITRF_to_GCRS(jd, {vector!r}) compare(position, {result!r}, 1e-13) """) for i, jd_tdb in enumerate(date_floats): result = novas.tdb2tt(jd_tdb)[1] output(locals(), """\ def test_tdb_minus_tt_on_date{i}(): result = timelib.tdb_minus_tt({jd_tdb!r}) compare(result, {result!r}, 1e-16) """)
#tt-ut1 delta_t = tt_tai + leap_second - ut1_utc #构造不同的儒略日时间变量 jd_utc = novas.julian_date(year, month, day, hour) #utc jd_ut1 = jd_utc + ut1_utc / 86400.0 #ut1 jd_tt = jd_utc + (leap_second + tt_tai) / 86400.0 #tt jd = (jd_tt, 0.0) jd0 = (jd_tt - ta / 86400, 0.0) #打开de历表 jd_s, jd_e, num = eph_manager.ephem_open() #太阳和地球构造 sun = novas.make_object(0, 10, 'sun', None) moon = novas.make_object(0, 11, 'moon', None) earth = novas.make_object(0, 3, 'earth', None) #位置构造 location1 = novas.make_on_surface(latitude, longitude, height, 25.0, 1013) location = novas.make_observer_on_surface(latitude, longitude, height, 25.0, 1013) #矢量和夹角初始化 O1_S1 = [0.0, 0.0, 0.0] #月球半影锥点到太阳质心矢量坐标 O2_S1 = [0.0, 0.0, 0.0] #月球全影锥点到太阳质心矢量坐标 O1_E = [0.0, 0.0, 0.0] #月球半影锥点到地心距离矢量坐标 O1_T = [0.0, 0.0, 0.0] #月球半影锥点到地球某一点距离矢量坐标 O2_E = [0.0, 0.0, 0.0] #月球全影锥点到地心距离矢量坐标 O2_T = [0.0, 0.0, 0.0] #月球全影锥点到地球某一点距离矢量坐标 O1_M = [0.0, 0.0, 0.0] #月球半影锥点到月心距离矢量坐标 O2_M = [0.0, 0.0, 0.0] #月球全影锥点到月心距离矢量坐标 E_O4 = [0.0, 0.0, 0.0] #经纬度转为ITRS下坐标 E_T=[re*math.cos(latitude*constants.DEG2RAD)*math.cos(longitude*constants.DEG2RAD),\ re*math.cos(latitude*constants.DEG2RAD)*math.sin(longitude*constants.DEG2RAD),\