# arabic parts

Jun 3rd, 2023
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. from datetime import datetime
3. import time
4.
5. def calculate_arabic_part(degrees, minutes, seconds):
6.     total_degrees = degrees + (minutes / 60) + (seconds / 3600)
7.     arabic_part = (total_degrees + 180) % 360
8.     return arabic_part
9.
10. def calculate_sun_arabic_part(day, month, year, hour, minute, second):
11.     jd = get_julian_day(day, month, year)
12.     t = get_julian_century(jd)
13.     l = get_mean_longitude(t, "Sun")
14.     p = get_mean_anomaly(t, "Sun")
15.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
16.
17. def calculate_moon_arabic_part(day, month, year, hour, minute, second):
18.     jd = get_julian_day(day, month, year)
19.     t = get_julian_century(jd)
20.     l = get_mean_longitude(t, "Moon")
21.     p = get_mean_anomaly(t, "Moon")
22.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
23.
24. def calculate_venus_arabic_part(day, month, year, hour, minute, second):
25.     jd = get_julian_day(day, month, year)
26.     t = get_julian_century(jd)
27.     l = get_mean_longitude(t, "Venus")
28.     p = get_mean_anomaly(t, "Venus")
29.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
30.
31. def calculate_mars_arabic_part(day, month, year, hour, minute, second):
32.     jd = get_julian_day(day, month, year)
33.     t = get_julian_century(jd)
34.     l = get_mean_longitude(t, "Mars")
35.     p = get_mean_anomaly(t, "Mars")
36.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
37.
38. def calculate_mercury_arabic_part(day, month, year, hour, minute, second):
39.     jd = get_julian_day(day, month, year)
40.     t = get_julian_century(jd)
41.     l = get_mean_longitude(t, "Mercury")
42.     p = get_mean_anomaly(t, "Mercury")
43.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
44.
45. def calculate_saturn_arabic_part(day, month, year, hour, minute, second):
46.     jd = get_julian_day(day, month, year)
47.     t = get_julian_century(jd)
48.     l = get_mean_longitude(t, "Saturn")
49.     p = get_mean_anomaly(t, "Saturn")
50.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
51.
52. def calculate_uranus_arabic_part(day, month, year, hour, minute, second):
53.     jd = get_julian_day(day, month, year)
54.     t = get_julian_century(jd)
55.     l = get_mean_longitude(t, "Uranus")
56.     p = get_mean_anomaly(t, "Uranus")
57.     return calculate_arabic_part(l, 0, 0) + calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
58.
59. def calculate_jupiter_arabic_part(day, month, year, hour, minute, second):
60.     jd = get_julian_day(day, month, year)
61.     t = get_julian_century(jd)
62.     l = get_mean_longitude(t, "Jupiter")
63.     p = get_mean_anomaly(t, "Jupiter")
64.     return calculate_arabic_part(l, 0, 0) +  calculate_arabic_part(p, 0, 0) - calculate_arabic_part(l, 0, 0)
65.
66.
67. def get_mean_longitude(t, planet):
68.     if planet == "Sun":
69.         return (280.4664567 + (360007.6982779 * t) + (0.03032028 * math.pow(t, 2)) + (1/49931 * math.pow(t, 3)) - (1/15299 * math.pow(t, 4)) - (1/1988000 * math.pow(t, 5))) % 360
70.     elif planet == "Moon":
71.         return (218.3165 + (481267.8813 * t) - (0.0013268 * math.pow(t, 2)) + (math.pow(t, 3) / 538841) - (math.pow(t, 4) / 65194000)) % 360
72.     elif planet == "Venus":
73.         return (280.461 + (58519.813 * t) + (0.0002447095833333 * math.pow(t, 2))) % 360
74.     elif planet == "Mars":
75.         return (352.8840 + (35999.0498 * t) - (0.0001536 * math.pow(t, 2))) % 360
76.     elif planet == "Mercury":
77.         return (281.22083333 + (149472.67486623 * t) + (0.000005379 * math.pow(t, 2)) - (0.00000000273 * math.pow(t, 3))) % 360
78.     elif planet == "Uranus":
79.        return (314.20666 + (54.950137 * t) - (0.0015786 * math.pow(t, 2))) % 360
80.     elif planet == "Jupiter":
81.        return (219.991069 + (3034.066573 * t) - (0.0084479 * math.pow(t, 2))) % 360
82.     elif planet == "Saturn":
83.        return (38.907060 + (1186.607332 * t) - (0.001592 * math.pow(t ,2  ))) % 360
84.
85. def get_mean_anomaly(t, planet):
86.     if planet == "Sun":
87.         return (357.5291 + (35999.0503 * t) - (0.0001559 * math.pow(t, 2)) - (0.00000048 * math.pow(t, 3))) % 360
88.     elif planet == "Moon":
89.         return (134.9634 + (477198.8675 * t) + (0.0088553 * math.pow(t, 2)) + (math.pow(t, 3) / 69699) - (math.pow(t, 4) / 14712000)) % 360
90.     elif planet == "Venus":
91.         return (50.341 + (58519.813 * t) + (0.0005451041666667 * math.pow(t, 2)) % 360)
92.     elif planet == "Mars":
93.         return (319.5294 + (19139.8585 * t) + (0.0001815 * math.pow(t, 2))) % 360
94.     elif planet == "Mercury":
95.         return (174.215556 + (149472.67486623 * t) + (0.000005378 * math.pow(t, 2)) + (0.00000000274 * math.pow(t, 3))) % 360
96.     elif planet == "Uranus":
97.        return (210.3313 + (54.950137 * t)) % 360
98.     elif planet == "Jupiter":
99.        return (239.9242 + (3034.0660 * t) - (0.0080197 * math.pow(t, 2))) % 360
100.     elif planet == "Saturn":
101.        return (206.1082 + (1186.607 * t) - (0.0014680 * math.pow(t, 2)) + (22.7449 * math.sin(682.600 * t -0.557))) % 360
102.
103. def get_julian_day(day, month, year):
104.     if month <= 2:
105.         year -= 1
106.         month += 12
107.     a = math.floor(year / 100)
108.     b = 2 - a + math.floor(a / 4)
109.     return math.floor(365.25 * (year + 4716)) + math.floor(30.6001 * (month + 1)) + day + b - 1524.5
110.
111. def get_julian_century(jd):
112.     return (jd - 2451545) / 36525
113.
114. # Example usage:
115.
116. while True:
117.     now = datetime.now()
118.
119.     day = now.day
120.     month = now.month
121.     year = now.year
122.
123.     hour = now.hour
124.     minute = now.minute
125.     second = now.second
126.
127.     sun_arabic_part = calculate_sun_arabic_part(day, month, year, hour, minute, second)
128.     moon_arabic_part = calculate_moon_arabic_part(day, month, year, hour, minute, second)
129.     venus_arabic_part = calculate_venus_arabic_part(day, month, year, hour, minute, second)
130.     mars_arabic_part = calculate_mars_arabic_part(day, month, year, hour, minute, second)
131.     mercury_arabic_part = calculate_mercury_arabic_part(day, month, year, hour, minute, second)
132.     saturn_arabic_part =  calculate_saturn_arabic_part(day, month, year, hour, minute, second)
133.     uranus_arabic_part = calculate_uranus_arabic_part(day, month, year, hour, minute, second)
134.     jupiter_arabic_part = calculate_jupiter_arabic_part(day, month, year, hour, minute, second)
135.
136.     print(f"Sun Arabic Part: {sun_arabic_part}")
137.     print(f"Moon Arabic Part: {moon_arabic_part}")
138.     print(f"Venus Arabic Part:{venus_arabic_part}")
139.     print(f"Mars Arabic Part: {mars_arabic_part}")
140.     print(f"Mercury Arabic Part: {mercury_arabic_part}")
141.     print(f"Saturn Arabic Part:{saturn_arabic_part}")
142.     print(f"Uranus Arabic Part:{uranus_arabic_part}")
143.     print(f"Jupiter Arabic Part:{jupiter_arabic_part}")
144.
145.     # Wait 5 seconds and recalculate
146.     time.sleep(5)
147.     print()
148.