SergeyO7 commited on
Commit
af624bb
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -0
app.py CHANGED
@@ -7,6 +7,72 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ from skyfield.api import load, Topos
11
+ from skyfield.almanac import find_discrete, moon_phase_fraction
12
+ import gradio as gr
13
+
14
+ # Load astronomical data
15
+ planets = load('de421.bsp') # Downloaded from JPL Horizons
16
+ ts = load.timescale()
17
+
18
+ # Define Zodiac signs and their boundaries
19
+ ZODIAC_SIGNS = [
20
+ ("Aries", 0, 30),
21
+ ("Taurus", 30, 60),
22
+ ("Gemini", 60, 90),
23
+ ("Cancer", 90, 120),
24
+ ("Leo", 120, 150),
25
+ ("Virgo", 150, 180),
26
+ ("Libra", 180, 210),
27
+ ("Scorpio", 210, 240),
28
+ ("Sagittarius", 240, 270),
29
+ ("Capricorn", 270, 300),
30
+ ("Aquarius", 300, 330),
31
+ ("Pisces", 330, 360),
32
+ ]
33
+
34
+ def get_moon_position():
35
+ """Calculate the current Moon position in the Zodiac."""
36
+ now = datetime.datetime.now(pytz.utc)
37
+ t = ts.from_datetime(now)
38
+
39
+ # Get the geocentric position of the Moon
40
+ earth = planets['earth']
41
+ moon = planets['moon']
42
+ astrometric = earth.at(t).observe(moon)
43
+ ra, dec, distance = astrometric.radec()
44
+
45
+ # Convert RA to degrees
46
+ ra_in_degrees = ra._degrees
47
+
48
+ # Determine the Zodiac sign based on RA
49
+ for sign, start, end in ZODIAC_SIGNS:
50
+ if start <= ra_in_degrees < end:
51
+ return f"{sign} ({start}° - {end}°)"
52
+
53
+ return "Unknown"
54
+
55
+ def create_gradio_interface():
56
+ """Create a Gradio interface for the Moon position tool."""
57
+ def predict():
58
+ moon_pos = get_moon_position()
59
+ return f"The Moon is currently in {moon_pos}."
60
+
61
+ iface = gr.Interface(
62
+ fn=predict,
63
+ inputs=None,
64
+ outputs="text",
65
+ title="Moon Position in Zodiac",
66
+ description="This tool calculates the current position of the Moon in the Zodiac.",
67
+ )
68
+ return iface
69
+
70
+ if __name__ == "__main__":
71
+ # Launch the Gradio interface
72
+ interface = create_gradio_interface()
73
+ interface.launch()
74
+
75
+
76
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
77
  @tool
78
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type