예제 #1
0
파일: gmu.py 프로젝트: olyoberdorf/DRAGONS
def toicrs(frame, ra, dec, equinox=2000.0, ut_datetime=None):
    # Utility function. Converts and RA and Dec in the specified reference frame
    # and equinox at ut_datetime into ICRS. This is used by the ra and dec descriptors.

    # Assume equinox is julian calendar
    equinox = 'J{}'.format(equinox)

    # astropy doesn't understand APPT coordinates. However, it does understand
    # CIRS coordinates, and we can convert from APPT to CIRS by adding the
    # equation of origins to the RA. We can get that using ERFA.
    # To proceed with this, we first let astopy construct the CIRS frame, so
    # that we can extract the obstime object from that to pass to erfa.
    appt_frame = (frame == 'APPT')
    if frame == 'APPT':
        frame = 'cirs'
    if frame == 'FK5':
        frame = 'fk5'

    # Try this with the passed frame but, if it doesn't work, convert to "cirs"
    # If that doesn't work, then raise an error
    try:
        coords = coordinates.SkyCoord(ra=ra * units.degree,
                                      dec=dec * units.degree,
                                      frame=frame,
                                      equinox=equinox,
                                      obstime=ut_datetime)
    except ValueError:
        frame = 'cirs'
        coords = coordinates.SkyCoord(ra=ra * units.degree,
                                      dec=dec * units.degree,
                                      frame=frame,
                                      equinox=equinox,
                                      obstime=ut_datetime)

    if appt_frame:
        # Call ERFA.apci13 to get the Equation of Origin (EO).
        # We just discard the astrom context return
        astrom, eo = _erfa.apci13(coords.obstime.jd1, coords.obstime.jd2)
        astrom = None
        # eo comes back as a single element array in radians
        eo = float(eo)
        eo = eo * units.radian
        # re-create the coords frame object with the corrected ra
        coords = coordinates.SkyCoord(ra=coords.ra + eo,
                                      dec=coords.dec,
                                      frame=coords.frame.name,
                                      equinox=coords.equinox,
                                      obstime=coords.obstime)

    # Now we can just convert to ICRS...
    icrs = coords.icrs

    # And return values in degrees
    return (icrs.ra.degree, icrs.dec.degree)
예제 #2
0
def test_atciqz_aticq(st):
    """Check replacements against erfa versions for consistency."""
    t, pos = st
    jd1, jd2 = get_jd12(t, 'tdb')
    astrom, _ = erfa.apci13(jd1, jd2)

    ra, dec = pos
    ra = ra.value
    dec = dec.value
    assert_allclose(erfa.atciqz(ra, dec, astrom), atciqz(ra, dec, astrom))
    assert_allclose(erfa.aticq(ra, dec, astrom), aticq(ra, dec, astrom))
예제 #3
0
def test_atciqz_aticq(st):
    """Check replacements against erfa versions for consistency."""
    t, pos = st
    jd1, jd2 = get_jd12(t, 'tdb')
    astrom, _ = erfa.apci13(jd1, jd2)

    ra, dec = pos
    ra = ra.value
    dec = dec.value
    assert_allclose(erfa.atciqz(ra, dec, astrom), atciqz(ra, dec, astrom))
    assert_allclose(erfa.aticq(ra, dec, astrom), aticq(ra, dec, astrom))
예제 #4
0
파일: gmu.py 프로젝트: mmorage/DRAGONS
def toicrs(frame, ra, dec, equinox=2000.0, ut_datetime=None):
    # Utility function. Converts and RA and Dec in the specified reference frame
    # and equinox at ut_datetime into ICRS. This is used by the ra and dec descriptors.

    # Assume equinox is julian calendar
    equinox = 'J{}'.format(equinox)

    # astropy doesn't understand APPT coordinates. However, it does understand
    # CIRS coordinates, and we can convert from APPT to CIRS by adding the
    # equation of origins to the RA. We can get that using ERFA.
    # To proceed with this, we first let astopy construct the CIRS frame, so
    # that we can extract the obstime object from that to pass to erfa.
    appt_frame = (frame == 'APPT')
    if frame == 'APPT':
        frame = 'cirs'
    if frame == 'FK5':
        frame = 'fk5'

    # Try this with the passed frame but, if it doesn't work, convert to "cirs"
    # If that doesn't work, then raise an error
    try:
        coords = coordinates.SkyCoord(ra=ra*units.degree, dec=dec*units.degree,
                  frame=frame, equinox=equinox, obstime=ut_datetime)
    except ValueError:
        frame = 'cirs'
        coords = coordinates.SkyCoord(ra=ra*units.degree, dec=dec*units.degree,
                  frame=frame, equinox=equinox, obstime=ut_datetime)

    if appt_frame:
        # Call ERFA.apci13 to get the Equation of Origin (EO).
        # We just discard the astrom context return
        astrom, eo = _erfa.apci13(coords.obstime.jd1, coords.obstime.jd2)
        astrom = None
        # eo comes back as a single element array in radians
        eo = float(eo)
        eo = eo * units.radian
        # re-create the coords frame object with the corrected ra
        coords = coordinates.SkyCoord(ra=coords.ra+eo, dec=coords.dec,
                          frame=coords.frame.name, equinox=coords.equinox,
                          obstime=coords.obstime)

    # Now we can just convert to ICRS...
    icrs = coords.icrs

    # And return values in degrees
    return (icrs.ra.degree, icrs.dec.degree)
예제 #5
0
def test_structs():
    """
    Checks producing and consuming of ERFA c structs
    """

    am, eo = erfa.apci13(2456165.5, [0.401182685, 1])
    assert am.shape == (2, )
    assert am.dtype == erfa.dt_eraASTROM
    assert eo.shape == (2, )

    # a few spotchecks from test_erfa.c
    np.testing.assert_allclose(am[0]['pmt'], 12.65133794027378508)
    np.testing.assert_allclose(am[0]['v'], [0.4289638897157027528e-4,
                                            0.8115034002544663526e-4,
                                            0.3517555122593144633e-4])

    ri, di = erfa.atciqz(2.71, 0.174, am[0])
    np.testing.assert_allclose(ri, 2.709994899247599271)
    np.testing.assert_allclose(di, 0.1728740720983623469)