Esempio n. 1
0
    def dimension(self, jd, planet, dim):
        """Return one of heliocentric ecliptic longitude, latitude and radius.
        
        [Meeus-1998: pg 218]
        
        Parameters:
            jd : Julian Day in dynamical time
            planet : must be one of ("Mercury", "Venus", "Earth", "Mars", 
                "Jupiter", "Saturn", "Uranus", "Neptune")
            dim : must be one of "L" (longitude) or "B" (latitude) or "R" (radius)
            
        Returns:
            longitude in radians, or
            latitude in radians, or
            radius in au
        
        """
        X = 0.0
        tauN = 1.0
        tau = jd_to_jcent(jd) / 10.0
        c = _planets[(planet, dim)]

        for s in c:
            X += sum([A * cos(B + C * tau) for A, B, C in s]) * tauN
            tauN = tauN * tau  # last calculation is wasted

        if dim == "L":
            X = modpi2(X)

        return X
Esempio n. 2
0
def nut_in_lon(jd):
    """Return the nutation in longitude. 
    
    High precision. [Meeus-1998: pg 144]
    
    Parameters:
        jd : Julian Day in dynamical time
        
    Returns:
        nutation in longitude, in radians
    
    """
    # 
    # Future optimization: factor the /1e5 and /1e6 adjustments into the table.
    #
    # Could turn the loop into a generator expression. Too messy?
    #
    T = jd_to_jcent(jd)
    D, M, M1, F, omega = _constants(T)
    deltaPsi = 0.0
    for tD, tM, tM1, tF, tomega, tpsiK, tpsiT, tepsK, tepsT in _tbl:
        arg = D*tD + M*tM + M1*tM1 + F*tF + omega*tomega
        deltaPsi += (tpsiK/10000.0 + tpsiT/100000.0 * T) * sin(arg)

    deltaPsi /= 3600
    deltaPsi = d_to_r(deltaPsi)
    return deltaPsi
Esempio n. 3
0
def equinox_approx(yr, season):
    """Returns the approximate time of a solstice or equinox event.
    
    The year must be in the range -1000...3000. Within that range the
    the error from the precise instant is at most 2.16 minutes.
    
    Parameters:
        yr     : year
        season : one of ("spring", "summer", "autumn", "winter")
    
    Returns:
        Julian Day of the event in dynamical time
    
    """
    if not (-1000 <= yr <= 3000):
        raise Error, "year is out of range"
    if season not in astronomia.globals.season_names:
        raise Error, "unknown season =" + season
        
    yr = int(yr)
    if -1000 <= yr <= 1000:
        Y = yr / 1000.0
        tbl = _approx_1000
    else:
        Y = (yr - 2000) / 1000.0
        tbl = _approx_3000

    jd = polynomial(tbl[season], Y)
    T = jd_to_jcent(jd)
    W = d_to_r(35999.373 * T - 2.47)
    delta_lambda = 1 + 0.0334 * cos(W) + 0.0007 * cos(2 * W)

    jd += 0.00001 * sum([A * cos(B + C * T) for A, B, C in _terms]) / delta_lambda

    return jd
Esempio n. 4
0
def longitude_radius_low(jd):
    """Return geometric longitude and radius vector. 
    
    Low precision. The longitude is accurate to 0.01 degree.  The latitude
    should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5
    
    Parameters:
        jd : Julian Day in dynamical time

    Returns:
        longitude in radians
        radius in au

    """
    T = jd_to_jcent(jd)
    L0 = polynomial(_kL0, T)
    M = polynomial(_kM, T)
    e = polynomial((0.016708634, -0.000042037, -0.0000001267), T)
    C = polynomial(_kC, T) * sin(M) \
        + (_ck3 - _ck4 * T) * sin(2 * M) \
        + _ck5 * sin(3 * M)
    L = modpi2(L0 + C)
    v = M + C
    R = 1.000001018 * (1 - e * e) / (1 + e * cos(v))
    return L, R
Esempio n. 5
0
    def _latitude(self, jd):
        """Return the geocentric ecliptic latitude in radians.

        A subset of the logic in dimension3()

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        bsum = 0.0
        for tD, tM, tM1, tF, tb in _tblB:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tb *= E
            elif abs(tM) == 2:
                tb *= E2
            bsum += tb * sin(arg)

        bsum += -2235 * sin(L1) +      \
                  382 * sin(A3) +      \
                  175 * sin(A1 - F) +  \
                  175 * sin(A1 + F) +  \
                  127 * sin(L1 - M1) - \
                  115 * sin(L1 + M1)

        latitude = d_to_r(bsum / 1000000)
        return latitude
Esempio n. 6
0
def nut_in_obl(jd):
    """Return the nutation in obliquity. 
    
    High precision. [Meeus-1998: pg 144]
    
    Parameters:
        jd : Julian Day in dynamical time
        
    Returns:
        nutation in obliquity, in radians

    """
    # 
    # Future optimization: factor the /1e5 and /1e6 adjustments into the table.
    #
    # Could turn the loop into a generator expression. Too messy?
    #
    T = jd_to_jcent(jd)
    D, M, M1, F, omega = _constants(T)
    deltaEps = 0.0;
    for tD, tM, tM1, tF, tomega, tpsiK, tpsiT, tepsK, tepsT in _tbl:
        arg = D*tD + M*tM + M1*tM1 + F*tF + omega*tomega
        deltaEps = deltaEps + (tepsK/10000.0 + tepsT/100000.0 * T) * cos(arg)
    deltaEps = deltaEps / 3600
    deltaEps = d_to_r(deltaEps)
    return deltaEps
Esempio n. 7
0
def longitude_radius_low(jd):
    """Return geometric longitude and radius vector. 
    
    Low precision. The longitude is accurate to 0.01 degree.  The latitude
    should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5
    
    Parameters:
        jd : Julian Day in dynamical time

    Returns:
        longitude in radians
        radius in au

    """
    T = jd_to_jcent(jd)
    L0 = polynomial(_kL0, T)
    M = polynomial(_kM, T)
    e = polynomial((0.016708634, -0.000042037, -0.0000001267), T)
    C = polynomial(_kC, T) * sin(M) \
        + (_ck3 - _ck4 * T) * sin(2 * M) \
        + _ck5 * sin(3 * M)
    L = modpi2(L0 + C)
    v = M + C
    R = 1.000001018 * (1 - e * e) / (1 + e * cos(v))
    return L, R
Esempio n. 8
0
    def dimension(self, jd, planet, dim):
        """Return one of heliocentric ecliptic longitude, latitude and radius.
        
        [Meeus-1998: pg 218]
        
        Parameters:
            jd : Julian Day in dynamical time
            planet : must be one of ("Mercury", "Venus", "Earth", "Mars", 
                "Jupiter", "Saturn", "Uranus", "Neptune")
            dim : must be one of "L" (longitude) or "B" (latitude) or "R" (radius)
            
        Returns:
            longitude in radians, or
            latitude in radians, or
            radius in au
        
        """
        X = 0.0
        tauN = 1.0
        tau = jd_to_jcent(jd)/10.0
        c = _planets[(planet, dim)]

        for s in c:
            X += sum([A*cos(B + C*tau) for A, B, C in s])*tauN
            tauN = tauN*tau  # last calculation is wasted
        
        if dim == "L": 
            X = modpi2(X)

        return X
Esempio n. 9
0
    def mean_longitude(self, jd):
        """Return mean longitude.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - Longitude in radians

        """
        jd = np.atleast_1d(jd)
        T = jd_to_jcent(jd)

        # From astrolabe
        #X = polynomial((d_to_r(100.466457),
        #                d_to_r(36000.7698278),
        #                d_to_r(0.00030322),
        #                d_to_r(0.000000020)), T)

        # From AA, Naughter
        # Takes T/10.0
        X = polynomial(
            (d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028),
             d_to_r(1.0 / 49931), d_to_r(-1.0 / 15300), d_to_r(
                 -1.0 / 2000000)), T / 10.0)

        X = modpi2(X + np.pi)
        return _scalar_if_one(X)
Esempio n. 10
0
    def mean_longitude(self, jd):
        """Return mean longitude.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - Longitude in radians

        """
        jd = np.atleast_1d(jd)
        T = jd_to_jcent(jd)

        # From astrolabe
        #X = polynomial((d_to_r(100.466457),
        #                d_to_r(36000.7698278),
        #                d_to_r(0.00030322),
        #                d_to_r(0.000000020)), T)

        # From AA, Naughter
        # Takes T/10.0
        X = polynomial((d_to_r(100.4664567),
                        d_to_r(360007.6982779),
                        d_to_r(0.03032028),
                        d_to_r(1.0/49931),
                        d_to_r(-1.0/15300),
                        d_to_r(-1.0/2000000)), T/10.0)

        X = modpi2(X + np.pi)
        return _scalar_if_one(X)
Esempio n. 11
0
def nutation_in_obliquity(jd):
    """Return the nutation in obliquity.

    High precision. [Meeus-1998: pg 144]

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - nutation in obliquity, in radians

    """
    #
    # Future optimization: factor the /1e5 and /1e6 adjustments into the table.
    #
    # Could turn the loop into a generator expression. Too messy?
    #
    T = jd_to_jcent(jd)
    D, M, M1, F, omega = _constants(T)
    deltaEps = 0.0
    for tD, tM, tM1, tF, tomega, tpsiK, tpsiT, tepsK, tepsT in _tbl:
        arg = D*tD + M*tM + M1*tM1 + F*tF + omega*tomega
        deltaEps = deltaEps + (tepsK/10000.0 +
                               tepsT/100000.0 * T) * np.cos(arg)
    deltaEps = deltaEps / 3600
    deltaEps = d_to_r(deltaEps)
    return deltaEps
Esempio n. 12
0
    def _latitude(self, jd):
        """Return the geocentric ecliptic latitude in radians.

        A subset of the logic in dimension3()

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        bsum = 0.0
        for tD, tM, tM1, tF, tb in _tblB:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tb *= E
            elif abs(tM) == 2:
                tb *= E2
            bsum += tb * sin(arg)

        bsum += -2235 * sin(L1) +      \
                  382 * sin(A3) +      \
                  175 * sin(A1 - F) +  \
                  175 * sin(A1 + F) +  \
                  127 * sin(L1 - M1) - \
                  115 * sin(L1 + M1)

        latitude = d_to_r(bsum / 1000000)
        return latitude
