44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Check real_radius for all planets"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
|
|
sys.path.append(os.path.join(os.getcwd(), "backend"))
|
|
|
|
from app.database import AsyncSessionLocal
|
|
from sqlalchemy import select
|
|
from app.models.db.celestial_body import CelestialBody
|
|
|
|
async def check_radii():
|
|
async with AsyncSessionLocal() as session:
|
|
# Get all planets and dwarf planets
|
|
stmt = select(CelestialBody).where(
|
|
CelestialBody.type.in_(['planet', 'dwarf_planet', 'star'])
|
|
).order_by(CelestialBody.name)
|
|
|
|
result = await session.execute(stmt)
|
|
bodies = result.scalars().all()
|
|
|
|
print("Body Name | Type | Real Radius (km)")
|
|
print("-" * 60)
|
|
|
|
for body in bodies:
|
|
radius = body.extra_data.get('real_radius') if body.extra_data else None
|
|
print(f"{body.name:20s} | {body.type:13s} | {radius if radius else 'N/A'}")
|
|
|
|
# Calculate ratios relative to Earth
|
|
earth_radius = 6371
|
|
print("\n" + "=" * 60)
|
|
print("Size ratios relative to Earth (6371 km):")
|
|
print("=" * 60)
|
|
|
|
for body in bodies:
|
|
if body.extra_data and body.extra_data.get('real_radius'):
|
|
radius = body.extra_data['real_radius']
|
|
ratio = radius / earth_radius
|
|
print(f"{body.name:20s}: {radius:8.0f} km = {ratio:6.2f}x Earth")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(check_radii())
|