50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""
|
|
Test fetching Pluto position from NASA Horizons
|
|
"""
|
|
import asyncio
|
|
from datetime import datetime, UTC
|
|
from app.services.horizons import HorizonsService
|
|
|
|
|
|
async def test_pluto():
|
|
"""Test if we can fetch Pluto's position"""
|
|
print("🔍 Testing Pluto position fetch from NASA Horizons API...")
|
|
|
|
horizons = HorizonsService()
|
|
|
|
try:
|
|
# Fetch current position for Pluto (ID: 999)
|
|
now = datetime.now(UTC)
|
|
positions = horizons.get_body_positions(
|
|
body_id="999",
|
|
start_time=now,
|
|
end_time=now,
|
|
step="1d"
|
|
)
|
|
|
|
if positions:
|
|
print(f"\n✅ Successfully fetched Pluto position!")
|
|
print(f" Time: {positions[0].time}")
|
|
print(f" Position (AU):")
|
|
print(f" X: {positions[0].x:.4f}")
|
|
print(f" Y: {positions[0].y:.4f}")
|
|
print(f" Z: {positions[0].z:.4f}")
|
|
|
|
# Calculate distance from Sun
|
|
import math
|
|
distance = math.sqrt(
|
|
positions[0].x**2 +
|
|
positions[0].y**2 +
|
|
positions[0].z**2
|
|
)
|
|
print(f" Distance from Sun: {distance:.2f} AU")
|
|
else:
|
|
print("❌ No position data returned")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error fetching Pluto position: {e}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_pluto())
|