Esempio n. 13
0
def vsop_to_fk5(jd, L, B):
    """Convert VSOP to FK5 coordinates. 
    
    This is required only when using the full precision of the 
    VSOP model.
    
    [Meeus-1998: pg 219]
    
    Parameters:
        jd : Julian Day in dynamical time
        L : longitude in radians
        B : latitude in radians
        
    Returns:
        corrected longitude in radians
        corrected latitude in radians
    
    """
    T = jd_to_jcent(jd)
    L1 = polynomial([L, _k0, _k1], T)
    cosL1 = cos(L1)
    sinL1 = sin(L1)
    deltaL = _k2 + _k3*(cosL1 + sinL1)*tan(B)
    deltaB = _k3*(cosL1 - sinL1)
    return modpi2(L + deltaL), B + deltaB
Esempio n. 14
0
def nutation_in_longitude(jd):
    """Return the nutation in longitude.

    High precision. [Meeus-1998: pg 144]

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - nutation in longitude, in radians

    """
    #
    # Future optimization: factor the /1e5 and /1e6 adjustments into the table.
    #
    # Could turn the loop into a generator expression. Too messy?
    #
    T = jd_to_jcent(jd)
    D, M, M1, F, omega = _constants(T)
    deltaPsi = 0.0
    for tD, tM, tM1, tF, tomega, tpsiK, tpsiT, tepsK, tepsT in _tbl:
        arg = D * tD + M * tM + M1 * tM1 + F * tF + omega * tomega
        deltaPsi += (tpsiK / 10000.0 + tpsiT / 100000.0 * T) * np.sin(arg)

    deltaPsi /= 3600
    deltaPsi = d_to_r(deltaPsi)
    return deltaPsi
Esempio n. 15
0
def vsop_to_fk5(jd, L, B):
    """Convert VSOP to FK5 coordinates. 
    
    This is required only when using the full precision of the 
    VSOP model.
    
    [Meeus-1998: pg 219]
    
    Parameters:
        jd : Julian Day in dynamical time
        L : longitude in radians
        B : latitude in radians
        
    Returns:
        corrected longitude in radians
        corrected latitude in radians
    
    """
    T = jd_to_jcent(jd)
    L1 = polynomial([L, _k0, _k1], T)
    cosL1 = cos(L1)
    sinL1 = sin(L1)
    deltaL = _k2 + _k3 * (cosL1 + sinL1) * tan(B)
    deltaB = _k3 * (cosL1 - sinL1)
    return modpi2(L + deltaL), B + deltaB
Esempio n. 16
0
def longitude_radius_low(jd):
    """Return geometric longitude and radius vector.

    Low precision. The longitude is accurate to 0.01 degree.  The latitude
    should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - longitude in radians
      - radius in au

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    L0 = polynomial(_kL0, T)
    M = polynomial(_kM, T)
    er = polynomial((0.016708634, -0.000042037, -0.0000001267), T)
    C = polynomial(_kC, T) * np.sin(M) \
        + (_ck3 - _ck4 * T) * np.sin(2 * M) \
        + _ck5 * np.sin(3 * M)
    L = modpi2(L0 + C)
    v = M + C
    R = 1.000001018 * (1 - er * er) / (1 + er * np.cos(v))
    return L, R
Esempio n. 17
0
    def dimension(self, jd, planet, dim):
        """Return one of heliocentric ecliptic longitude, latitude and radius.
        [Meeus-1998: pg 218]

        Arguments:
          - `jd`     : Julian Day in dynamical time
          - `planet` : must be one of ("Mercury", "Venus", "Earth", "Mars",
            "Jupiter", "Saturn", "Uranus", "Neptune")
          - `dim`    : must be one of "L" (longitude) or "B" (latitude) or "R"
            (radius)

        Returns:
          - longitude in radians, or latitude in radians, or radius in au,
            depending on the value of `dim`.

        """
        jd = np.atleast_1d(jd)
        X = 0.0
        tauN = 1.0
        tau = jd_to_jcent(jd)/10.0
        c = _planets[(planet, dim)]

        for s in c:
            X += np.sum([A*np.cos(B + C*tau) for A, B, C in s])*tauN
            tauN = tauN*tau  # last calculation is wasted

        if dim == "L":
            X = modpi2(X)

        return _scalar_if_one(X)
Esempio n. 18
0
    def dimension(self, jd, planet, dim):
        """Return one of heliocentric ecliptic longitude, latitude and radius.
        [Meeus-1998: pg 218]

        Arguments:
          - `jd`     : Julian Day in dynamical time
          - `planet` : must be one of ("Mercury", "Venus", "Earth", "Mars",
            "Jupiter", "Saturn", "Uranus", "Neptune")
          - `dim`    : must be one of "L" (longitude) or "B" (latitude) or "R"
            (radius)

        Returns:
          - longitude in radians, or latitude in radians, or radius in au,
            depending on the value of `dim`.

        """
        jd = np.atleast_1d(jd)
        X = 0.0
        tauN = 1.0
        tau = jd_to_jcent(jd) / 10.0
        c = _planets[(planet, dim)]

        for s in c:
            X += np.sum([A * np.cos(B + C * tau) for A, B, C in s]) * tauN
            tauN = tauN * tau  # last calculation is wasted

        if dim == "L":
            X = modpi2(X)

        return _scalar_if_one(X)
Esempio n. 19
0
def longitude_radius_low(jd):
    """Return geometric longitude and radius vector.

    Low precision. The longitude is accurate to 0.01 degree.  The latitude
    should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - longitude in radians
      - radius in au

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    L0 = polynomial(_kL0, T)
    M = polynomial(_kM, T)
    er = polynomial((0.016708634, -0.000042037, -0.0000001267), T)
    C = polynomial(_kC, T) * np.sin(M) \
        + (_ck3 - _ck4 * T) * np.sin(2 * M) \
        + _ck5 * np.sin(3 * M)
    L = modpi2(L0 + C)
    v = M + C
    R = 1.000001018 * (1 - er * er) / (1 + er * np.cos(v))
    return L, R
