Esempio n. 1
0
    def longitude_true_ascending_node(epoch):
        """This method computes the longitude of the true ascending node of the
        Moon in degrees, for a given instant, measured from the mean equinox of
        the date.

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

        :returns: The longitude of the true ascending node.
        :rtype: py:class:`Angle`
        :raises: TypeError if input value is of wrong type.

        >>> epoch = Epoch(1913, 5, 27.0)
        >>> Omega = Moon.longitude_true_ascending_node(epoch)
        >>> print(round(Omega, 4))
        0.8763
        """

        # First check that input values are of correct types
        if not (isinstance(epoch, Epoch)):
            raise TypeError("Invalid input type")
        # Let's start computing the longitude of the MEAN ascending node
        Omega = Moon.longitude_mean_ascending_node(epoch)
        # Get the time from J2000.0 in Julian centuries
        t = (epoch - JDE2000) / 36525.0
        # Mean elongation of the Moon
        D = 297.8501921 + (445267.1114034
                           + (-0.0018819
                              + (1.0/545868.0 - t/113065000.0) * t) * t) * t
        # Sun's mean anomaly
        M = 357.5291092 + (35999.0502909 + (-0.0001536 + t/24490000.0) * t) * t
        # Moon's mean anomaly
        Mprime = 134.9633964 + (477198.8675055
                                + (0.0087414
                                   + (1.0/69699.9
                                      + t/14712000.0) * t) * t) * t
        # Moon's argument of latitude
        F = 93.2720950 + (483202.0175233
                          + (-0.0036539
                             + (-1.0/3526000.0 + t/863310000.0) * t) * t) * t
        # Reduce the angles to a [0 360] range
        D = Angle(Angle.reduce_deg(D)).to_positive()
        Dr = D.rad()
        M = Angle(Angle.reduce_deg(M)).to_positive()
        Mr = M.rad()
        Mprime = Angle(Angle.reduce_deg(Mprime)).to_positive()
        Mprimer = Mprime.rad()
        F = Angle(Angle.reduce_deg(F)).to_positive()
        Fr = F.rad()
        # Compute the periodic terms
        corr = (-1.4979 * sin(2.0 * (Dr - Fr)) - 0.15 * sin(Mr)
                - 0.1226 * sin(2.0 * Dr) + 0.1176 * sin(2.0 * Fr)
                - 0.0801 * sin(2.0 * (Mprimer - Fr)))
        Omega += Angle(corr)
        return Omega
Esempio n. 2
0
def test_angle_reduce_deg():
    """Tests reduce_deg() static method of Angle class"""

    d = Angle.reduce_deg(745.67)
    assert abs(d - 25.67) < TOL, \
        "ERROR: In 1st reduce_deg() test, degrees value doesn't match"

    d = Angle.reduce_deg(-360.86)
    assert abs(d - (-0.86)) < TOL, \
        "ERROR: In 2nd reduce_deg() test, degrees value doesn't match"
