Spaces:
Sleeping
Sleeping
fix for a few issues
Browse files
app.py
CHANGED
|
@@ -15,31 +15,30 @@ from Gradio_UI import GradioUI
|
|
| 15 |
|
| 16 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 17 |
@tool
|
| 18 |
-
def
|
| 19 |
-
|
| 20 |
-
"""A tool that does nothing yet
|
| 21 |
Args:
|
| 22 |
-
lon:
|
| 23 |
-
lat: latitude of observer
|
| 24 |
-
|
| 25 |
-
|
| 26 |
"""
|
| 27 |
try:
|
| 28 |
# Define observer location
|
| 29 |
-
observer_location = EarthLocation(lat=
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
time =
|
| 33 |
|
| 34 |
-
# Get celestial object coordinates
|
| 35 |
-
|
| 36 |
|
| 37 |
# Convert to AltAz frame
|
| 38 |
-
obj_altaz =
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
@tool
|
| 45 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 15 |
|
| 16 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 17 |
@tool
|
| 18 |
+
def calculateCelestialAzimuth(lon: float, lat: float, celestial_obj: str, observation_time: str) -> str:
|
| 19 |
+
"""Calculate the azimuth and altitude of a celestial object
|
|
|
|
| 20 |
Args:
|
| 21 |
+
lon: longitude of the observer (in degrees)
|
| 22 |
+
lat: latitude of observer (in degrees)
|
| 23 |
+
celestial_obj: name of celestial object to locate (e.g., 'Moon', 'Sun', 'M31')
|
| 24 |
+
observation_time: time of observation (ISO format: YYYY-MM-DD HH:MM:SS)
|
| 25 |
"""
|
| 26 |
try:
|
| 27 |
# Define observer location
|
| 28 |
+
observer_location = EarthLocation(lat=lat * u.deg, lon=lon * u.deg, height=0 * u.m)
|
| 29 |
|
| 30 |
+
# Parse observation time
|
| 31 |
+
time = Time(observation_time)
|
| 32 |
|
| 33 |
+
# Get celestial object coordinates
|
| 34 |
+
obj_coords = SkyCoord.from_name(celestial_obj)
|
| 35 |
|
| 36 |
# Convert to AltAz frame
|
| 37 |
+
obj_altaz = obj_coords.transform_to(AltAz(obstime=time, location=observer_location))
|
| 38 |
|
| 39 |
+
return f"Azimuth = {obj_altaz.az:.2f}, Altitude = {obj_altaz.alt:.2f}"
|
| 40 |
+
except Exception as e:
|
| 41 |
+
return f"Error calculating celestial coordinates: {str(e)}"
|
| 42 |
|
| 43 |
@tool
|
| 44 |
def get_current_time_in_timezone(timezone: str) -> str:
|