#python #satellite
#python #Спутники
Вопрос:
Приведенный ниже код генерирует график, показывающий спутниковую наземную трассу (черные точки), наложенную на карту Земли. Красная точка — это начало наземной дорожки, соответствующее времени эпохи. К моему удивлению, изменение эпохи не меняет местоположение красной точки на карте. Что-то должно быть не так, потому что плоскость орбиты фиксирована относительно звезд, а Земля — нет. Любые советы будут оценены.
# Section 1: Preliminaries.
# Section 1.1: Import from Python standard library.
import os, pickle, sys
from datetime import datetime
from numpy import arange, pi
# Section 1.2: Import from packages in the Anaconda distribution.
import matplotlib.pyplot as plt
from pytz import timezone, utc
import cartopy.crs as ccrs
from astropy import coordinates, time, units as u
from poliastro.bodies import Earth, Moon, Sun
from poliastro.twobody import Orbit, propagation
# Section 1.3: Global variables and constants.
RAD2DEG= 180 / pi
tz= utc
# Section 2:
epoch= [2020, 12, 7, 20, 38]
# Naive datetime is datetime with no timezone information. Here we 'localize' the naive
# datetime, i.e., convert it to a timezone-specific time:
datetime_local= tz.localize(datetime(*epoch))
# Convert localized datetime to UTC:
datetime_UTC= datetime_local.astimezone(utc)
# Convert to Astropy time on UTC scale:
t= time.Time(datetime_UTC, scale='utc')
# Section 3: Simulate orbit.
a = 26600 * u.km # semi-major axis
ecc= 0.74 * u.one # eccentricity
inc= 63.4 * u.deg # inclination of the orbit plane
raan= 49.562 * u.deg # right ascension of the ascending node
argp= 270 * u.deg # argument of perigee
nu = 0 * u.deg # true anomaly at epoch
T_sim_hrs= 24
T_step_min= 3
orbit= Orbit.from_classical(Earth, a, ecc, inc, raan, argp, nu, epoch=t)
print(f"Orbit period: {orbit.period.to(u.min):.3f}")
# Create time steps covering the duration of the simulation:
times= arange(0, 60*T_sim_hrs 1, T_step_min) * u.min
xyz= propagation.propagate(
orbit,
time.TimeDelta(times),
method=propagation.cowell,
rtol=1e-10,
)
# Convert positions from Cartesian to spherical coordinates:
d_lat_lon= coordinates.cartesian_to_spherical(xyz.z, xyz.y, xyz.z)
# Section 4: Generate plot.
fig= plt.figure(figsize=(12, 7))
ax= fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.stock_img()
# longitude # latitude
plt.scatter(x=RAD2DEG*d_lat_lon[2], y=RAD2DEG*d_lat_lon[1],
color="black", s=12, alpha=0.5, transform=ccrs.PlateCarree())
# Mark the first point, corresponding to epoch, with a special symbol:
plt.scatter(x=RAD2DEG*d_lat_lon[2][:1], y=RAD2DEG*d_lat_lon[1][:1],
color="red", s=160, marker='o', alpha=1.0, transform=ccrs.PlateCarree())
plt.tight_layout()
plt.show()
Комментарии:
1.
d_lat_lon= coordinates.cartesian_to_spherical(xyz.z, xyz.y, xyz.z)
? Вы имели в виду...(xyz.x,...
?2. Спасибо, что поймали мою опечатку! График теперь выглядит более разумным, но проблема с эпохой остается.