Esempio n. 20
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of lunar perigee

        """
        T = jd_to_jcent(jd)
        X = polynomial(
            (d_to_r(83.3532465), d_to_r(4069.0137287), d_to_r(-0.0103200),
             d_to_r(-1. / 80053), d_to_r(1. / 18999000)), T)
        return modpi2(X)
Esempio n. 21
0
    def argument_of_latitude(self, jd):
        """Return geocentric mean longitude.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - argument of latitude in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kF, T))
Esempio n. 22
0
    def argument_of_latitude(self, jd):
        """Return geocentric mean longitude.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - argument of latitude in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kF, T))
Esempio n. 23
0
    def mean_anomaly(self, jd):
        """Return geocentric mean anomaly.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - mean anomaly in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kM1, T))
Esempio n. 24
0
    def mean_elongation(self, jd):
        """Return geocentric mean elongation.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - mean elongation in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kD, T))
Esempio n. 25
0
    def mean_anomaly(self, jd):
        """Return geocentric mean anomaly.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - mean anomaly in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kM1, T))
Esempio n. 26
0
    def mean_elongation(self, jd):
        """Return geocentric mean elongation.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - mean elongation in radians

        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(kD, T))
Esempio n. 27
0
    def mean_longitude(self, jd):
        """Return geocentric mean longitude.

        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            longitude in radians

        """
        T = jd_to_jcent(jd)
        L1 = modpi2(polynomial(_kL1, T))
        return L1
Esempio n. 28
0
    def mean_longitude(self, jd):
        """Return geocentric mean longitude.

        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            longitude in radians

        """
        T = jd_to_jcent(jd)
        L1 = modpi2(polynomial(_kL1, T))
        return L1
Esempio n. 29
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of lunar perigee

        """
        T = jd_to_jcent(jd)
        X = polynomial(
            (d_to_r(83.3532465), 
             d_to_r(4069.0137287), 
             d_to_r(-0.0103200), 
             d_to_r(-1./80053), 
             d_to_r(1./18999000)
            ), 
            T)
        return modpi2(X)
Esempio n. 30
0
def obliquity(jd):
    """Return the mean obliquity of the ecliptic.

    Low precision, but good enough for most uses. [Meeus-1998: equation 22.2].
    Accuracy is 1" over 2000 years and 10" over 4000 years.

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - obliquity, in radians

    """
    T = jd_to_jcent(jd)
    return polynomial(_el0, T)
Esempio n. 31
0
def obliquity(jd):
    """Return the mean obliquity of the ecliptic.

    Low precision, but good enough for most uses. [Meeus-1998: equation 22.2].
    Accuracy is 1" over 2000 years and 10" over 4000 years.

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - obliquity, in radians

    """
    T = jd_to_jcent(jd)
    return polynomial(_el0, T)
Esempio n. 32
0
def apparent_longitude_low(jd, L):
    """Correct the geometric longitude for nutation and aberration.
    
    Low precision. [Meeus-1998: pg 164]
    
    Parameters:
        jd : Julian Day in dynamical time
        L : longitude in radians

    Returns:
        corrected longitude in radians

    """
    T = jd_to_jcent(jd)
    omega = _lk0 - _lk1 * T
    return modpi2(L - _lk2 - _lk3 * sin(omega))
