Kackle commited on
Commit
2c2a457
·
verified ·
1 Parent(s): 90bb313

fix for a few issues

Browse files
Files changed (1) hide show
  1. app.py +15 -16
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 calclateCelestrialAzimuth(_long:float, _lat:float, _celeasrealObj:str, observationTime:datetime)-> str: #it's import to specify the return type
19
- #Keep this format for the description / args / args description but feel free to modify the tool
20
- """A tool that does nothing yet
21
  Args:
22
- lon: longitute of the observer
23
- lat: latitude of observer
24
- celeasrealObj: object the observer is trying to locate
25
- observationTime: time of observation
26
  """
27
  try:
28
  # Define observer location
29
- observer_location = EarthLocation(lat=_lat * u.deg, _long=-74 * u.deg, height=390 * u.m)
30
 
31
- # Define observation time
32
- time = celeasrealObj #Time("2025-06-06 23:00:00") - 4 * u.hour # Adjust for timezone
33
 
34
- # Get celestial object coordinates (e.g., M33)
35
- celeasrealObj = SkyCoord.from_name(_celeasrealObj)
36
 
37
  # Convert to AltAz frame
38
- obj_altaz = m33.transform_to(AltAz(obstime=time, location=observer_location))
39
 
40
- print(f"Azimuth = {obj_altaz.az:.2f}, Altitude = {obj_altaz.alt:.2f}")
41
-
42
- return f"Azimuth = {obj_altaz.az:.2f}, Altitude = {obj_altaz.alt:.2f}"
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: