-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle TLE archives with multiple entries #73
base: main
Are you sure you want to change the base?
Conversation
DeepCode failed to analyze this pull requestSomething went wrong despite trying multiple times, sorry about that. |
@epsg Thanks a lot for putting this all together! I haven't looked at the code yet, but it sounds great!
I will try to have a look at the code shortly! |
…d from the init function...also, your bot merging changes into my branch is *awful* and I hate it deeply
…ng to a branch I own without asking
@mraspaud any chance you can take a look at this when you have a moment? Last year I moved and switched jobs twice after I started this PR, but things have settled down a bit now and I would like to get it merged. To pick up the conversation and items from last round:
let me know what you think... |
Ok, a lot of good things here, thanks a lot for taking this up again! So I had a good look at the code, and the principles are sound.
@classmethod
def create_tle_list(cls, platform, tle_file):
uris, open_func = _get_uris_and_open_func(tle_file=tle_file)
tles = []
for tle in _get_tles_from_uris(uris, open_func, platform=platform, only_first=False):
line1, line2 = tle.split("\n")
tles.append(cls(platform, line1=line1, line2=line2))
return tles
But again, great ideas! let's keep the ball rolling this time :) |
def utctime(self, utc_time): | ||
if not isinstance(utc_time, datetime): | ||
times = np.array(utc_time, dtype='datetime64[m]') | ||
if times.max() - times.min() > np.timedelta64(3, 'D'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, could we check instead that both min and max times are within 3 days of the epoch instead? or do you think it would be too restrictive?
This PR adds TLE archive parsing to grab the correct TLE based on the specified UTC time. This is in response to #70 , where calling
get_lonlatalt
can give very spurious results when the orbital parameters are propagated over long time intervals (i.e., months, years, or decades). The solution is to use TLE archives... but the current version of pyorbital only grabs the first TLE and doesn't check for closest in time to the query. I've added a single new parameter,self.utctime
, that is updated whenever a function requests a utctime input from the user (e.g.,get_lonlatalt()
). I also changed how the orbital parameters are stored in the object-- gettingself.sgdp4
forces a call onself.orbit_elements
, which returns the evaluation ofOrbitElements(self.tle)
, and similarly forces evaluation ofself.tle
, which on read parses for the correct TLE based on the parameterutctime
. In other words, the orbital parameters are dynamically calculated and returned based off of the last update toutctime
, instead of created as static values that are stored in the object.A couple of caveats:
tlefile.Read()
whentle_file=None
is to fetch from celestrak. That's fine and still works, but if no TLE archive is specified, and a location for a year ago is requested, an exception occurs just as it would if a TLE archive was supplied but theutctime
parameter supplied by the user wasn't in archive or close to it. (Same for if the TLE Line1 and Line2 values are provided at time of object creation as strings). If the current TLE from celestrek or user string is close (within a week) to the utctime query, everything works as expected.Orbital
object needs to be wrapped in a loop so that the object can update the dates and TLE selection.Orbital
is unchanged. The new attributeutctime
could be added as another positional argument if desired...right now it is either set as None and inferred at runtime when a time is provided, inferred from the TLE that is used at object creation, or set todatetime.now()
if the most recent TLE from celestrek is used.flake8 pyorbital