Esempio n. 33
0
def apparent_longitude_low(jd, L):
    """Correct the geometric longitude for nutation and aberration.
    
    Low precision. [Meeus-1998: pg 164]
    
    Parameters:
        jd : Julian Day in dynamical time
        L : longitude in radians

    Returns:
        corrected longitude in radians

    """    
    T = jd_to_jcent(jd)
    omega = _lk0 - _lk1 * T
    return modpi2(L - _lk2 - _lk3 * sin(omega))
Esempio n. 34
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of solar perigee.
        
        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            Longitude of solar perigee in radians
                
        """
        T = jd_to_jcent(jd)

        X = polynomial((1012395.0, 6189.03, 1.63, 0.012), (T + 1)) / 3600.0
        X = d_to_r(X)

        X = modpi2(X)
        return X
Esempio n. 35
0
def obliquity_hi(jd):
    """Return the mean obliquity of the ecliptic. 
    
    High precision [Meeus-1998: equation 22.3].
    
    Accuracy is 0.01" between 1000 and 3000, and "a few arc-seconds
    after 10,000 years".
    
    Parameters:
        jd : Julian Day in dynamical time
        
    Returns:
        obliquity, in radians

    """
    U = jd_to_jcent(jd) / 100
    return polynomial(_el1, U)
Esempio n. 36
0
def apparent_longitude_low(jd, L):
    """Correct the geometric longitude for nutation and aberration.

    Low precision. [Meeus-1998: pg 164]

    Arguments:
      - `jd` : Julian Day in dynamical time
      - `L` : longitude in radians

    Returns:
      - corrected longitude in radians

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    omega = _lk0 - _lk1 * T
    return _scalar_if_one(modpi2(L - _lk2 - _lk3 * np.sin(omega)))
Esempio n. 37
0
    def _radius(self, jd):
        """Return the geocentric radius in km.
        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        rsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tr *= E
            elif abs(tM) == 2:
                tr *= E2
            rsum += tr * np.cos(arg)

        dist = 385000.56 + rsum / 1000
        return dist
Esempio n. 38
0
def apparent_longitude_low(jd, L):
    """Correct the geometric longitude for nutation and aberration.

    Low precision. [Meeus-1998: pg 164]

    Arguments:
      - `jd` : Julian Day in dynamical time
      - `L` : longitude in radians

    Returns:
      - corrected longitude in radians

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    omega = _lk0 - _lk1 * T
    return _scalar_if_one(modpi2(L - _lk2 - _lk3 * np.sin(omega)))
Esempio n. 39
0
    def _radius(self, jd):
        """Return the geocentric radius in km.
        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        rsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD*D + tM*M + tM1*M1 + tF*F
            if abs(tM) == 1:
                tr *= E
            elif abs(tM) == 2:
                tr *= E2
            rsum += tr * np.cos(arg)

        dist = 385000.56 + rsum / 1000
        return dist
Esempio n. 40
0
def obliquity_hi(jd):
    """Return the mean obliquity of the ecliptic.

    High precision [Meeus-1998: equation 22.3].

    Accuracy is 0.01" between 1000 and 3000, and "a few arc-seconds
    after 10,000 years".

    Arguments:
      - `jd` : Julian Day in dynamical time

    Returns:
      - obliquity, in radians

    """
    U = jd_to_jcent(jd) / 100
    return polynomial(_el1, U)
Esempio n. 41
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of solar perigee.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - Longitude of solar perigee in radians

        """
        jd = np.atleast_1d(jd)
        T = jd_to_jcent(jd)

        X = polynomial((1012395.0, 6189.03, 1.63, 0.012), (T + 1)) / 3600.0
        X = d_to_r(X)

        X = modpi2(X)
        return _scalar_if_one(X)
Esempio n. 42
0
    def mean_longitude_ascending_node(self, jd):
        """Return mean longitude of ascending node

        Another equation from:
            *  This routine is part of the International Astronomical Union's
            *  SOFA (Standards of Fundamental Astronomy) software collection.
            *  Fundamental (Delaunay) arguments from Simon et al. (1994)
        *  Arcseconds to radians
           DOUBLE PRECISION DAS2R
           PARAMETER ( DAS2R = 4.848136811095359935899141D-6 )

        *  Milliarcseconds to radians
           DOUBLE PRECISION DMAS2R
           PARAMETER ( DMAS2R = DAS2R / 1D3 )

        *  Arc seconds in a full circle
           DOUBLE PRECISION TURNAS
           PARAMETER ( TURNAS = 1296000D0 )

        *  Mean longitude of the ascending node of the Moon.
           OM  = MOD ( 450160.398036D0  -6962890.5431D0*T, TURNAS ) * DAS2R

        Current implemention in astronomia is from:
            PJ Naughter (Web: www.naughter.com, Email: [email protected])

            Look in nutation.py for calculation of omega
            _ko  = (d_to_r(125.04452), d_to_r( -1934.136261), d_to_r( 0.0020708), d_to_r( 1.0/450000))
            Though the last term was left off...
            Will have to incorporate better...
        """

        T = jd_to_jcent(jd)
        X = polynomial(
            (d_to_r(125.0445479), 
             d_to_r(-1934.1362891), 
             d_to_r(0.0020754), 
             d_to_r(1.0/467441.0), 
             d_to_r(1.0/60616000.0)
            ), 
            T)
        return modpi2(X)
