I'm trying to obtain ECEF coordinates from geocentric coordinates and then plot the ground track using the subpoint function. Any advice? My objective is to create an accurate ground track.
Additional question. To get a better ground track should I convert geocentric to topocentric or to ECEF? If so how to do it with skyfield?
Edit: How to add the line: '''
bremen = Topos('53.073635 N ','8.806422 E', elevation_m=12)
subsat = geocentric.subpoint(bremen)
'''
I get the error: '''
subsat = geocentric.subpoint(bremen)
TypeError: Geocentric.subpoint() takes 1 positional argument but 2 were given
''' '''
import numpy as np
import matplotlib.pyplot as plt
from skyfield.api import Loader, Topos, EarthSatellite, wgs84
import cartopy.crs as ccrs
# https://www.celestrak.com/NORAD/elements/stations.txt
'''
url = http://celestrak.org/NORAD/elements/gp.php?GROUP=cubesat&FORMAT=tle
satellites = load.tle_file(url)
by_name = {sat.name: sat for sat in satellites}
satellite = by_name['BEESAT 9']
'''
load = Loader('~/Documents/fishing/SkyData')
ts = load.timescale(builtin=True)
TLE = """BEESAT 9
1 44412U 19038AC 23275.86235167 .00050353 00000+0 14104-2 0 9990
2 44412 97.6836 260.5532 0009869 285.4354 74.5799 15.36410657234651"""
L1, L2, L3 = TLE.splitlines() #We split the lines
satellite = EarthSatellite(L2,L3, L1 ) #We creat an sateliite object
#geocentric = geocentric.position.m
mean_mo= satellite.model.no_kozai # / 60
period = (2*np.pi) / mean_mo # in min
t_now = ts.now() #We use the current time to know the actual position of the satellite
#Epoch from TLE
year, month, day, hour, minute, sec = satellite.epoch.ut1_calendar()
#geocentric = satellite.at(t_now)
period1 = np.arange(0,period,0.5)
times = ts.utc(year, month, day, hour, period1)
#minutes = np.arange(0, 200, 0.1) # about two orbits
#times = ts.utc(2019, 7, 23, 0, minutes)
geocentric = satellite.at(times) # We convert TEME Coordinates into geocentric Coordinates
#lat, lon = wgs84.latlon_of(geocentric)
#geocentric1 = geocentric.position.m
'''Convert to ECEF'''
print()
subsat = geocentric.subpoint()
fig = plt.figure(figsize=(15.2, 8.2))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
background_image_path = r'D:\Satellite_Code\earth.jpg'
background_img = plt.imread(background_image_path)
# Create a figure and axis for the map with the background image
plt.scatter(subsat.longitude.degrees, subsat.latitude.degrees, label = satellite.name +" Ground Track", color='yellow', marker='o', s=2 ,transform=ccrs.PlateCarree())
ax.imshow(background_img, extent=[-180, 180, -90, 90])
ax.set_xlabel("Longitude (degrees)")
ax.set_ylabel("Latitude (degrees)")
ax.set_title(satellite.name + " Ground Track ")
ax.legend()
ax.grid(True, color='w', linestyle=":", alpha=0.4)
plt.show()
'''
basemap
map are in this answer $\endgroup$