由 TLE 两行根数构造 OrbitalElements,轨道根数从 TLE 解析填充。 SGP4 传播时直接使用 TLE 数据;轨道根数字段仅用于回退和元数据。 参数 ---- name : str 卫星名称。 sat_id : str 系统内部卫星 ID。 tle_line1 : str TLE 第一行。 tle_line2 : str TLE 第二行。 epoch
(cls, name: str, sat_id: str,
tle_line1: str, tle_line2: str,
epoch=None,
j2_perturbation=True)
| 192 | |
| 193 | @classmethod |
| 194 | def from_tle(cls, name: str, sat_id: str, |
| 195 | tle_line1: str, tle_line2: str, |
| 196 | epoch=None, |
| 197 | j2_perturbation=True) -> "OrbitalElements": |
| 198 | """由 TLE 两行根数构造 OrbitalElements,轨道根数从 TLE 解析填充。 |
| 199 | |
| 200 | SGP4 传播时直接使用 TLE 数据;轨道根数字段仅用于回退和元数据。 |
| 201 | |
| 202 | 参数 |
| 203 | ---- |
| 204 | name : str |
| 205 | 卫星名称。 |
| 206 | sat_id : str |
| 207 | 系统内部卫星 ID。 |
| 208 | tle_line1 : str |
| 209 | TLE 第一行。 |
| 210 | tle_line2 : str |
| 211 | TLE 第二行。 |
| 212 | epoch : datetime, optional |
| 213 | TLE 历元(None 则从 TLE 解析,回退 datetime.now())。 |
| 214 | |
| 215 | 返回 |
| 216 | ---- |
| 217 | OrbitalElements |
| 218 | 带有 TLE 字段的实例,propagate() 将走 SGP4 路径。 |
| 219 | """ |
| 220 | # 从 TLE 第二行解析轨道根数(用于回退/元数据) |
| 221 | try: |
| 222 | fields = tle_line2.split() |
| 223 | inclination = float(fields[2]) |
| 224 | raan = float(fields[3]) |
| 225 | eccentricity = float("0." + fields[4]) |
| 226 | arg_perigee = float(fields[5]) |
| 227 | mean_anomaly = float(fields[6]) |
| 228 | mean_motion_rev_day = float(fields[7][:11]) |
| 229 | # 由平运动推算半长轴 (km) |
| 230 | mu = 398600.4418 |
| 231 | n_rad_s = mean_motion_rev_day * 2.0 * math.pi / 86400.0 |
| 232 | semi_major_axis = (mu / (n_rad_s ** 2)) ** (1.0 / 3.0) |
| 233 | except (IndexError, ValueError): |
| 234 | # TLE 解析失败时使用保守默认值(SGP4 仍可正常运行) |
| 235 | inclination = 0.0 |
| 236 | raan = 0.0 |
| 237 | eccentricity = 0.0 |
| 238 | arg_perigee = 0.0 |
| 239 | mean_anomaly = 0.0 |
| 240 | semi_major_axis = 7000.0 # ~629 km LEO |
| 241 | |
| 242 | return cls( |
| 243 | name=name, |
| 244 | sat_id=sat_id, |
| 245 | semi_major_axis=semi_major_axis, |
| 246 | eccentricity=eccentricity, |
| 247 | inclination=inclination, |
| 248 | raan=raan, |
| 249 | arg_perigee=arg_perigee, |
| 250 | mean_anomaly=mean_anomaly, |
| 251 | epoch=epoch, |