Esempio n. 43
0
    def _longitude(self, jd):
        """Return the geocentric ecliptic longitude in radians.
        """
        from astronomia.nutation import nutation_in_longitude

        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)
        lsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
            elif abs(tM) == 2:
                tl *= E2
            lsum += tl * np.sin(arg)

        lsum += 3958 * np.sin(A1) + 1962 * np.sin(L1 - F) + 318 * np.sin(A2)

        nutinlong = nutation_in_longitude(jd)
        longitude = L1 + d_to_r(lsum / 1000000) + nutinlong
        return longitude
Esempio n. 44
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of solar perigee.

        Arguments:
          - `jd` : Julian Day in dynamical time

        Returns:
          - Longitude of solar perigee in radians

        """
        jd = np.atleast_1d(jd)
        T = jd_to_jcent(jd)

        X = polynomial((1012395.0,
                        6189.03,
                        1.63,
                        0.012), (T + 1))/3600.0
        X = d_to_r(X)

        X = modpi2(X)
        return _scalar_if_one(X)
Esempio n. 45
0
    def mean_longitude(self, jd):
        """Return mean longitude.
        
        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            Longitude in radians
                
        """
        T = jd_to_jcent(jd)

        # From astrolabe
        #X = polynomial((d_to_r(100.466457), d_to_r(36000.7698278), d_to_r(0.00030322), d_to_r(0.000000020)), T)

        # From AA, Naughter
        # Takes T/10.0
        X = polynomial((d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028), d_to_r(1.0/49931), d_to_r(-1.0/15300), d_to_r(-1.0/2000000)), T/10.0)

        X = modpi2(X + pi)
        return X
Esempio n. 46
0
    def _longitude(self, jd):
        """Return the geocentric ecliptic longitude in radians.
        """
        from astronomia.nutation import nutation_in_longitude

        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)
        lsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
            elif abs(tM) == 2:
                tl *= E2
            lsum += tl * np.sin(arg)

        lsum += 3958*np.sin(A1) + 1962*np.sin(L1 - F) + 318*np.sin(A2)

        nutinlong = nutation_in_longitude(jd)
        longitude = L1 + d_to_r(lsum / 1000000) + nutinlong
        return longitude
Esempio n. 47
0
    def mean_longitude_perigee(self, jd):
        """Return mean longitude of solar perigee.
        
        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            Longitude of solar perigee in radians
                
        """
        T = jd_to_jcent(jd)

        X = polynomial((1012395.0, 
                        6189.03  ,
                        1.63     , 
                        0.012    ), (T + 1))/3600.0
        X = d_to_r(X)


        X = modpi2(X)
        return X
Esempio n. 48
0
    def mean_longitude_ascending_node(self, jd):
        """Return mean longitude of ascending node

        Another equation from:
           This routine is part of the International Astronomical Union's
           SOFA (Standards of Fundamental Astronomy) software collection.
           Fundamental (Delaunay) arguments from Simon et al. (1994)

        *  Arcseconds to radians
           DOUBLE PRECISION DAS2R
           PARAMETER ( DAS2R = 4.848136811095359935899141D-6 )

        *  Milliarcseconds to radians
           DOUBLE PRECISION DMAS2R
           PARAMETER ( DMAS2R = DAS2R / 1D3 )

        *  Arc seconds in a full circle
           DOUBLE PRECISION TURNAS
           PARAMETER ( TURNAS = 1296000D0 )

        *  Mean longitude of the ascending node of the Moon.
           OM  = MOD ( 450160.398036D0  -6962890.5431D0*T, TURNAS ) * DAS2R

        Keeping above for documentation, but...
        Current implemention in astronomia is from:

           PJ Naughter (Web: www.naughter.com, Email: [email protected])

        Arguments:
          - `jd` : julian Day

        Returns:
          - mean longitude of ascending node
        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(ko, T))
Esempio n. 49
0
def vsop_to_fk5(jd, L, B):
    """Convert VSOP to FK5 coordinates.

    This is required only when using the full precision of the
    VSOP model.  [Meeus-1998: pg 219]

    Arguments:
      - `jd` : Julian Day in dynamical time
      - `L`  : longitude in radians
      - `B`  : latitude in radians

    Returns:
      - corrected longitude in radians
      - corrected latitude in radians

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    L1 = polynomial([L, _k0, _k1], T)
    cosL1 = np.cos(L1)
    sinL1 = np.sin(L1)
    deltaL = _k2 + _k3*(cosL1 + sinL1)*np.tan(B)
    deltaB = _k3*(cosL1 - sinL1)
    return _scalar_if_one(modpi2(L + deltaL)), _scalar_if_one(B + deltaB)
Esempio n. 50
0
    def _longitude(self, jd):
        """Return the geocentric ecliptic longitude in radians.

        A subset of the logic in dimension3()

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        lsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M +tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
            elif abs(tM == 2):
                tl *= E2
            lsum += tl * sin(arg)

        lsum += 3958 * sin(A1) +      \
                1962 * sin(L1 - F) +  \
                 318 * sin(A2)

        longitude = L1 + d_to_r(lsum / 1000000)
        return longitude
