skyfielders / python-skyfield

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

load.tle does not load a local path #137

Closed darkstar007 closed 6 years ago

darkstar007 commented 7 years ago

If the following code is run:

from skyfield.api import Topos, load

stations_url = '/home/matt/ephem_data_raw/ephem_20170510/cubesat.txt'

satellites = load.tle(stations_url, reload=True)

it fails with:

  File "/usr/local/lib/python2.7/dist-packages/skyfield/iokit.py", line 196, in tle
    with self.open(url, reload=reload) as f:
  File "/usr/local/lib/python2.7/dist-packages/skyfield/iokit.py", line 211, in open
    download(url, path, self.verbose)
  File "/usr/local/lib/python2.7/dist-packages/skyfield/iokit.py", line 364, in download
    raise IOError('cannot get {0} because {1}'.format(url, e))
IOError: cannot get /home/matt/ephem_data_raw/ephem_20170510/cubesat.txt because unknown url type: /home/matt/ephem_data_raw/ephem_20170510/cubesat.txt

However, the documentation says:

Given a URL or a local path,

So it only excepts a URL (i.e. http: or file:) and not a local path?

Thanks,

Matt

Engineero commented 6 years ago

Was this resolved? I was able to load from file in the local directory with:

tles = load.tle('./tle_file.txt')
brandon-rhodes commented 6 years ago

I'm going to add a special case to load.tle() that recognizes local file paths, instead of assuming that everything is a URL.