skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Error with new find_events function #337

Closed smp55 closed 4 years ago

smp55 commented 4 years ago

I built an EarthSatellite object with a TLE. I then tried to call find_events() to a topo location, but received the error that the object had no model.no_kozai attribute. Looking at the source, it looks like model.no_kozai is never defined in the EarthSatellite class, even though it is called from the find_events method? Did I miss something?

brandon-rhodes commented 4 years ago

What versions of Skyfield and SGP4 are installed? pip freeze might show you the list of installed versions.

smp55 commented 4 years ago

Skyfield = 1.17 SGP4 = 2.3

brandon-rhodes commented 4 years ago

The model object of an EarthSatellite is another object called an sgp4 Satrec object, and it should have a no_kozai whether it’s the C++ version of the class:

https://github.com/brandon-rhodes/python-sgp4/blob/ae6787f13157bf16cfdac9b67372e18ae25df7b2/extension/wrapper.cpp#L192

Or whether it's the Python fallback:

https://github.com/brandon-rhodes/python-sgp4/blob/ae6787f13157bf16cfdac9b67372e18ae25df7b2/sgp4/io.py#L192

Could you check out your SGP4 install to see if those definitions are in place in the source? I'm trying to think of how they could go missing and am not thinking of anything yet.

smp55 commented 4 years ago

I'm very new to Git and how packages work, so forgive me if I miss something. I found the Satrec class, and it tries to inherit from vallado_cpp.Satrec (where no_kozai would be), but I could not find 'vallado' in any filename anywhere (not just the sgp4 or skyfield folders; I searched the whole environment). I should mention that I am using Anaconda, although I had to install Skyfield with pip.

brandon-rhodes commented 4 years ago

A filename with vallado will only appear if SGP4 was able to successfully compile the C++ accelerated version of the algorithm. I have just installed the conda-forge version of sgp4 and, like you, I see no such file — so the conda-forge folks must not be succeeding in building the C++ right now. I'll go look a their build logs to see if I can figure out why.

On the other hand, though, I am not having problems using that attribute. Could you try running this script, and sharing the whole output that results? Thanks!

import sgp4
print(sgp4.__file__)

from sgp4.api import Satrec
s = '1 25544U 98067A   19343.69339541  .00001764  00000-0  38792-4 0  9991'
t = '2 25544  51.6439 211.2001 0007417  17.6667  85.6398 15.50103472202482'
sat = Satrec.twoline2rv(s, t)
jd, fr = 2458827, 0.362605
e, r, v = sat.sgp4(jd, fr)
print(sat.no_kozai)
smp55 commented 4 years ago

Man, I don't know what happened, but it works now :-/. Sorry! Your script worked, and it printed the value, so I went back and tried what I was doing before, and it works. I have no idea why, but thank you! Glad I could call your attention to the conda-forge problem, at least!