Esempio n. 1
0
 def setup(self):
     self.mjd_array = np.array([
         58827.15925499, 58827.15925499, 58827.15925499, 58827.15925499,
         58827.15925499
     ])
     self.mjd_scalar = self.mjd_array[0].item()
     self.utc2mjd = 2400000.5
     paranal_long = -1.228798
     paranal_lat = -0.42982
     paranal_height = 2669.
     self.astrom_scalar, _ = erfa.apco13(self.utc2mjd, self.mjd_scalar, 0.0,
                                         paranal_long, paranal_lat,
                                         paranal_height, 0.0, 0.0, 0.0, 0.0,
                                         0.0, 2.5)
     self.astrom_array, _ = erfa.apco13(self.utc2mjd, self.mjd_array, 0.0,
                                        paranal_long, paranal_lat,
                                        paranal_height, 0.0, 0.0, 0.0, 0.0,
                                        0.0, 2.5)
Esempio n. 2
0
def test_iau_fullstack(fullstack_icrs, fullstack_fiducial_altaz,
                       fullstack_times, fullstack_locations,
                       fullstack_obsconditions):
    """
    Test the full transform from ICRS <-> AltAz
    """

    # create the altaz frame
    altazframe = AltAz(obstime=fullstack_times,
                       location=fullstack_locations,
                       pressure=fullstack_obsconditions[0],
                       temperature=fullstack_obsconditions[1],
                       relative_humidity=fullstack_obsconditions[2],
                       obswl=fullstack_obsconditions[3])

    aacoo = fullstack_icrs.transform_to(altazframe)

    # compare aacoo to the fiducial AltAz - should always be different
    assert np.all(
        np.abs(aacoo.alt - fullstack_fiducial_altaz.alt) > 50 *
        u.milliarcsecond)
    assert np.all(
        np.abs(aacoo.az - fullstack_fiducial_altaz.az) > 50 * u.milliarcsecond)

    # if the refraction correction is included, we *only* do the comparisons
    # where altitude >5 degrees.  The SOFA guides imply that below 5 is where
    # where accuracy gets more problematic, and testing reveals that alt<~0
    # gives garbage round-tripping, and <10 can give ~1 arcsec uncertainty
    if fullstack_obsconditions[0].value == 0:
        # but if there is no refraction correction, check everything
        msk = slice(None)
        tol = 5 * u.microarcsecond
    else:
        msk = aacoo.alt > 5 * u.deg
        # most of them aren't this bad, but some of those at low alt are offset
        # this much.  For alt > 10, this is always better than 100 masec
        tol = 750 * u.milliarcsecond

    # now make sure the full stack round-tripping works
    icrs2 = aacoo.transform_to(ICRS)

    adras = np.abs(fullstack_icrs.ra - icrs2.ra)[msk]
    addecs = np.abs(fullstack_icrs.dec - icrs2.dec)[msk]
    assert np.all(adras < tol), 'largest RA change is {0} mas, > {1}'.format(
        np.max(adras.arcsec * 1000), tol)
    assert np.all(addecs < tol), 'largest Dec change is {0} mas, > {1}'.format(
        np.max(addecs.arcsec * 1000), tol)

    # check that we're consistent with the ERFA alt/az result
    xp, yp = u.Quantity(iers.IERS_Auto.open().pm_xy(fullstack_times)).to_value(
        u.radian)
    lon = fullstack_locations.geodetic[0].to_value(u.radian)
    lat = fullstack_locations.geodetic[1].to_value(u.radian)
    height = fullstack_locations.geodetic[2].to_value(u.m)
    jd1, jd2 = get_jd12(fullstack_times, 'utc')
    pressure = fullstack_obsconditions[0].to_value(u.hPa)
    temperature = fullstack_obsconditions[1].to_value(u.deg_C)
    # Relative humidity can be a quantity or a number.
    relative_humidity = u.Quantity(fullstack_obsconditions[2], u.one).value
    obswl = fullstack_obsconditions[3].to_value(u.micron)
    astrom, eo = erfa.apco13(jd1, jd2, fullstack_times.delta_ut1_utc, lon, lat,
                             height, xp, yp, pressure, temperature,
                             relative_humidity, obswl)
    erfadct = _erfa_check(fullstack_icrs.ra.rad, fullstack_icrs.dec.rad,
                          astrom)
    npt.assert_allclose(erfadct['alt'], aacoo.alt.radian, atol=1e-7)
    npt.assert_allclose(erfadct['az'], aacoo.az.radian, atol=1e-7)
