I've implemented sgp4 algorithm using Skyfield in python.
I need the position vector for 1 day time interval with 1 second periodicity. For that, I have to calculate the sgp4 repeatedly, adding 1 second each time.
Is there a way to return a vector, which contains all position?
You can do this by creating a skyfield.EarthSatellite
object form a TLE, and then generating astrometric
objects for each time in a list of times. You need to specify your list of times as timezone-aware datetime objects. You can create your list of times with something like (probably lots of room to make this more efficient):
from datetime import timezone, timedelta, datetime
from skyfield.api import load
ts = load.timescale() # create skyfield timescale object
tz = timezone(timedelta(hours=-4)) # whatever your timezone offset from UTC is
start = datetime(2018, 06, 21, 0, 0, 0, tzinfo=tz) # timezone-aware start time
end = start + timedelta(hours=24) # one day's worth of times
delta = timedelta(minutes=1) # your interval over which you evaluate
times = [start]
now = start
while now <= end:
now += delta
times.append(now)
And evaluate it with:
astrometrics = my_earthsat.at(ts.utc(times))
This will give you a list of astrometrics at each time that you specified. You can use these objects to get positions (and I think velocities) of your object in just about any units or reference frame you like. You can get, for instance, the altitude and azimuth in radians for each element in the list with something like:
alt_az = []
for ast in astrometrics:
alt_az.append(ast.altaz().radians)