Esempio n. 3
0
    def geocentric_ecliptical_pos(epoch):
        """This method computes the 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:

            * Geocentric longitude of the center of the Moon, as an
              py:class:`Epoch` object.
            * 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.geocentric_ecliptical_pos(epoch)
        >>> print(round(Lambda, 6))
        133.162655
        >>> 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")
        # Get the time from J2000.0 in Julian centuries
        t = (epoch - JDE2000) / 36525.0
        # Compute Moon's mean longitude, referred to mean equinox of date
        Lprime = 218.3164477 + (481267.88123421
                                + (-0.0015786
                                   + (1.0/538841.0
                                       - t/65194000.0) * t) * t) * t
        # Mean elongation of the Moon
        D = 297.8501921 + (445267.1114034
                           + (-0.0018819
                              + (1.0/545868.0 - t/113065000.0) * t) * t) * t
        # Sun's mean anomaly
        M = 357.5291092 + (35999.0502909 + (-0.0001536 + t/24490000.0) * t) * t
        # Moon's mean anomaly
        Mprime = 134.9633964 + (477198.8675055
                                + (0.0087414
                                   + (1.0/69699.9
                                      + t/14712000.0) * t) * t) * t
        # Moon's argument of latitude
        F = 93.2720950 + (483202.0175233
                          + (-0.0036539
                             + (-1.0/3526000.0 + t/863310000.0) * t) * t) * t
        # Let's compute some additional arguments
        A1 = 119.75 + 131.849 * t
        A2 = 53.09 + 479264.290 * t
        A3 = 313.45 + 481266.484 * t
        # Eccentricity of Earth's orbit around the Sun
        E = 1.0 + (-0.002516 - 0.0000074 * t) * t
        E2 = E * E
        # Reduce the angles to a [0 360] range
        Lprime = Angle(Angle.reduce_deg(Lprime)).to_positive()
        Lprimer = Lprime.rad()
        D = Angle(Angle.reduce_deg(D)).to_positive()
        Dr = D.rad()
        M = Angle(Angle.reduce_deg(M)).to_positive()
        Mr = M.rad()
        Mprime = Angle(Angle.reduce_deg(Mprime)).to_positive()
        Mprimer = Mprime.rad()
        F = Angle(Angle.reduce_deg(F)).to_positive()
        Fr = F.rad()
        A1 = Angle(Angle.reduce_deg(A1)).to_positive()
        A1r = A1.rad()
        A2 = Angle(Angle.reduce_deg(A2)).to_positive()
        A2r = A2.rad()
        A3 = Angle(Angle.reduce_deg(A3)).to_positive()
        A3r = A3.rad()
        # Let's store this results in a list, in preparation for using tables
        arguments = [Dr, Mr, Mprimer, Fr]
        # Now we use the tables of periodic terms. First for sigmal and sigmar
        sigmal = 0.0
        sigmar = 0.0
        for i, value in enumerate(PERIODIC_TERMS_LR_TABLE):
            argument = 0.0
            for j in range(4):
                if PERIODIC_TERMS_LR_TABLE[i][j]:  # Avoid multiply by zero
                    argument += PERIODIC_TERMS_LR_TABLE[i][j] * arguments[j]
            coeffl = value[4]
            coeffr = value[5]
            if abs(value[1]) == 1:
                coeffl = coeffl * E
                coeffr = coeffr * E
            elif abs(value[1]) == 2:
                coeffl = coeffl * E2
                coeffr = coeffr * E2
            sigmal += coeffl * sin(argument)
            sigmar += coeffr * cos(argument)
        # Add the additive terms to sigmal
        sigmal += (3958.0 * sin(A1r) + 1962.0 * sin(Lprimer - Fr)
                   + 318.0 * sin(A2r))
        # Now use the tabla for sigmab
        sigmab = 0.0
        for i, value in enumerate(PERIODIC_TERMS_B_TABLE):
            argument = 0.0
            for j in range(4):
                if PERIODIC_TERMS_B_TABLE[i][j]:  # Avoid multiply by zero
                    argument += PERIODIC_TERMS_B_TABLE[i][j] * arguments[j]
            coeffb = value[4]
            if abs(value[1]) == 1:
                coeffb = coeffb * E
            elif abs(value[1]) == 2:
                coeffb = coeffb * E2
            sigmab += coeffb * sin(argument)
        # Add the additive terms to sigmab
        sigmab += (-2235.0 * sin(Lprimer) + 382.0 * sin(A3r)
                   + 175.0 * sin(A1r - Fr) + 175.0 * sin(A1r + Fr)
                   + 127.0 * sin(Lprimer - Mprimer)
                   - 115.0 * sin(Lprimer + Mprimer))
        Lambda = Lprime + (sigmal / 1000000.0)
        Beta = Angle(sigmab / 1000000.0)
        Delta = 385000.56 + (sigmar / 1000.0)
        ppii = asin(6378.14 / Delta)
        ppi = Angle(ppii, radians=True)
        return Lambda, Beta, Delta, ppi