Skip to content
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

Loader(dir).tle(file) does not honor directory #193

Closed
jkrage opened this issue Jul 31, 2018 · 2 comments
Closed

Loader(dir).tle(file) does not honor directory #193

jkrage opened this issue Jul 31, 2018 · 2 comments
Assignees

Comments

@jkrage
Copy link

jkrage commented Jul 31, 2018

As described in the documentation (http://rhodesmill.org/skyfield/files.html) and API (http://rhodesmill.org/skyfield/api-iokit.html), a customer Loader using a data directory, e.g., Loader(cache) should keep data files in that directory. The open() method, also called by tle(), does not honor the custom Loader directory. Related to discussion in closed issue #89.

My intended use case is to be able to make use of multiple (already local) TLE files from past times for point-in-time retrospectives. One path of exploration would use multiple Loader() objects.

Workaround is to prepend the data directory manually prior to open() or tle() calls. Easy enough in the short term.

With d5b70da open() was updated to permit specifying local filenames (yay!). Prior to the commit, using a relative path (e.g., './tle.txt') within the custom Loader() sufficed as a kludge.

Sample poc.py:

import skyfield.api

load = skyfield.api.Loader('cache')

earth_satellites = load.tle('cache/3le.txt')
print(f'Loaded {len(earth_satellites)} object identifiers')

print('\n-----\n')

earth_satellites = load.tle('./3le.txt')
print(f'Loaded {len(earth_satellites)} object identifiers')

Traceback:

$ python poc.py
Loaded 2 object identifiers

-----

Traceback (most recent call last):
  File "poc.py", line 12, in <module>
    earth_satellites = load.tle('./3le.txt')
  File "~/.local/virtualenvs/DPXkZ7s8/lib/python3.7/site-packages/skyfield/iokit.py", line 213, in tle
    with self.open(url, reload=reload, filename=filename) as f:
  File "~/.local/virtualenvs/DPXkZ7s8/lib/python3.7/site-packages/skyfield/iokit.py", line 240, in open
    return open(url, mode)
FileNotFoundError: [Errno 2] No such file or directory: './3le.txt'

File structure:

$ ls poc.py cache
poc.py

cache:
3le.txt

My sample 3le.txt only has two entries, and existed prior to invocation.

@jkrage
Copy link
Author

jkrage commented Jul 31, 2018

I forgot to point out this is a similar issue as initially reported in #174, though the discussion on that has moved into a different direction.

@brandon-rhodes
Copy link
Member

Thanks for pointing out that problem! I have added tests, so hopefully this won't break from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants