Exemple #1
0
def test_against_hor2eq():
    """Check that Astropy gives consistent results with an IDL hor2eq example.

    See EXAMPLE input and output here:
    http://idlastro.gsfc.nasa.gov/ftp/pro/astro/hor2eq.pro
    """
    print('IDL hor2eq')
    # Observatory position for `kpno` from here:
    # http://idlastro.gsfc.nasa.gov/ftp/pro/astro/observatory.pro
    location = EarthLocation(lon=Angle('-111d36.0m'),
                             lat=Angle('31d57.8m'),
                             height=2120. * u.m)

    # obstime = Time('2041-12-26 05:00:00')
    obstime = Time(2466879.7083333, format='jd')
    # obstime += TimeDelta(-2, format='sec')

    altaz_frame = AltAz(obstime=obstime, location=location)
    altaz = SkyCoord('264d55m06s 37d54m41s', frame=altaz_frame)

    radec_frame = 'icrs'

    # The following transformation throws a warning about precision problems
    # because the observation date is in the future
    with catch_warnings() as _:
        radec_actual = altaz.transform_to(radec_frame)
    print('Astropy: ', radec_actual)

    radec_expected = SkyCoord('00h13m14.1s  +15d11m0.3s', frame=radec_frame)
    print('Source:  ', radec_expected)
    distance = radec_actual.separation(radec_expected).to('arcsec')
    # print(distance)

    # TODO: why is there a difference of 2.6 arcsec currently?
    # radec_expected = ra=3.30875 deg, dec=15.183416666666666 deg
    # radec_actual = ra=3.3094193224314625 deg, dec=15.183757021354532 deg
    # distance = 2.6285 arcsec
    #     assert distance < 5 * u.arcsec

    # SAPPHiRE
    longitude = -111.6
    latitude = 31.9633
    jd = 2466879.7083333
    elevation = (37, 54, 41)
    azi = (264, 55, 6)
    # lst = clock.gmst_to_lst(clock.juliandate_to_gmst(jd), longitude)
    # Matches  LAST = +03 53 53.6  in the hor2eq.pro
    gps = clock.utc_to_gps(
        calendar.timegm(clock.juliandate_to_utc(jd).utctimetuple()))
    zenith, azimuth = celestial.horizontal_to_zenithazimuth(
        np.radians(base.sexagesimal_to_decimal(*elevation)),
        np.radians(base.sexagesimal_to_decimal(*azi)))
    ra, dec = celestial.zenithazimuth_to_equatorial(longitude, latitude, gps,
                                                    zenith, azimuth)

    print('SAPPHiRE: ra=%f, dec=%f' % (np.degrees(ra), np.degrees(dec)))