Esempio n. 51
0
    def _longitude(self, jd):
        """Return the geocentric ecliptic longitude in radians.

        A subset of the logic in dimension3()

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        lsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
            elif abs(tM == 2):
                tl *= E2
            lsum += tl * sin(arg)

        lsum += 3958 * sin(A1) +      \
                1962 * sin(L1 - F) +  \
                 318 * sin(A2)

        longitude = L1 + d_to_r(lsum / 1000000)
        return longitude
Esempio n. 52
0
    def mean_longitude_ascending_node(self, jd):
        """Return mean longitude of ascending node

        Another equation from:
            *  This routine is part of the International Astronomical Union's
            *  SOFA (Standards of Fundamental Astronomy) software collection.
            *  Fundamental (Delaunay) arguments from Simon et al. (1994)
        *  Arcseconds to radians
           DOUBLE PRECISION DAS2R
           PARAMETER ( DAS2R = 4.848136811095359935899141D-6 )

        *  Milliarcseconds to radians
           DOUBLE PRECISION DMAS2R
           PARAMETER ( DMAS2R = DAS2R / 1D3 )

        *  Arc seconds in a full circle
           DOUBLE PRECISION TURNAS
           PARAMETER ( TURNAS = 1296000D0 )

        *  Mean longitude of the ascending node of the Moon.
           OM  = MOD ( 450160.398036D0  -6962890.5431D0*T, TURNAS ) * DAS2R

        Current implemention in astronomia is from:
            PJ Naughter (Web: www.naughter.com, Email: [email protected])

            Look in nutation.py for calculation of omega
            _ko  = (d_to_r(125.04452), d_to_r( -1934.136261), d_to_r( 0.0020708), d_to_r( 1.0/450000))
            Though the last term was left off...
            Will have to incorporate better...
        """

        T = jd_to_jcent(jd)
        X = polynomial(
            (d_to_r(125.0445479), d_to_r(-1934.1362891), d_to_r(0.0020754),
             d_to_r(1.0 / 467441.0), d_to_r(1.0 / 60616000.0)), T)
        return modpi2(X)
Esempio n. 53
0
    def mean_longitude_ascending_node(self, jd):
        """Return mean longitude of ascending node

        Another equation from:
           This routine is part of the International Astronomical Union's
           SOFA (Standards of Fundamental Astronomy) software collection.
           Fundamental (Delaunay) arguments from Simon et al. (1994)

        *  Arcseconds to radians
           DOUBLE PRECISION DAS2R
           PARAMETER ( DAS2R = 4.848136811095359935899141D-6 )

        *  Milliarcseconds to radians
           DOUBLE PRECISION DMAS2R
           PARAMETER ( DMAS2R = DAS2R / 1D3 )

        *  Arc seconds in a full circle
           DOUBLE PRECISION TURNAS
           PARAMETER ( TURNAS = 1296000D0 )

        *  Mean longitude of the ascending node of the Moon.
           OM  = MOD ( 450160.398036D0  -6962890.5431D0*T, TURNAS ) * DAS2R

        Keeping above for documentation, but...
        Current implemention in astronomia is from:

           PJ Naughter (Web: www.naughter.com, Email: [email protected])

        Arguments:
          - `jd` : julian Day

        Returns:
          - mean longitude of ascending node
        """
        T = jd_to_jcent(jd)
        return modpi2(polynomial(ko, T))
Esempio n. 54
0
def vsop_to_fk5(jd, L, B):
    """Convert VSOP to FK5 coordinates.

    This is required only when using the full precision of the
    VSOP model.  [Meeus-1998: pg 219]

    Arguments:
      - `jd` : Julian Day in dynamical time
      - `L`  : longitude in radians
      - `B`  : latitude in radians

    Returns:
      - corrected longitude in radians
      - corrected latitude in radians

    """
    jd = np.atleast_1d(jd)
    T = jd_to_jcent(jd)
    L1 = polynomial([L, _k0, _k1], T)
    cosL1 = np.cos(L1)
    sinL1 = np.sin(L1)
    deltaL = _k2 + _k3 * (cosL1 + sinL1) * np.tan(B)
    deltaB = _k3 * (cosL1 - sinL1)
    return _scalar_if_one(modpi2(L + deltaL)), _scalar_if_one(B + deltaB)
Esempio n. 55
0
def equinox_approx(yr, season):
    """Returns the approximate time of a solstice or equinox event.
    
    The year must be in the range -1000...3000. Within that range the
    the error from the precise instant is at most 2.16 minutes.
    
    Parameters:
        yr     : year
        season : one of ("spring", "summer", "autumn", "winter")
    
    Returns:
        Julian Day of the event in dynamical time
    
    """
    if not (-1000 <= yr <= 3000):
        raise Error, "year is out of range"
    if season not in astronomia.globals.season_names:
        raise Error, "unknown season =" + season

    yr = int(yr)
    if -1000 <= yr <= 1000:
        Y = yr / 1000.0
        tbl = _approx_1000
    else:
        Y = (yr - 2000) / 1000.0
        tbl = _approx_3000

    jd = polynomial(tbl[season], Y)
    T = jd_to_jcent(jd)
    W = d_to_r(35999.373 * T - 2.47)
    delta_lambda = 1 + 0.0334 * cos(W) + 0.0007 * cos(2 * W)

    jd += 0.00001 * sum([A * cos(B + C * T)
                         for A, B, C in _terms]) / delta_lambda

    return jd
Esempio n. 56
0
    def mean_longitude(self, jd):
        """Return mean longitude.
        
        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            Longitude in radians
                
        """
        T = jd_to_jcent(jd)

        # From astrolabe
        #X = polynomial((d_to_r(100.466457), d_to_r(36000.7698278), d_to_r(0.00030322), d_to_r(0.000000020)), T)

        # From AA, Naughter
        # Takes T/10.0
        X = polynomial(
            (d_to_r(100.4664567), d_to_r(360007.6982779), d_to_r(0.03032028),
             d_to_r(1.0 / 49931), d_to_r(-1.0 / 15300), d_to_r(
                 -1.0 / 2000000)), T / 10.0)

        X = modpi2(X + pi)
        return X
Esempio n. 57
0
    def dimension3(self, jd):
        """Return geocentric ecliptic longitude, latitude and radius.

        When we need all three dimensions it is more efficient to combine the
        calculations in one routine.

        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            longitude in radians
            latitude in radians
            radius in km, Earth's center to Moon's center

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        #
        # longitude and radius
        #
        lsum = 0.0
        rsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
                tr *= E
            elif abs(tM == 2):
                tl *= E2
                tr *= E2
            lsum += tl * sin(arg)
            rsum += tr * cos(arg)

        #
        # latitude
        #
        bsum = 0.0
        for tD, tM, tM1, tF, tb in _tblB:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tb *= E
            elif abs(tM) == 2:
                tb *= E2
            bsum += tb * sin(arg)

        lsum += 3958 * sin(A1) +       \
                1962 * sin(L1 - F) +   \
                 318 * sin(A2)

        bsum += -2235 * sin(L1) +      \
                  382 * sin(A3) +      \
                  175 * sin(A1 - F) +  \
                  175 * sin(A1 + F) +  \
                  127 * sin(L1 - M1) - \
                  115 * sin(L1 + M1)

        longitude = L1 + d_to_r(lsum / 1000000)
        latitude = d_to_r(bsum / 1000000)
        dist = 385000.56 + rsum / 1000
        return longitude, latitude, dist
