Skip to content

Commit

Permalink
Display builtin=True advice for third file, too
Browse files Browse the repository at this point in the history
Should help users in a situation like #317, where it was the leap
second file that gave someone a problem, rather than the more usual ΔT
culprits.
  • Loading branch information
brandon-rhodes committed Apr 22, 2020
1 parent 041e8c7 commit 1ab4d3d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions skyfield/iokit.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def timescale(self, delta_t=None, builtin=False):
data_end_time = data[0, -1]
i = np.searchsorted(preds[0], data_end_time, side='right')
delta_t_recent = np.concatenate([data, preds[:,i:]], axis=1)
leap_dates, leap_offsets = self('Leap_Second.dat')
try:
leap_dates, leap_offsets = self('Leap_Second.dat')
except IOError as e:
e.args = (e.args[0] + _TIMESCALE_IO_ADVICE,) + e.args[1:]
raise
return Timescale(delta_t_recent, leap_dates, leap_offsets)

@property
Expand All @@ -345,9 +349,10 @@ def log(self):

_TIMESCALE_IO_ADVICE = """
Try opening the same URL in your browser to learn more about the problem.
If you want to fall back on the timescale files that Skyfield ships with,
try `.timescale(builtin=True)` instead."""
You can avoid this error by passing `timescale(builtin=True)` which
makes Skyfield use built-in copies of the timescale files instead of
downloading new ones. The built-in leap second and Earth rotation files
will gradually go out of date unless you periodically upgrade Skyfield."""

def _search(mapping, filename):
"""Search a Loader data structure for a filename."""
Expand Down

0 comments on commit 1ab4d3d

Please sign in to comment.