示例#1
0
def test_coordinates_ecliptical2equatorial():
    """Tests the ecliptical2equatorial() method of Coordinates module"""

    lon = Angle(113.21563)
    lat = Angle(6.68417)
    epsilon = Angle(23.4392911)
    ra, dec = ecliptical2equatorial(lon, lat, epsilon)

    assert ra.ra_str(n_dec=3) == "7h 45' 18.946''", \
        "ERROR: 1st ecliptical2equatorial() test, 'ra' doesn't match"

    assert dec.dms_str(n_dec=2) == "28d 1' 34.26''", \
        "ERROR: 2nd ecliptical2equatorial() test, 'declination' doesn't match"
示例#2
0
    def equation_of_time(epoch):
        """This method computes the equation of time for a given epoch,
        understood as the difference between apparent and mean time, or the
        difference between the hour angle of the true Sun and the mean Sun.

        :param epoch: Epoch to compute the equation of time, as an Epoch object
        :type epoch: :py:class:`Epoch`

        :returns: Difference between apparent and mean time, as a tuple, in
            minutes (int) and seconds (float) of time
        :rtype: tuple
        :raises: TypeError if input values are of wrong type.

        >>> epoch = Epoch(1992, 10, 13.0)
        >>> m, s = Sun.equation_of_time(epoch)
        >>> print(m)
        13
        >>> print(round(s, 1))
        42.6
        """

        # First check that input values are of correct types
        if not isinstance(epoch, Epoch):
            raise TypeError("Invalid input type")
        # Compute time in Julian millenia from J2000.0
        t = (epoch - JDE2000) / 365250
        l0 = (280.4664567 + t * (360007.6982779 + t *
                                 (0.03032028 + t *
                                  (1.0 / 49931.0 + t *
                                   (-1.0 / 15300.0 - t * 1.0 / 2000000.0)))))
        l0 = Angle(l0)
        l0 = l0.to_positive()
        # Compute the apparent position of the Sun
        lon, lat, r = Sun.apparent_geocentric_position(epoch)
        # Now, get the true obliquity
        epsilon = true_obliquity(epoch)
        # Transform from eclliptical to equatorial coordinates
        alpha, dec = ecliptical2equatorial(lon, lat, epsilon)
        alpha = alpha.to_positive()
        # Now we need the nutation in longitude
        deltapsi = nutation_longitude(epoch)
        e = l0() - 0.0057183 - alpha + deltapsi * cos(epsilon.rad())
        e *= 4.0
        # Extract seconds
        s = (abs(e()) % 1) * 60.0
        m = int(e())
        return m, s
示例#3
0
    def apparent_equatorial_pos(epoch):
        """This method computes the apparent equatorial position (right
        ascension, declination) of the Moon for a given instant, referred to
        the mean equinox of the date, as well as the Moon-Earth distance in
        kilometers and the equatorial horizontal parallax.

        :param epoch: Instant to compute the Moon's position, as an
            py:class:`Epoch` object
        :type epoch: :py:class:`Epoch`

        :returns: Tuple containing:

            * Apparent right ascension of the center of the Moon, as an
              py:class:`Epoch` object.
            * Apparent declination of the center of the Moon, as an
              py:class:`Epoch` object.
            * Distance in kilometers between the centers of Earth and Moon, in
              kilometers (float)
            * Equatorial horizontal parallax of the Moon, as an
              py:class:`Epoch` object.
        :rtype: tuple
        :raises: TypeError if input value is of wrong type.

        >>> epoch = Epoch(1992, 4, 12.0)
        >>> ra, dec, Delta, ppi = Moon.apparent_equatorial_pos(epoch)
        >>> print(round(ra, 6))
        134.688469
        >>> print(round(dec, 6))
        13.768367
        >>> print(round(Delta, 1))
        368409.7
        >>> print(round(ppi, 5))
        0.99199
        """

        # First check that input values are of correct types
        if not (isinstance(epoch, Epoch)):
            raise TypeError("Invalid input type")
        # Let's start calling the method 'apparent_ecliptical_pos()'
        Lambda, Beta, Delta, ppi = Moon.apparent_ecliptical_pos(epoch)
        # Now we need the obliquity of the ecliptic
        epsilon = true_obliquity(epoch)
        # And now let's carry out the transformation ecliptical->equatorial
        ra, dec = ecliptical2equatorial(Lambda, Beta, epsilon)
        return ra, dec, Delta, ppi