Esempio n. 58
0
    def dimension3(self, jd):
        """Return geocentric ecliptic longitude, latitude and radius.

        When we need all three dimensions it is more efficient to combine the
        calculations in one routine.

        Parameters:
            jd : Julian Day in dynamical time

        Returns:
            longitude in radians
            latitude in radians
            radius in km, Earth's center to Moon's center

        """
        T = jd_to_jcent(jd)
        L1, D, M, M1, F, A1, A2, A3, E, E2 = _constants(T)

        #
        # longitude and radius
        #
        lsum = 0.0
        rsum = 0.0
        for tD, tM, tM1, tF, tl, tr in _tblLR:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tl *= E
                tr *= E
            elif abs(tM == 2):
                tl *= E2
                tr *= E2
            lsum += tl * sin(arg)
            rsum += tr * cos(arg)

        #
        # latitude
        #
        bsum = 0.0
        for tD, tM, tM1, tF, tb in _tblB:
            arg = tD * D + tM * M + tM1 * M1 + tF * F
            if abs(tM) == 1:
                tb *= E
            elif abs(tM) == 2:
                tb *= E2
            bsum += tb * sin(arg)

        lsum += 3958 * sin(A1) +       \
                1962 * sin(L1 - F) +   \
                 318 * sin(A2)

        bsum += -2235 * sin(L1) +      \
                  382 * sin(A3) +      \
                  175 * sin(A1 - F) +  \
                  175 * sin(A1 + F) +  \
                  127 * sin(L1 - M1) - \
                  115 * sin(L1 + M1)

        longitude = L1 + d_to_r(lsum / 1000000)
        latitude = d_to_r(bsum / 1000000)
        dist = 385000.56 + rsum / 1000
        return longitude, latitude, dist