cosmo/verify_final_sizes.py

67 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python3
"""Verify final sizes after updates"""
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
from app.services.system_settings_service import system_settings_service
async def verify_final_sizes():
async with AsyncSessionLocal() as session:
# Get updated config
configs = await system_settings_service.get_setting_value('celestial_type_configs', session)
# Solar System body IDs
solar_ids = ['10', '199', '299', '399', '499', '599', '699', '799', '899', '999',
'2000001', '136199', '136108', '136472']
stmt = select(CelestialBody).where(CelestialBody.id.in_(solar_ids))
result = await session.execute(stmt)
bodies = result.scalars().all()
print("=" * 85)
print("FINAL VERIFICATION - All Celestial Body Sizes")
print("=" * 85)
print(f"{'Name':<20} {'Type':<15} {'Real Radius':<15} {'Ratio':<12} {'Display Size':<12} {'vs Earth'}")
print("-" * 85)
earth_size = None
sizes = []
for body in sorted(bodies, key=lambda b: b.extra_data.get('real_radius', 0) if b.extra_data else 0, reverse=True):
if body.extra_data and body.extra_data.get('real_radius'):
real_radius = body.extra_data['real_radius']
ratio = configs[body.type]['ratio']
display_size = real_radius * ratio
sizes.append((body.name, body.type, real_radius, ratio, display_size))
if body.name == 'Earth':
earth_size = display_size
# Print with Earth comparison
for name, btype, real_radius, ratio, display_size in sizes:
vs_earth = f"{display_size / earth_size:.2f}x" if earth_size else "N/A"
print(f"{name:<20} {btype:<15} {real_radius:>8.0f} km {ratio:.6f} {display_size:>10.4f} {vs_earth:>7}")
print("\n" + "=" * 85)
print("✅ VERIFICATION COMPLETE")
print("=" * 85)
print("All bodies now use:")
print(f" • Unified ratio: {configs['planet']['ratio']}")
print(f" • Display Size = real_radius × {configs['planet']['ratio']}")
print("\nSize relationships:")
print(f" • Jupiter = {sizes[0][4] / earth_size:.2f}x Earth (should be ~11x)")
print(f" • Saturn = {sizes[1][4] / earth_size:.2f}x Earth (should be ~9x)")
print(f" • Pluto = {[s for s in sizes if s[0] == 'Pluto'][0][4] / earth_size:.2f}x Earth (should be ~0.19x)")
print(f" • Ceres = {[s for s in sizes if s[0] == 'Ceres'][0][4] / earth_size:.2f}x Earth (should be ~0.07x)")
print("\n🎉 All sizes are now consistent and physically accurate!")
if __name__ == "__main__":
asyncio.run(verify_final_sizes())