2025-11-27 05:16:19 +00:00
|
|
|
|
"""
|
|
|
|
|
|
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")
|
2025-11-27 10:14:25 +00:00
|
|
|
|
name_zh: str | None = Field(None, description="Chinese name")
|
2025-11-27 05:16:19 +00:00
|
|
|
|
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",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "旅行者1号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "离地球最远的人造物体,已进入星际空间",
|
|
|
|
|
|
"launch_date": "1977-09-05",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-32": {
|
|
|
|
|
|
"name": "Voyager 2",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "旅行者2号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "唯一造访过天王星和海王星的探测器",
|
|
|
|
|
|
"launch_date": "1977-08-20",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-98": {
|
|
|
|
|
|
"name": "New Horizons",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "新视野号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "飞掠冥王星,正处于柯伊伯带",
|
|
|
|
|
|
"launch_date": "2006-01-19",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-96": {
|
|
|
|
|
|
"name": "Parker Solar Probe",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "帕克太阳探测器",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "正在'触摸'太阳,速度最快的人造物体",
|
|
|
|
|
|
"launch_date": "2018-08-12",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-61": {
|
|
|
|
|
|
"name": "Juno",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "朱诺号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "正在木星轨道运行",
|
|
|
|
|
|
"launch_date": "2011-08-05",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-82": {
|
|
|
|
|
|
"name": "Cassini",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "卡西尼号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "土星探测器(已于2017年撞击销毁)",
|
|
|
|
|
|
"launch_date": "1997-10-15",
|
|
|
|
|
|
"status": "inactive",
|
|
|
|
|
|
},
|
|
|
|
|
|
"-168": {
|
|
|
|
|
|
"name": "Perseverance",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "毅力号",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "probe",
|
|
|
|
|
|
"description": "火星探测车",
|
|
|
|
|
|
"launch_date": "2020-07-30",
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
},
|
|
|
|
|
|
# Planets
|
|
|
|
|
|
"10": {
|
|
|
|
|
|
"name": "Sun",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "太阳",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "star",
|
|
|
|
|
|
"description": "太阳,太阳系的中心",
|
|
|
|
|
|
},
|
|
|
|
|
|
"199": {
|
|
|
|
|
|
"name": "Mercury",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "水星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "水星,距离太阳最近的行星",
|
|
|
|
|
|
},
|
|
|
|
|
|
"299": {
|
|
|
|
|
|
"name": "Venus",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "金星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "金星,太阳系中最热的行星",
|
|
|
|
|
|
},
|
|
|
|
|
|
"399": {
|
|
|
|
|
|
"name": "Earth",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "地球",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "地球,我们的家园",
|
|
|
|
|
|
},
|
|
|
|
|
|
"301": {
|
|
|
|
|
|
"name": "Moon",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "月球",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "月球,地球的天然卫星",
|
|
|
|
|
|
},
|
|
|
|
|
|
"499": {
|
|
|
|
|
|
"name": "Mars",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "火星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "火星,红色星球",
|
|
|
|
|
|
},
|
|
|
|
|
|
"599": {
|
|
|
|
|
|
"name": "Jupiter",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "木星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "木星,太阳系中最大的行星",
|
|
|
|
|
|
},
|
|
|
|
|
|
"699": {
|
|
|
|
|
|
"name": "Saturn",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "土星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "土星,拥有美丽的光环",
|
|
|
|
|
|
},
|
|
|
|
|
|
"799": {
|
|
|
|
|
|
"name": "Uranus",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "天王星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "天王星,侧躺着自转的行星",
|
|
|
|
|
|
},
|
|
|
|
|
|
"899": {
|
|
|
|
|
|
"name": "Neptune",
|
2025-11-27 10:14:25 +00:00
|
|
|
|
"name_zh": "海王星",
|
2025-11-27 05:16:19 +00:00
|
|
|
|
"type": "planet",
|
|
|
|
|
|
"description": "海王星,太阳系最外层的行星",
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|