Spaces:
Sleeping
Sleeping
correct phase
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
import datetime
|
8 |
import ephem
|
9 |
from Gradio_UI import GradioUI
|
|
|
10 |
|
11 |
|
12 |
@tool
|
@@ -33,24 +34,37 @@ def get_moon_phase(date: datetime.date) -> str:
|
|
33 |
moon = ephem.Moon(observer)
|
34 |
phase = moon.phase
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
phase_name = "New Moon 🌑"
|
38 |
-
elif
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
phase_name = "
|
44 |
-
elif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
phase_name = "Full Moon 🌕"
|
46 |
-
elif 62.5 <= phase < 75:
|
47 |
-
phase_name = "Waning Gibbous 🌖"
|
48 |
-
elif 75 <= phase < 87.5:
|
49 |
-
phase_name = "Third Quarter 🌗"
|
50 |
-
elif 87.5 <= phase <= 100:
|
51 |
-
phase_name = "Waning Crescent 🌘"
|
52 |
-
else:
|
53 |
-
phase_name = "Unknown"
|
54 |
|
55 |
return f"{phase_name} ({phase:.2f}%) on {date}"
|
56 |
|
|
|
7 |
import datetime
|
8 |
import ephem
|
9 |
from Gradio_UI import GradioUI
|
10 |
+
from datetime import timedelta
|
11 |
|
12 |
|
13 |
@tool
|
|
|
34 |
moon = ephem.Moon(observer)
|
35 |
phase = moon.phase
|
36 |
|
37 |
+
observer.date = date - timedelta(days=1)
|
38 |
+
|
39 |
+
moon = ephem.Moon(observer)
|
40 |
+
yesterday_phase = moon.phase
|
41 |
+
|
42 |
+
if phase > yesterday_phase:
|
43 |
+
phase_trend = "Waxing"
|
44 |
+
else:
|
45 |
+
phase_trend = "Waning"
|
46 |
+
|
47 |
+
if 0 <= phase < 1:
|
48 |
phase_name = "New Moon 🌑"
|
49 |
+
elif 1 <= phase < 49:
|
50 |
+
if phase_trend == "Waxing":
|
51 |
+
phase_emoji = "🌒"
|
52 |
+
else:
|
53 |
+
phase_emoji = "🌘"
|
54 |
+
phase_name = f"{phase_trend} Crescent {phase_emoji}"
|
55 |
+
elif phase == 50:
|
56 |
+
if phase_trend == "Waxing":
|
57 |
+
phase_name = "First Quarter 🌓"
|
58 |
+
else:
|
59 |
+
phase_name = "Last Quarter 🌗"
|
60 |
+
elif 51 <= phase < 99:
|
61 |
+
if phase_trend == "Waxing":
|
62 |
+
phase_emoji = "🌔"
|
63 |
+
else:
|
64 |
+
phase_emoji = "🌖"
|
65 |
+
phase_name = f"{phase_trend} Gibbous {phase_emoji}"
|
66 |
+
elif phase == 100:
|
67 |
phase_name = "Full Moon 🌕"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
return f"{phase_name} ({phase:.2f}%) on {date}"
|
70 |
|