예제 #1
0
    def ephemeris_physical_observations(epoch):
        """This method uses Carrington's formulas to compute the following
        quantities:

        - P  : position angle of the northern extremity of the axis of rotation
        - B0 : heliographic latitude of the center of the solar disk
        - L0 : heliographic longitude of the center of the solar disk

        :param epoch: Epoch to compute the parameters
        :type epoch: :py:class:`Epoch`

        :returns: Parameters P, B0 and L0, in a tuple
        :rtype: tuple
        :raises: TypeError if input value is of wrong type.

        >>> epoch = Epoch(1992, 10, 13)
        >>> p, b0, l0 = Sun.ephemeris_physical_observations(epoch)
        >>> print(round(p, 2))
        26.27
        >>> print(round(b0, 2))
        5.99
        >>> print(round(l0, 2))
        238.63
        """

        # First check that input values are of correct types
        if not isinstance(epoch, Epoch):
            raise TypeError("Invalid input type")
        # Compute the auxiliary parameters
        epoch += 0.00068
        theta = (epoch() - 2398220.0) * 360.0 / 25.38
        theta = Angle(theta)
        i = Angle(7.25)
        k = 73.6667 + 1.3958333 * (epoch() - 2396758.0) / 36525.0
        k = Angle(k)
        lon, lat, r = Sun.apparent_geocentric_position(epoch, nutation=False)
        eps = true_obliquity(epoch)
        dpsi = nutation_longitude(epoch)
        lonp = lon + dpsi
        x = atan(-cos(lonp.rad()) * tan(eps.rad()))
        x = Angle(x, radians=True)
        delta = lon - k
        y = atan(-cos(delta.rad()) * tan(i.rad()))
        y = Angle(y, radians=True)
        p = x + y
        b0 = asin(sin(delta.rad()) * sin(i.rad()))
        b0 = Angle(b0, radians=True)
        eta = atan(tan(delta.rad()) * cos(i.rad()))
        eta = Angle(eta, radians=True)
        l0 = eta - theta
        return p, b0, l0.to_positive()
예제 #2
0
def test_coordinates_nutation_longitude():
    """Tests the nutation_longitude() method of Coordinates module"""

    dpsi = nutation_longitude(1987, 4, 10)
    a = dpsi.dms_tuple()
    assert abs(a[0] - 0.0) < TOL, \
        "ERROR: 1st nutation_longitude() test, 'degrees' value doesn't match"

    assert abs(a[1] - 0.0) < TOL, \
        "ERROR: 2nd nutation_longitude() test, 'minutes' value doesn't match"

    assert abs(round(a[2], 3) - 3.788) < TOL, \
        "ERROR: 3rd nutation_longitude() test, 'seconds value doesn't match"

    assert abs(a[3] - (-1.0)) < TOL, \
        "ERROR: 4th nutation_longitude() test, 'sign' value doesn't match"
예제 #3
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
예제 #4
0
    def apparent_ecliptical_pos(epoch):
        """This method computes the apparent geocentric ecliptical position
        (longitude, latitude) 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 geocentric longitude of the center of the Moon, as an
              py:class:`Epoch` object.
            * Apparent geocentric latitude 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)
        >>> Lambda, Beta, Delta, ppi = Moon.apparent_ecliptical_pos(epoch)
        >>> print(round(Lambda, 5))
        133.16726
        >>> print(round(Beta, 6))
        -3.229126
        >>> 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")
        # Now, let's call the method geocentric_ecliptical_pos()
        Lambda, Beta, Delta, ppi = Moon.geocentric_ecliptical_pos(epoch)
        # Compute the nutation in longitude (deltaPsi)
        deltaPsi = nutation_longitude(epoch)
        # Correct the longitude to obtain the apparent longitude
        aLambda = Lambda + deltaPsi
        return aLambda, Beta, Delta, ppi