skyfielders / python-skyfield

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

Skyfield should offer a way to discover DE431’s filename #95

Closed davidmikolas closed 4 years ago

davidmikolas commented 8 years ago

I wanted to resolve a sub-kilometer difference between Skyfield and JPL Horizons, so I thought I would load DE431, since my Horizons output lists this as the ephemeris used.

Here's what I got on the terminal. DE421 loaded in a few seconds, DE431 gives a url open error.

>>> data = load('de421.bsp')
[#################################] 100% de421.bsp
>>> data = load('de431.bsp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/uhoh/anaconda/envs/npy/lib/python2.7/site-packages/skyfield/iokit.py", line 71, in __call__
    return load(filename, self.directory, verbose=self.verbose)
  File "/Users/uhoh/anaconda/envs/npy/lib/python2.7/site-packages/skyfield/iokit.py", line 176, in load
    download(url, path, verbose=verbose)
  File "/Users/uhoh/anaconda/envs/npy/lib/python2.7/site-packages/skyfield/iokit.py", line 207, in download
    raise IOError('cannot get {0} because {1}'.format(url, e))
IOError: cannot get ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/de431.bsp because <urlopen error ftp error: [Errno ftp error] 550 Failed to change directory.>
brandon-rhodes commented 8 years ago

NASA has chosen the filename de431t.bsp for that ephemeris:

ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/

I will edit this issue to add the idea that Skyfield should maybe offer a way to list ephemerides, or even to let the user search them given a substring to search for.

davidmikolas commented 8 years ago

Great! A simple method that returned a list or dict would be excellent (and pythonic), with size, begin and end dates available. Maybe a text/comment field with the gory details, but that's icing.

Something along the lines of:

infodict = load('info')
brandon-rhodes commented 8 years ago

Running a simple list-directory on each external source of ephemerides would be enough to collect the filenames. For the beginning and ending dates, would we pull the first few blocks of each .bsp file to read its header information?

brandon-rhodes commented 4 years ago

Per my answer on #134, I am not, alas, inclined at the moment to start tangling Skyfield up with further in-code knowledge of how files are purveyed out on the Internet. Just in the past few weeks, the USNO took down a major server, and every year or two an ephemeris seems to change names or locations. It might be that there should exist a stand-alone tool for exploring the space of binary astronomy resources online from Python — does AstroPy have such a thing, I wonder? — but there are already enough Skyfield releases necessary because file names or formats changed. I am not inclined at this point to add another.

So while I do want Skyfield to have useful and accurate documentation leading people to find and download useful .bsp files and other sorts of files, let’s not expand that into code at this point.

Thanks for the idea, though, and I hope you continue to find Skyfield useful!