MCPcopy Create free account
hub / github.com/Tong89/smartNode / OrbitalElements

Class OrbitalElements

backend/orbit.py:54–255  ·  view source on GitHub ↗

轨道六根数定义 - 用于精确计算卫星位置。 支持可选的 TLE 两行根数驱动 SGP4 传播。当 ``tle_line1`` / ``tle_line2`` 字段 非空时,``propagate()`` 使用 :func:`~backend.physics.propagator.propagate_tle`; 否则回退现有开普勒二体解析解,行为与重构前完全一致。 参数 ---- tle_line1 : str, optional TLE 第一行(74 字符 NORAD 格式)。 tle_line2 : str, opt

Source from the content-addressed store, hash-verified

52
53
54class OrbitalElements:
55 """轨道六根数定义 - 用于精确计算卫星位置。
56
57 支持可选的 TLE 两行根数驱动 SGP4 传播。当 ``tle_line1`` / ``tle_line2`` 字段
58 非空时,``propagate()`` 使用 :func:`~backend.physics.propagator.propagate_tle`;
59 否则回退现有开普勒二体解析解,行为与重构前完全一致。
60
61 参数
62 ----
63 tle_line1 : str, optional
64 TLE 第一行(74 字符 NORAD 格式)。
65 tle_line2 : str, optional
66 TLE 第二行(74 字符 NORAD 格式)。
67 """
68
69 def __init__(self, name, sat_id,
70 semi_major_axis, eccentricity, inclination,
71 raan, arg_perigee, mean_anomaly, epoch=None,
72 tle_line1=None, tle_line2=None,
73 j2_perturbation=True):
74 self.name = name
75 self.sat_id = sat_id
76 self.a = semi_major_axis
77 self.e = eccentricity
78 self.i = inclination
79 self.raan = raan
80 self.omega = arg_perigee
81 self.M0 = mean_anomaly
82 self.epoch = epoch or datetime.now()
83 self.mu = 398600.4418 # 地球引力常数 (km³/s²)
84 self.R_earth = 6371.0 # 地球半径 (km)
85 # 可选 TLE 字段(非空时启用 SGP4 传播)
86 self.tle_line1 = tle_line1
87 self.tle_line2 = tle_line2
88 # J2 摄动开关(默认开启;设为 False 可禁用以复现纯二体结果)
89 self.j2_perturbation = j2_perturbation
90 # 延迟初始化 Propagator(避免循环导入问题)
91 self._propagator = None
92
93 def _get_propagator(self):
94 """惰性构建并缓存 Propagator 实例。"""
95 if self._propagator is None:
96 from backend.physics.propagator import Propagator # pylint: disable=import-outside-toplevel
97 self._propagator = Propagator.from_orbital_elements(self)
98 return self._propagator
99
100 def get_mean_motion(self):
101 return math.sqrt(self.mu / (self.a ** 3))
102
103 def get_orbital_period(self):
104 return 2 * math.pi * math.sqrt((self.a ** 3) / self.mu)
105
106 def get_altitude(self):
107 return (self.a - self.R_earth) * 1000
108
109 def propagate(self, current_time):
110 """根据当前时间计算卫星位置,返回 (lat°, lon°, alt m)。
111

Callers 14

_generate_random_leoMethod · 0.90
load_scenarioFunction · 0.90
constellation.pyFile · 0.90
iss_likeFunction · 0.90
polar_orbitFunction · 0.90
leo_elementFunction · 0.90
sso_orbitFunction · 0.90
iss_like_j2Function · 0.90
iss_like_no_j2Function · 0.90

Calls

no outgoing calls

Tested by 11

iss_likeFunction · 0.72
polar_orbitFunction · 0.72
leo_elementFunction · 0.72
sso_orbitFunction · 0.72
iss_like_j2Function · 0.72
iss_like_no_j2Function · 0.72