Skip to content

Commit

Permalink
Do not attempt to refresh the IERS-A table if downloading is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ayshih committed Nov 13, 2024
1 parent beec5a1 commit e2c3406
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions astropy/utils/iers/iers.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,11 @@ def _refresh_table_as_needed(self, mjd):
In other words the IERS-A table was created by IERS long enough
ago that it can be considered stale for predictions.
"""
# If downloading is disabled, bail out silently.
# _check_interpolate_indices() will error later if appropriate.
if not conf.auto_download:
return

# Pass in initial to np.max to allow things to work for empty mjd.
max_input_mjd = np.max(mjd, initial=50000)
now_mjd = self.time_now.mjd
Expand Down
13 changes: 10 additions & 3 deletions astropy/utils/iers/tests/test_iers.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,19 @@ def test_simple(self):
dat.ut1_utc(Time(60000, format="mjd").jd)
assert len(warns) == 1

# Warning only if we are getting return status
# Warning only (i.e., no exception) if we are getting return status
with pytest.warns(
iers.IERSStaleWarning, match="IERS_Auto predictive values are older"
) as warns:
):
dat.ut1_utc(Time(60000, format="mjd").jd, return_status=True)
assert len(warns) == 1

# Confirm that there is an interpolation error when downloading is disabled
with iers.conf.set_temp("auto_download", False):
with pytest.raises(
ValueError,
match="interpolating from IERS_Auto using predictive values that are more",
):
dat.ut1_utc(Time(60000, format="mjd").jd)

# Now set auto_max_age = None which says that we don't care how old the
# available IERS-A file is. There should be no warnings or exceptions.
Expand Down
2 changes: 2 additions & 0 deletions docs/changes/utils/17387.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a bug where an old IERS-A table with stale predictive values could trigger
the download of a new IERS-A table even if automatic downloading was disabled.

0 comments on commit e2c3406

Please sign in to comment.