skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

Can't instantiate EarthSatellite (blocked by WiFi) #153

Closed davidmikolas closed 6 years ago

davidmikolas commented 6 years ago

I'm not sure if this is an issue or the way it is supposed to be.

I already have TLEs and would like to calculate an orbit. I am using expire=False in Loader, but the call to EarthSatellite still results in a timeout. Shouldn't I be able to do this offline somehow? If I've missed something obvious please excuse.

L1 = "1 43166U 18010D   18025.80477516  .00000329 -10372-5  00000+0 0  9996"
L2 = "2 43166  82.9254 134.8007 0172197 205.7092 153.5626 15.52820119   739"

import numpy as np
from skyfield.api import Loader, EarthSatellite

load = Loader('~/Documents/SkyData', expire=False)
data = load('de421.bsp')
ts   = load.timescale()

planets = load('de421.bsp')
earth   = planets['earth']

minutes = np.arange(0, 100, 0.5)
time    = ts.utc(2018, 1, 26, 12, minutes)

sat = EarthSatellite(L1, L2)

throws the following after a few minutes (WiFi on) or instantly (WiFi off):

Traceback (most recent call last):
  File "/Users/david/Documents/fishing/Humanity Star/Humanity Star v00.py", line 17, in <module>
    sat = EarthSatellite(L1, L2)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/skyfield/sgp4lib.py", line 46, in __init__
    EarthSatellite.timescale = api.load.timescale()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/skyfield/iokit.py", line 231, in timescale
    data = self('deltat.data')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/skyfield/iokit.py", line 170, in __call__
    download(url, path, self.verbose)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/skyfield/iokit.py", line 364, in download

If Wifi ON:

    raise IOError('cannot get {0} because {1}'.format(url, e))
IOError: cannot get http://maia.usno.navy.mil/ser7/deltat.data because <urlopen error [Errno 60] Operation timed out>

If WiFi OFF:

    raise IOError('cannot get {0} because {1}'.format(url, e))
IOError: cannot get http://maia.usno.navy.mil/ser7/deltat.data because <urlopen error [Errno 8] nodename nor servname provided, or not known>
brandon-rhodes commented 6 years ago

My intention was that it not try to fetch more files if the ones it needed were present. I've assigned myself to this issue so that I can investigate this weekend!

davidmikolas commented 6 years ago

Do you think this is in any way related to deltat.preds file downloads on every call to load.timescale() because file has expired and not been updated #170? In the mean time, might there be a work-around?

Obviously this is a less-urgent situation, more of a slight inconvenience most of the time, but it would be nice to do quickie propagations without having to find the internet.

dam90 commented 6 years ago

Any update on this?

brandon-rhodes commented 6 years ago

No, no update — I've been busy trying to get the star library into shape to produce actual star charts and haven't had time yet to dive back into the I/O library.