""" Data models for celestial bodies and positions """ from datetime import datetime from typing import Literal from pydantic import BaseModel, Field class Position(BaseModel): """3D position in space (AU)""" time: datetime = Field(..., description="Timestamp for this position") x: float = Field(..., description="X coordinate in AU (heliocentric)") y: float = Field(..., description="Y coordinate in AU (heliocentric)") z: float = Field(..., description="Z coordinate in AU (heliocentric)") class CelestialBody(BaseModel): """Celestial body (planet or probe)""" id: str = Field(..., description="JPL Horizons ID") name: str = Field(..., description="Display name") type: Literal["planet", "probe", "star"] = Field(..., description="Body type") positions: list[Position] = Field( default_factory=list, description="Position history" ) description: str | None = Field(None, description="Description") class CelestialDataResponse(BaseModel): """API response for celestial positions""" timestamp: datetime = Field( default_factory=datetime.utcnow, description="Data fetch timestamp" ) bodies: list[CelestialBody] = Field(..., description="List of celestial bodies") class BodyInfo(BaseModel): """Detailed information about a celestial body""" id: str name: str type: Literal["planet", "probe", "star"] description: str launch_date: str | None = None status: str | None = None # Predefined celestial bodies CELESTIAL_BODIES = { # Probes "-31": { "name": "Voyager 1", "type": "probe", "description": "离地球最远的人造物体,已进入星际空间", "launch_date": "1977-09-05", "status": "active", }, "-32": { "name": "Voyager 2", "type": "probe", "description": "唯一造访过天王星和海王星的探测器", "launch_date": "1977-08-20", "status": "active", }, "-98": { "name": "New Horizons", "type": "probe", "description": "飞掠冥王星,正处于柯伊伯带", "launch_date": "2006-01-19", "status": "active", }, "-96": { "name": "Parker Solar Probe", "type": "probe", "description": "正在'触摸'太阳,速度最快的人造物体", "launch_date": "2018-08-12", "status": "active", }, "-61": { "name": "Juno", "type": "probe", "description": "正在木星轨道运行", "launch_date": "2011-08-05", "status": "active", }, "-82": { "name": "Cassini", "type": "probe", "description": "土星探测器(已于2017年撞击销毁)", "launch_date": "1997-10-15", "status": "inactive", }, "-168": { "name": "Perseverance", "type": "probe", "description": "火星探测车", "launch_date": "2020-07-30", "status": "active", }, # Planets "10": { "name": "Sun", "type": "star", "description": "太阳,太阳系的中心", }, "199": { "name": "Mercury", "type": "planet", "description": "水星,距离太阳最近的行星", }, "299": { "name": "Venus", "type": "planet", "description": "金星,太阳系中最热的行星", }, "399": { "name": "Earth", "type": "planet", "description": "地球,我们的家园", }, "301": { "name": "Moon", "type": "planet", "description": "月球,地球的天然卫星", }, "499": { "name": "Mars", "type": "planet", "description": "火星,红色星球", }, "599": { "name": "Jupiter", "type": "planet", "description": "木星,太阳系中最大的行星", }, "699": { "name": "Saturn", "type": "planet", "description": "土星,拥有美丽的光环", }, "799": { "name": "Uranus", "type": "planet", "description": "天王星,侧躺着自转的行星", }, "899": { "name": "Neptune", "type": "planet", "description": "海王星,太阳系最外层的行星", }, }