pytroll / pyorbital

Orbital and astronomy computations in python
http://pyorbital.readthedocs.org/
GNU General Public License v3.0
224 stars 77 forks source link

Azimuth/elevation output not changing with 1-second increments #85

Closed adamk closed 2 years ago

adamk commented 2 years ago
from pyorbital.orbital import Orbital
from math import sin,cos,sqrt
import datetime
from skyfield.api import load, wgs84
import os
import re
import pytz

stations_url = 'https://celestrak.com/NORAD/elements/starlink.txt'
satellites = load.tle_file(stations_url, filename='starlink.txt')

print('Loaded', len(satellites), 'Starlink satellites')
by_name = {sat.name: sat for sat in satellites}
starlink_sats = list(by_name.keys())

# User input for specific day of predictions
start_date = input("Enter single day as %Y-%m-%d \n")
local = pytz.timezone("America/New_York")
naive = datetime.datetime.strptime(start_date + " 00:00:00", "%Y-%m-%d %H:%M:%S")
local_dt = local.localize(naive, is_dst=None)
utc_dt = local_dt.astimezone(pytz.utc)
date = datetime.datetime(int(start_date[0:4]), int(start_date[5:7]),int(start_date[8:10]), 0, 0, 0)
print
ALTITUDE_ASL = 0.629
LON = some_lon (for privacy)
LAT = some_lat (for privacy)

def do_calc(d, sat_name):
    orb = Orbital(sat_name, 'starlink.txt')
    passes = orb.get_next_passes(d, 24, LON, LAT, ALTITUDE_ASL, horizon=30)
    rise_az, rise_el = orb.get_observer_look(passes[0][0], LON, LAT, ALTITUDE_ASL)
    transit_az, transit_el = orb.get_observer_look(passes[0][2], LON, LAT, ALTITUDE_ASL)
    set_az, set_el = orb.get_observer_look(passes[0][1], LON, LAT, ALTITUDE_ASL)

    print(sat_name)
    print(passes[0][0], rise_az, rise_el)
    #print(passes[0][1], set_az, set_el)
    rise_time = passes[0][0].strftime("%H:%M:%S")
    fall_time = passes[0][1].strftime("%H:%M:%S")
    print(rise_time)
    print(fall_time)
    start_time = passes[0][0]
    stop_time = passes[0][1]
    current_time = start_time
    while current_time <= stop_time:
        az, el = orb.get_observer_look(current_time.date(), LON, LAT, ALTITUDE_ASL)
        print(current_time.strftime("%H:%M:%S"))
        print(az)
        print(el)
        current_time += datetime.timedelta(seconds=1)

do_calc(date, 'STARLINK-24')

Problem description

I'm trying to generate azimuth/elevation every 1 second of a satellite's pass (>30 deg above horizon). Why is Pyorbital not computing any change? It surely shows the precision capable to perform this calculation. The Pyorbital function of interest is get_observer_look(). My end goal is to use this az/el data to compute apparent angular speed which I already have python code written for. I was orignally using PREDICT by KD2BD but the output was inconsistent in timestamps and the az/el was jumping weirdly so I've resorted to Pyorbital for the job.

Expected Output

Expecting the elevation and azimuth values to change over time.

Actual Result (Snippet)

01:16:41 114.56791262934946 -34.88507329077975 01:16:42 114.56791262934946 -34.88507329077975 01:16:43 114.56791262934946 -34.88507329077975 01:16:44 114.56791262934946 -34.88507329077975 01:16:45 114.56791262934946 -34.88507329077975 01:16:46 114.56791262934946 -34.88507329077975 01:16:47 114.56791262934946 -34.88507329077975 starlink.txt

adamk commented 2 years ago

Problem solved. Mistake was using current_time.date() which removes the necessary timestamp part.