Exemple #2
0
    def test_against_hor2eq(self):
        """Check for consistent results with an IDL hor2eq example.

        See EXAMPLE input and output here:
        http://idlastro.gsfc.nasa.gov/ftp/pro/astro/hor2eq.pro

        Observatory position for ``kpno`` from here:
        http://idlastro.gsfc.nasa.gov/ftp/pro/astro/observatory.pro

        """
        # IDL hor2eq
        ra_expected = np.radians(3.30875)
        dec_expected = np.radians(15.183416666666666)

        # Astropy 1.0rc1
        ra_astropy = np.radians(3.3094193224314625)
        dec_astropy = np.radians(15.183757021354532)

        # KPNO observatory
        longitude = -111.6
        latitude = 31.9633

        # Observation time
        jd = 2466879.7083333

        # Altitude Azimuth
        altitude = (37, 54, 41)
        azi = (264, 55, 6)

        # lst = clock.gmst_to_lst(clock.juliandate_to_gmst(jd), longitude)
        # Matches  LAST = +03 53 53.6  in the hor2eq.pro

        # SAPPHiRE
        utc = calendar.timegm(clock.juliandate_to_utc(jd).utctimetuple())
        gps = clock.utc_to_gps(utc)
        zenith, azimuth = celestial.horizontal_to_zenithazimuth(
            np.radians(base.sexagesimal_to_decimal(*altitude)),
            np.radians(base.sexagesimal_to_decimal(*azi)))
        ra, dec = celestial.zenithazimuth_to_equatorial(latitude, longitude,
                                                        gps, zenith, azimuth)

        # Test eq_to_zenaz merely against IDL
        zencalc, azcalc = celestial.equatorial_to_zenithazimuth(
            latitude, longitude, gps, ra_expected, dec_expected)

        self.assertAlmostEqual(ra, ra_expected, 1)
        self.assertAlmostEqual(ra, ra_astropy, 1)
        self.assertAlmostEqual(dec, dec_expected, 2)
        self.assertAlmostEqual(dec, dec_astropy, 2)

        self.assertAlmostEqual(zencalc, zenith, 1)
        self.assertAlmostEqual(azcalc, azimuth, 2)
    def test_against_hor2eq(self):
        """Check for consistent results with an IDL hor2eq example.

        See EXAMPLE input and output here:
        http://idlastro.gsfc.nasa.gov/ftp/pro/astro/hor2eq.pro

        Observatory position for ``kpno`` from here:
        http://idlastro.gsfc.nasa.gov/ftp/pro/astro/observatory.pro

        """
        # IDL hor2eq
        ra_expected = np.radians(3.30875)
        dec_expected = np.radians(15.183416666666666)

        # Astropy 1.0rc1
        ra_astropy = np.radians(3.3094193224314625)
        dec_astropy = np.radians(15.183757021354532)

        # KPNO observatory
        longitude = -111.6
        latitude = 31.9633

        # Observation time
        jd = 2466879.7083333

        # Altitude Azimuth
        altitude = (37, 54, 41)
        azi = (264, 55, 6)

        # lst = clock.gmst_to_lst(clock.juliandate_to_gmst(jd), longitude)
        # Matches  LAST = +03 53 53.6  in the hor2eq.pro

        # SAPPHiRE
        utc = calendar.timegm(clock.juliandate_to_utc(jd).utctimetuple())
        gps = clock.utc_to_gps(utc)
        zenith, azimuth = celestial.horizontal_to_zenithazimuth(
            np.radians(base.sexagesimal_to_decimal(*altitude)),
            np.radians(base.sexagesimal_to_decimal(*azi)))
        ra, dec = celestial.zenithazimuth_to_equatorial(
            latitude, longitude, gps, zenith, azimuth)

        # Test eq_to_zenaz merely against IDL
        zencalc, azcalc = celestial.equatorial_to_zenithazimuth(
            latitude, longitude, gps, ra_expected, dec_expected)

        self.assertAlmostEqual(ra, ra_expected, 1)
        self.assertAlmostEqual(ra, ra_astropy, 1)
        self.assertAlmostEqual(dec, dec_expected, 2)
        self.assertAlmostEqual(dec, dec_astropy, 2)

        self.assertAlmostEqual(zencalc, zenith, 1)
        self.assertAlmostEqual(azcalc, azimuth, 2)
Exemple #4
0
 def test_juliandate_to_utc_gap(self):
     self.assertEqual(clock.juliandate_to_utc(2299159.5),
                      datetime.datetime(1582, 10, 4))
     self.assertEqual(clock.juliandate_to_utc(2299160.5),
                      datetime.datetime(1582, 10, 15))
Exemple #5
0
 def test_juliandate_to_utc(self):
     self.assertEqual(clock.juliandate_to_utc(2400000.5),
                      datetime.datetime(1858, 11, 17))
     self.assertEqual(clock.juliandate_to_utc(2455581.40429),
                      datetime.datetime(2011, 1, 19, 21, 42, 10, 655997))
Exemple #6
0
 def test_juliandate_to_utc_gap(self):
     self.assertEqual(clock.juliandate_to_utc(2299159.5),
                      datetime.datetime(1582, 10, 4))
     self.assertEqual(clock.juliandate_to_utc(2299160.5),
                      datetime.datetime(1582, 10, 15))
Exemple #7
0
 def test_juliandate_to_utc(self):
     self.assertEqual(clock.juliandate_to_utc(2400000.5),
                      datetime.datetime(1858, 11, 17))
     self.assertEqual(clock.juliandate_to_utc(2455581.40429),
                      datetime.datetime(2011, 1, 19, 21, 42, 10, 655997))