Esempio n. 3
0
def test_iau_fullstack(fullstack_icrs, fullstack_fiducial_altaz,
                       fullstack_times, fullstack_locations,
                       fullstack_obsconditions):
    """
    Test the full transform from ICRS <-> AltAz
    """

    # create the altaz frame
    altazframe = AltAz(obstime=fullstack_times, location=fullstack_locations,
                       pressure=fullstack_obsconditions[0],
                       temperature=fullstack_obsconditions[1],
                       relative_humidity=fullstack_obsconditions[2],
                       obswl=fullstack_obsconditions[3])

    aacoo = fullstack_icrs.transform_to(altazframe)

    # compare aacoo to the fiducial AltAz - should always be different
    assert np.all(np.abs(aacoo.alt - fullstack_fiducial_altaz.alt) > 50*u.milliarcsecond)
    assert np.all(np.abs(aacoo.az - fullstack_fiducial_altaz.az) > 50*u.milliarcsecond)

    # if the refraction correction is included, we *only* do the comparisons
    # where altitude >5 degrees.  The SOFA guides imply that below 5 is where
    # where accuracy gets more problematic, and testing reveals that alt<~0
    # gives garbage round-tripping, and <10 can give ~1 arcsec uncertainty
    if fullstack_obsconditions[0].value == 0:
        # but if there is no refraction correction, check everything
        msk = slice(None)
        tol = 5*u.microarcsecond
    else:
        msk = aacoo.alt > 5*u.deg
        # most of them aren't this bad, but some of those at low alt are offset
        # this much.  For alt > 10, this is always better than 100 masec
        tol = 750*u.milliarcsecond

    # now make sure the full stack round-tripping works
    icrs2 = aacoo.transform_to(ICRS)

    adras = np.abs(fullstack_icrs.ra - icrs2.ra)[msk]
    addecs = np.abs(fullstack_icrs.dec - icrs2.dec)[msk]
    assert np.all(adras < tol), 'largest RA change is {0} mas, > {1}'.format(np.max(adras.arcsec*1000), tol)
    assert np.all(addecs < tol), 'largest Dec change is {0} mas, > {1}'.format(np.max(addecs.arcsec*1000), tol)

    # check that we're consistent with the ERFA alt/az result
    xp, yp = u.Quantity(iers.IERS_Auto.open().pm_xy(fullstack_times)).to_value(u.radian)
    lon = fullstack_locations.geodetic[0].to_value(u.radian)
    lat = fullstack_locations.geodetic[1].to_value(u.radian)
    height = fullstack_locations.geodetic[2].to_value(u.m)
    jd1, jd2 = get_jd12(fullstack_times, 'utc')
    pressure = fullstack_obsconditions[0].to_value(u.hPa)
    temperature = fullstack_obsconditions[1].to_value(u.deg_C)
    # Relative humidity can be a quantity or a number.
    relative_humidity = u.Quantity(fullstack_obsconditions[2], u.one).value
    obswl = fullstack_obsconditions[3].to_value(u.micron)
    astrom, eo = erfa.apco13(jd1, jd2,
                             fullstack_times.delta_ut1_utc,
                             lon, lat, height,
                             xp, yp,
                             pressure, temperature, relative_humidity,
                             obswl)
    erfadct = _erfa_check(fullstack_icrs.ra.rad, fullstack_icrs.dec.rad, astrom)
    npt.assert_allclose(erfadct['alt'], aacoo.alt.radian, atol=1e-7)
    npt.assert_allclose(erfadct['az'], aacoo.az.radian, atol=1e-7)