def lunar_node(tee): """Return Angular distance of the node from the equinoctal point at fixed moment, tee. Adapted from eq. 47.7 in "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed., 1998 with corrections June 2005.""" return (moon_node(julian_centuries(tee)) + 90) % 180 - 90
def lunar_longitude(tee): """Return longitude of moon (in degrees) at moment tee. Adapted from "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed., 1998.""" c = julian_centuries(tee) cap_L_prime = mean_lunar_longitude(c) cap_D = lunar_elongation(c) cap_M = solar_anomaly(c) cap_M_prime = lunar_anomaly(c) cap_F = moon_node(c) # see eq. 47.6 in Meeus cap_E = poly(c, [1, mpf(-0.002516), mpf(-0.0000074)]) args_lunar_elongation = \ [0, 2, 2, 0, 0, 0, 2, 2, 2, 2, 0, 1, 0, 2, 0, 0, 4, 0, 4, 2, 2, 1, 1, 2, 2, 4, 2, 0, 2, 2, 1, 2, 0, 0, 2, 2, 2, 4, 0, 3, 2, 4, 0, 2, 2, 2, 4, 0, 4, 1, 2, 0, 1, 3, 4, 2, 0, 1, 2] args_solar_anomaly = \ [0, 0, 0, 0, 1, 0, 0, -1, 0, -1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, -2, 1, 2, -2, 0, 0, -1, 0, 0, 1, -1, 2, 2, 1, -1, 0, 0, -1, 0, 1, 0, 1, 0, 0, -1, 2, 1, 0] args_lunar_anomaly = \ [1, -1, 0, 2, 0, 0, -2, -1, 1, 0, -1, 0, 1, 0, 1, 1, -1, 3, -2, -1, 0, -1, 0, 1, 2, 0, -3, -2, -1, -2, 1, 0, 2, 0, -1, 1, 0, -1, 2, -1, 1, -2, -1, -1, -2, 0, 1, 4, 0, -2, 0, 2, 1, -2, -3, 2, 1, -1, 3] args_moon_node = \ [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -2, 2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, -2, 2, 0, 2, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0] sine_coefficients = \ [6288774,1274027,658314,213618,-185116,-114332, 58793,57066,53322,45758,-40923,-34720,-30383, 15327,-12528,10980,10675,10034,8548,-7888, -6766,-5163,4987,4036,3994,3861,3665,-2689, -2602, 2390,-2348,2236,-2120,-2069,2048,-1773, -1595,1215,-1110,-892,-810,759,-713,-700,691, 596,549,537,520,-487,-399,-381,351,-340,330, 327,-323,299,294] correction = ((1.0 / 1000000.0) * sigma([ sine_coefficients, args_lunar_elongation, args_solar_anomaly, args_lunar_anomaly, args_moon_node ], lambda v, w, x, y, z: v * pow(cap_E, abs(x)) * sin_degrees( (w * cap_D) + (x * cap_M) + (y * cap_M_prime) + (z * cap_F)))) A1 = mpf(119.75) + (c * mpf(131.849)) venus = ((3958 / 1000000) * sin_degrees(A1)) A2 = mpf(53.09) + c * mpf(479264.29) jupiter = ((318 / 1000000) * sin_degrees(A2)) flat_earth = ((1962 / 1000000) * sin_degrees(cap_L_prime - cap_F)) return (cap_L_prime + correction + venus + jupiter + flat_earth + nutation(tee)) % 360
def lunar_perigee(tee): """Return Angular distance of the perigee from the equinoctal point at moment, tee. Adapted from eq. 47.7 in "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed., 1998 with corrections June 2005.""" return normalized_degrees( poly(julian_centuries(tee), [ mpf(83.3532465), mpf(4069.0137287), mpf(-0.0103200), mpf(-1.0 / 80053.0), mpf(1.0 / 18999000.0) ]))
def alt_lunar_node(tee): """Return Angular distance of the node from the equinoctal point at fixed moment, tee. Adapted from eq. 47.7 in "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed., 1998 with corrections June 2005.""" return normalized_degrees( poly(julian_centuries(tee), [ mpf(125.0445479), mpf(-1934.1362891), mpf(0.0020754), mpf(1.0 / 467441.0), mpf(-1.0 / 60616000.0) ]))
def lunar_latitude(tee): """Return the latitude of moon (in degrees) at moment, tee. Adapted from "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 1998.""" c = julian_centuries(tee) cap_L_prime = mean_lunar_longitude(c) cap_D = lunar_elongation(c) cap_M = solar_anomaly(c) cap_M_prime = lunar_anomaly(c) cap_F = moon_node(c) cap_E = poly(c, [1, mpf(-0.002516), mpf(-0.0000074)]) args_lunar_elongation = \ [0, 0, 0, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 4, 0, 4, 2, 2, 2, 2, 0, 2, 2, 2, 2, 4, 2, 2, 0, 2, 1, 1, 0, 2, 1, 2, 0, 4, 4, 1, 4, 1, 4, 2] args_solar_anomaly = \ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, -1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 1, 0, -1, -2, 0, 1, 1, 1, 1, 1, 0, -1, 1, 0, -1, 0, 0, 0, -1, -2] args_lunar_anomaly = \ [0, 1, 1, 0, -1, -1, 0, 2, 1, 2, 0, -2, 1, 0, -1, 0, -1, -1, -1, 0, 0, -1, 0, 1, 1, 0, 0, 3, 0, -1, 1, -2, 0, 2, 1, -2, 3, 2, -3, -1, 0, 0, 1, 0, 1, 1, 0, 0, -2, -1, 1, -2, 2, -2, -1, 1, 1, -2, 0, 0] args_moon_node = \ [1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 3, 1, 1, 1, -1, -1, -1, 1, -1, 1, -3, 1, -3, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 3, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1] sine_coefficients = \ [5128122, 280602, 277693, 173237, 55413, 46271, 32573, 17198, 9266, 8822, 8216, 4324, 4200, -3359, 2463, 2211, 2065, -1870, 1828, -1794, -1749, -1565, -1491, -1475, -1410, -1344, -1335, 1107, 1021, 833, 777, 671, 607, 596, 491, -451, 439, 422, 421, -366, -351, 331, 315, 302, -283, -229, 223, 223, -220, -220, -185, 181, -177, 176, 166, -164, 132, -119, 115, 107] beta = ((1.0 / 1000000.0) * sigma([ sine_coefficients, args_lunar_elongation, args_solar_anomaly, args_lunar_anomaly, args_moon_node ], lambda v, w, x, y, z: (v * pow(cap_E, abs(x)) * sin_degrees( (w * cap_D) + (x * cap_M) + (y * cap_M_prime) + (z * cap_F))))) venus = ((175 / 1000000) * (sin_degrees(mpf(119.75) + c * mpf(131.849) + cap_F) + sin_degrees(mpf(119.75) + c * mpf(131.849) - cap_F))) flat_earth = ((-2235 / 1000000) * sin_degrees(cap_L_prime) + (127 / 1000000) * sin_degrees(cap_L_prime - cap_M_prime) + (-115 / 1000000) * sin_degrees(cap_L_prime + cap_M_prime)) extra = ((382 / 1000000) * sin_degrees(mpf(313.45) + c * mpf(481266.484))) return beta + venus + flat_earth + extra
def lunar_true_node(tee): """Return Angular distance of the true node (the node of the instantaneus lunar orbit) from the equinoctal point at moment, tee. Adapted from eq. 47.7 and pag. 344 in "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed., 1998 with corrections June 2005.""" c = julian_centuries(tee) cap_D = lunar_elongation(c) cap_M = solar_anomaly(c) cap_M_prime = lunar_anomaly(c) cap_F = moon_node(c) periodic_terms = (-1.4979 * sin_degrees(2 * (cap_D - cap_F)) + -0.1500 * sin_degrees(cap_M) + -0.1226 * sin_degrees(2 * cap_D) + 0.1176 * sin_degrees(2 * cap_F) + -0.0801 * sin_degrees(2 * (cap_M_prime - cap_F))) return alt_lunar_node(tee) + periodic_terms
def lunar_distance(tee): """Return the distance to moon (in meters) at moment, tee. Adapted from "Astronomical Algorithms" by Jean Meeus, Willmann_Bell, Inc., 2nd ed.""" c = julian_centuries(tee) cap_D = lunar_elongation(c) cap_M = solar_anomaly(c) cap_M_prime = lunar_anomaly(c) cap_F = moon_node(c) cap_E = poly(c, [1, mpf(-0.002516), mpf(-0.0000074)]) args_lunar_elongation = \ [0, 2, 2, 0, 0, 0, 2, 2, 2, 2, 0, 1, 0, 2, 0, 0, 4, 0, 4, 2, 2, 1, 1, 2, 2, 4, 2, 0, 2, 2, 1, 2, 0, 0, 2, 2, 2, 4, 0, 3, 2, 4, 0, 2, 2, 2, 4, 0, 4, 1, 2, 0, 1, 3, 4, 2, 0, 1, 2, 2,] args_solar_anomaly = \ [0, 0, 0, 0, 1, 0, 0, -1, 0, -1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, -2, 1, 2, -2, 0, 0, -1, 0, 0, 1, -1, 2, 2, 1, -1, 0, 0, -1, 0, 1, 0, 1, 0, 0, -1, 2, 1, 0, 0] args_lunar_anomaly = \ [1, -1, 0, 2, 0, 0, -2, -1, 1, 0, -1, 0, 1, 0, 1, 1, -1, 3, -2, -1, 0, -1, 0, 1, 2, 0, -3, -2, -1, -2, 1, 0, 2, 0, -1, 1, 0, -1, 2, -1, 1, -2, -1, -1, -2, 0, 1, 4, 0, -2, 0, 2, 1, -2, -3, 2, 1, -1, 3, -1] args_moon_node = \ [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -2, 2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, -2, 2, 0, 2, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, -2] cosine_coefficients = \ [-20905355, -3699111, -2955968, -569925, 48888, -3149, 246158, -152138, -170733, -204586, -129620, 108743, 104755, 10321, 0, 79661, -34782, -23210, -21636, 24208, 30824, -8379, -16675, -12831, -10445, -11650, 14403, -7003, 0, 10056, 6322, -9884, 5751, 0, -4950, 4130, 0, -3958, 0, 3258, 2616, -1897, -2117, 2354, 0, 0, -1423, -1117, -1571, -1739, 0, -4421, 0, 0, 0, 0, 1165, 0, 0, 8752] correction = sigma([ cosine_coefficients, args_lunar_elongation, args_solar_anomaly, args_lunar_anomaly, args_moon_node ], lambda v, w, x, y, z: (v * pow(cap_E, abs(x)) * cos_degrees( (w * cap_D) + (x * cap_M) + (y * cap_M_prime) + (z * cap_F)))) return 385000560 + correction
def solar_longitude(tee): """Return the longitude of sun at moment 'tee'. Adapted from 'Planetary Programs and Tables from -4000 to +2800' by Pierre Bretagnon and Jean_Louis Simon, Willmann_Bell, Inc., 1986. See also pag 166 of 'Astronomical Algorithms' by Jean Meeus, 2nd Ed 1998, with corrections Jun 2005.""" c = julian_centuries(tee) coefficients = [ 403406, 195207, 119433, 112392, 3891, 2819, 1721, 660, 350, 334, 314, 268, 242, 234, 158, 132, 129, 114, 99, 93, 86, 78, 72, 68, 64, 46, 38, 37, 32, 29, 28, 27, 27, 25, 24, 21, 21, 20, 18, 17, 14, 13, 13, 13, 12, 10, 10, 10, 10 ] multipliers = [ mpf(0.9287892), mpf(35999.1376958), mpf(35999.4089666), mpf(35998.7287385), mpf(71998.20261), mpf(71998.4403), mpf(36000.35726), mpf(71997.4812), mpf(32964.4678), mpf(-19.4410), mpf(445267.1117), mpf(45036.8840), mpf(3.1008), mpf(22518.4434), mpf(-19.9739), mpf(65928.9345), mpf(9038.0293), mpf(3034.7684), mpf(33718.148), mpf(3034.448), mpf(-2280.773), mpf(29929.992), mpf(31556.493), mpf(149.588), mpf(9037.750), mpf(107997.405), mpf(-4444.176), mpf(151.771), mpf(67555.316), mpf(31556.080), mpf(-4561.540), mpf(107996.706), mpf(1221.655), mpf(62894.167), mpf(31437.369), mpf(14578.298), mpf(-31931.757), mpf(34777.243), mpf(1221.999), mpf(62894.511), mpf(-4442.039), mpf(107997.909), mpf(119.066), mpf(16859.071), mpf(-4.578), mpf(26895.292), mpf(-39.127), mpf(12297.536), mpf(90073.778) ] addends = [ mpf(270.54861), mpf(340.19128), mpf(63.91854), mpf(331.26220), mpf(317.843), mpf(86.631), mpf(240.052), mpf(310.26), mpf(247.23), mpf(260.87), mpf(297.82), mpf(343.14), mpf(166.79), mpf(81.53), mpf(3.50), mpf(132.75), mpf(182.95), mpf(162.03), mpf(29.8), mpf(266.4), mpf(249.2), mpf(157.6), mpf(257.8), mpf(185.1), mpf(69.9), mpf(8.0), mpf(197.1), mpf(250.4), mpf(65.3), mpf(162.7), mpf(341.5), mpf(291.6), mpf(98.5), mpf(146.7), mpf(110.0), mpf(5.2), mpf(342.6), mpf(230.9), mpf(256.1), mpf(45.3), mpf(242.9), mpf(115.2), mpf(151.8), mpf(285.3), mpf(53.3), mpf(126.6), mpf(205.7), mpf(85.9), mpf(146.1) ] lam = (mpf(282.7771834) + mpf(36000.76953744) * c + mpf(0.000005729577951308232) * sigma([coefficients, addends, multipliers], lambda x, y, z: x * sin_degrees(y + (z * c)))) return (lam + aberration(tee) + nutation(tee)) % 360
def geometric_solar_mean_longitude(tee): """Return the geometric mean longitude of the Sun at moment, tee, referred to mean equinox of the date.""" c = julian_centuries(tee) return poly(c, [mpf(280.46646), mpf(36000.76983), mpf(0.0003032)])