Пример #1
0
def test_observing_earth_from_location_on_moon_with_time_vector():
    # See the above test for a more thorough blow-by-blow test of this
    # complete operation.  Here, we simply run through it quickly and
    # test only the end result, to see if the operation more thoroughly
    # tested above will also work when given a time vector.

    ts = load.timescale()
    t = ts.utc(2019, 12, [13, 14])

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

    frame = pc.build_frame_named('MOON_ME_DE421')
    pt = pc.build_latlon_degrees(frame, 26.3, 313.2)
    eph = load('de421.bsp')
    astrometric = (eph['moon'] + pt).at(t).observe(eph['earth'])
    apparent = astrometric.apparent()
    alt, az, distance = apparent.altaz()

    want = (42.0019, 40.7411), (114.9380, 116.3859)
    pair = alt.degrees, az.degrees
    arcsecond = 1.0 / 3600.0
    assert abs(np.array(want) - pair).max() < 12 * arcsecond
Пример #2
0
def moon_subsolar_point(t):
    eph = load('de421.bsp')
    sun = eph['sun']
    moon = eph['moon']

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))
    frame = pc.build_frame_named('MOON_ME_DE421')

    place = moon + pc.build_latlon_degrees(frame, 90.0, 180.0)
    sunpos = place.at(t).observe(sun).apparent()
    lat, lon, dist = sunpos.altaz()
    return lat.degrees, wrap180(lon.degrees), dist.km
Пример #3
0
def run():
    rospy.init_node('sun_seeker_node', anonymous=True)
    rospy.Subscriber('/clock', Clock, sim_time_callback)

    pub = rospy.Publisher('/sun_seeker/vector', Vector3, queue_size=1)
    rate = rospy.Rate(0.1)

    eph = load('de421.bsp')
    sun = eph['sun']
    moon = eph['moon']

    path = os.path.realpath(__file__)
    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

    frame = pc.build_frame_named('MOON_ME_DE421')
    place = moon + pc.build_latlon_degrees(frame, -86.79430, -21.18640)

    sun_angle_msg = Vector3()

    while not rospy.is_shutdown():
        dt = datetime.fromtimestamp(sim_time)
        dt_utc = dt.replace(tzinfo=pytz.UTC)
        ts = load.timescale()
        t = ts.from_datetime(dt_utc)

        sunpos = place.at(t).observe(sun).apparent()
        alt, az, distance = sunpos.altaz()

        sun_angle_msg.x = 0.0
        sun_angle_msg.y = alt.degrees
        sun_angle_msg.z = az.degrees

        if rospy.get_time() - last_msg_time < msg_timeout:
            rospy.loginfo('Publishing vector: x = {0:.3f}, y = {1:.3f}, z = {2:.3f}'.format(sun_angle_msg.x, sun_angle_msg.y, sun_angle_msg.z))
            pub.publish(sun_angle_msg)
        else:
            rospy.logwarn('Timeout {0:.1f} seconds: Is /clock publishing?'.format(msg_timeout))
        
        rate.sleep()
Пример #4
0
def test_using_elevation_to_locate_center_of_moon():
    # Test the `elevation_m` parameter by using it to offset a Moon
    # surface location back to the Moon's center.

    ts = load.timescale()
    t = ts.utc(2020, 4, 23)

    eph = load('de421.bsp')
    a1 = eph['moon'].at(t)

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))
    frame = pc.build_frame_named('MOON_ME_DE421')

    place = pc.build_latlon_degrees(frame, 26.3, 313.2, -1737400)
    a2 = (eph['moon'] + place).at(t)

    mm = 1e-3
    assert max(abs(a1.position.m - a2.position.m)) < mm
Пример #5
0
def test_horizons_position_of_latitude_longitude_on_moon():
    # This test against HORIZON is low-precision, with agreement only
    # within about 100m.  This is a symptom of the fact that here we are
    # using the recent high-accuracy MOON_ME frame, while HORIZONS says
    # it is using the old "IAU_MOON".  Alas, the NAIF presentation
    # `23_lunar-earth_pck-fk.pdf` says that the worse-case agreement
    # between the frames is 155m and is on average only 76m, so our low
    # agreement here is reasonable.
    #
    # See the file `horizons/moon-from-moon-topos` for the HORIZONS
    # result this test compares against.

    ts = load.timescale()
    t = ts.tdb_jd(2458827.5)

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

    frame = pc.build_frame_named('MOON_ME_DE421')
    assert frame.center == 301

    pt = pc.build_latlon_degrees(frame, 26.3, -46.8)
    assert pt.center == 301

    geometric = pt.at(t)
    assert geometric.center == 301

    # Note that the sign of these two vectors is flipped, since HORIZONS
    # measured the other direction, from the surface to the center.

    want = -1.043588965592271E-05, -3.340834944508400E-06, 3.848560523814720E-06
    meter = 1.0 / AU_M
    assert abs(geometric.position.au - want).max() < 101 * meter

    want = 3.480953228580460E-07, -2.173626424774260E-06, -9.429610667799021E-07
    assert abs(geometric.velocity.au_per_d - want).max() < 1.6e-10
Пример #6
0
def test_observing_earth_from_location_on_moon():
    ts = load.timescale()
    t = ts.utc(2019, 12, 13)

    pc = PlanetaryConstants()
    pc.read_text(load('moon_080317.tf'))
    pc.read_text(load('pck00008.tpc'))
    pc.read_binary(load('moon_pa_de421_1900-2050.bpc'))

    frame = pc.build_frame_named('MOON_ME_DE421')
    assert frame.center == 301

    pt = pc.build_latlon_degrees(frame, 26.3, 313.2)
    assert pt.center == 301

    eph = load('de421.bsp')
    astrometric = (eph['moon'] + pt).at(t).observe(eph['earth'])

    # See the file `horizons/earth-from-moon-topos` for the HORIZONS
    # source of the following `want` values.

    ra, dec, distance = astrometric.radec()
    want = 270.2590484, -22.8079717
    arcsecond = 1.0 / 3600.0
    assert abs(ra._degrees - want[0]) < 0.03 * arcsecond
    assert abs(dec.degrees - want[1]) < 0.03 * arcsecond

    # See the file `horizons/earth-from-moon-topos` for the HORIZONS
    # source of these angles.  TODO: Investigate how we descended from
    # the brilliant sub-arcsecond precision of the previous result to a
    # mere 12 arcseconds of agreement.
    apparent = astrometric.apparent()
    alt, az, distance = apparent.altaz()
    want = 42.0019, 114.9380
    pair = alt.degrees, az.degrees
    assert abs(np.array(want) - pair).max() < 12 * arcsecond