""" 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") name_zh: str | None = Field(None, description="Chinese name") type: Literal["planet", "probe", "star", "dwarf_planet", "satellite", "comet"] = Field(..., description="Body type") positions: list[Position] = Field( default_factory=list, description="Position history" ) description: str | None = Field(None, description="Description") is_active: bool | None = Field(None, description="Active status (for probes: True=active, False=inactive)") 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", "dwarf_planet", "satellite", "comet"] description: str launch_date: str | None = None status: str | None = None # Predefined celestial bodies CELESTIAL_BODIES = { # Probes "-31": { "name": "Voyager 1", "name_zh": "旅行者1号", "type": "probe", "description": "离地球最远的人造物体,已进入星际空间", "launch_date": "1977-09-05", "status": "active", }, "-32": { "name": "Voyager 2", "name_zh": "旅行者2号", "type": "probe", "description": "唯一造访过天王星和海王星的探测器", "launch_date": "1977-08-20", "status": "active", }, "-98": { "name": "New Horizons", "name_zh": "新视野号", "type": "probe", "description": "飞掠冥王星,正处于柯伊伯带", "launch_date": "2006-01-19", "status": "active", }, "-96": { "name": "Parker Solar Probe", "name_zh": "帕克太阳探测器", "type": "probe", "description": "正在'触摸'太阳,速度最快的人造物体", "launch_date": "2018-08-12", "status": "active", }, "-61": { "name": "Juno", "name_zh": "朱诺号", "type": "probe", "description": "正在木星轨道运行", "launch_date": "2011-08-05", "status": "active", }, "-82": { "name": "Cassini", "name_zh": "卡西尼号", "type": "probe", "description": "土星探测器(已于2017年撞击销毁)", "launch_date": "1997-10-15", "status": "inactive", }, "-168": { "name": "Perseverance", "name_zh": "毅力号", "type": "probe", "description": "火星探测车", "launch_date": "2020-07-30", "status": "active", }, # Planets "10": { "name": "Sun", "name_zh": "太阳", "type": "star", "description": "太阳,太阳系的中心", }, "199": { "name": "Mercury", "name_zh": "水星", "type": "planet", "description": "水星,距离太阳最近的行星", }, "299": { "name": "Venus", "name_zh": "金星", "type": "planet", "description": "金星,太阳系中最热的行星", }, "399": { "name": "Earth", "name_zh": "地球", "type": "planet", "description": "地球,我们的家园", }, "301": { "name": "Moon", "name_zh": "月球", "type": "planet", "description": "月球,地球的天然卫星", }, "499": { "name": "Mars", "name_zh": "火星", "type": "planet", "description": "火星,红色星球", }, "599": { "name": "Jupiter", "name_zh": "木星", "type": "planet", "description": "木星,太阳系中最大的行星", }, "699": { "name": "Saturn", "name_zh": "土星", "type": "planet", "description": "土星,拥有美丽的光环", }, "799": { "name": "Uranus", "name_zh": "天王星", "type": "planet", "description": "天王星,侧躺着自转的行星", }, "899": { "name": "Neptune", "name_zh": "海王星", "type": "planet", "description": "海王星,太阳系最外层的行星", }, "999": { "name": "Pluto", "name_zh": "冥王星", "type": "dwarf_planet", "description": "冥王星,曾经的第九大行星,现为矮行星", }, # Dwarf Planets "2000001": { "name": "Ceres", "name_zh": "谷神星", "type": "dwarf_planet", "description": "谷神星,小行星带中最大的天体,也是唯一的矮行星", }, "136199": { "name": "Eris", "name_zh": "阋神星", "type": "dwarf_planet", "description": "阋神星,曾被认为是第十大行星,导致冥王星被降级为矮行星", }, "136108": { "name": "Haumea", "name_zh": "妊神星", "type": "dwarf_planet", "description": "妊神星,形状像橄榄球的矮行星,拥有两颗卫星和光环", }, "136472": { "name": "Makemake", "name_zh": "鸟神星", "type": "dwarf_planet", "description": "鸟神星,柯伊伯带中第二亮的天体", }, }