You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IERSRangeError after downloading table from USNO #13227
Recent dates don't seem to be included in the IERS table when I force a fresh download
Expected behavior
I expected to convert a recent date
Actual behavior
astropy.utils.iers.iers.IERSRangeError: (some) times are outside of range covered by IERS table.
Steps to Reproduce
# Put your Python code snippet here.fromastropy.utils.dataimportdownload_filefromastropy.timeimportTime, TimeDeltafromastropy.utilsimportiersurl='https://maia.usno.navy.mil/ser7/finals2000A.all'filename=download_file(url, cache=False) # Force download of latest copydat=iers.IERS_Auto.read(file=filename)
iers.IERS.iers_table=datiers.conf.auto_download=False
(Time.now()-TimeDelta(3)).ut1#Raises Error# astropy.utils.iers.iers.IERSRangeError: (some) times are outside of range covered by IERS table.foriinrange(1000):
try:
LastDate= (Time('2021-01-11')+TimeDelta(i)).ut1exceptiers.iers.IERSRangeError:
print(Time('2021-01-11')+TimeDelta(i))
break# 2022-02-06 00:00:00.000 is the first date that cannot be converted
Since we do not control this data file, I have inquired with USNO and will post here if I hear back. Thanks for your patience!
Thank you for contacting USNO for me. What really confuses me is that if I get the year, month and day from the final row of the table, it is a date about 1 year in the future:
fromdatetimeimportdatetime, timedeltafromastropy.utils.dataimportdownload_filefromastropy.timeimportTime, TimeDeltafromastropy.utilsimportiersurl='https://maia.usno.navy.mil/ser7/finals2000A.all'filename=download_file(url, cache=False) # Force download of latest copydat=iers.IERS_Auto.read(file=filename)
Latest=datetime(2000+dat[-1]['year'],dat[-1]['month'],dat[-1]['day']).strftime('%Y-%m-%d')
print(Latest) #'2023-05-13'
This is smelling like a bug. The data is obviously there but somehow "invisible" when auto_download is set to False. My hunch is that the bug is somewhere here:
Thanks! I think @pllim has the right work-around, but you've clearly found a bug: unless one sets earth_orientation_table explicitly (like @pllim suggested) any Time use would call IERS_Auto.open() and that starts with
# If the URL has changed, we need to redownload the file, so we
# should ignore the internally cached version.
ifcls.iers_table.meta.get('data_url') inall_urls:
returncls.iers_table
You see that with auto_download=False it forces the IERS_B table, even though a good table is already set. Logically, it should just use the table present if one is there.
Would you be willing to make a quick PR? A test could use your example, except perhaps with IERS_A_EXCERPT instead of downloading the full file (or it could be skipped if not HAS_IERS_A; see iers/tests/test_iers.py)
@Warren-Porter , glad the workaround worked for you. Are you still interested to submit a PR to fix the underlying bug as mentioned in #13227 (comment) ? 😸
We encountered this same bug in the different context of puzzling CI errors. astropy's conftest.py naturally sets iers.conf.auto_download = False (for offline testing), but as noted by @mhvk, this has the unintuitive behavior of disregarding the IERS A table. For example, in the latest astropy-iers-data release at the time of this writing, IERS A has historical data up to February 13, but IERS B has data only up to January 16. Thus, a seemingly innocuous time conversion of, say, February 1 raises a warning on CI but does not raise a warning for a user with the default setting of iers.conf.auto_download = True.
Here's a minimal test example, illustrating the silliness that a just-downloaded IERS A table is subsequently ignored if iers.conf.auto_download = False:
Indeed, this clearly is a bug - fix like in my comment most welcome -- though it is now clear one would also need to adjust the documentation of the configuration parameter!
Okay, I did a bit of archaeology, and this logic unsurprisingly traces back eight years ago to when auto-downloading of IERS A was implemented (#4436), but there was no expectation that IERS A would get bundled. So, auto_download = False served two purposes in order to make Astropy 1.2 behave like 1.1:
Do not trigger downloads
Use the bundled table (IERS B) even if IERS A has been downloaded
Fast forward to the present day, with IERS A now bundled (#14819), we should definitely fix the bug that auto_download = False ignores IERS A. The question on my mind is whether auto_download = False should still ignore a downloaded IERS A. I see value in forcing code to use the bundled tables, but I think the keyword name is unfortunate (versus something clearer like use_bundled = True).
The argument for ignoring a downloaded IERS A is reproducibility. If auto_download = False forces code to use the bundled IERS A instead of any downloaded IERS A, then it's possible to reproduce a computation by knowing only the version of astropy-iers-data.
I think we should ensure that auto_download just does what its name suggest - not download anything. If people want a specific IERS file, they can just open that file explicitly. (But clearly, this will be not just a bug fix but a API change, even if implicit).
Activity
pllim commentedon May 6, 2022
Since we do not control this data file, I have inquired with USNO and will post here if I hear back. Thanks for your patience!
Warren-Porter commentedon May 6, 2022
Thank you for contacting USNO for me. What really confuses me is that if I get the year, month and day from the final row of the table, it is a date about 1 year in the future:
pllim commentedon May 6, 2022
The error only pops up when
iers.conf.auto_download = False🤔pllim commentedon May 6, 2022
This is smelling like a bug. The data is obviously there but somehow "invisible" when
auto_downloadis set toFalse. My hunch is that the bug is somewhere here:astropy/astropy/utils/iers/iers.py
Line 756 in 873d2c9
But I don't grok IERS or UT1 enough to see what is supposed to happen. Maybe @mhvk or @taldcroft have ideas?
pllim commentedon May 6, 2022
Maybe your code is somehow grabbing IERS B. What if you do this? Does it go all the way to May 2023 before crashing?
mhvk commentedon May 6, 2022
Thanks! I think @pllim has the right work-around, but you've clearly found a bug: unless one sets
earth_orientation_tableexplicitly (like @pllim suggested) anyTimeuse would callIERS_Auto.open()and that starts withastropy/astropy/utils/iers/iers.py
Lines 702 to 714 in 873d2c9
You see that with
auto_download=Falseit forces theIERS_Btable, even though a good table is already set. Logically, it should just use the table present if one is there.Would you be willing to make a quick PR? A test could use your example, except perhaps with
IERS_A_EXCERPTinstead of downloading the full file (or it could be skipped ifnot HAS_IERS_A; seeiers/tests/test_iers.py)Warren-Porter commentedon May 7, 2022
Setting
earth_orientation_tableexplicitly works for me. Thank you!pllim commentedon May 7, 2022
@Warren-Porter , glad the workaround worked for you. Are you still interested to submit a PR to fix the underlying bug as mentioned in #13227 (comment) ? 😸
ayshih commentedon Mar 9, 2024
We encountered this same bug in the different context of puzzling CI errors. astropy's
conftest.pynaturally setsiers.conf.auto_download = False(for offline testing), but as noted by @mhvk, this has the unintuitive behavior of disregarding the IERS A table. For example, in the latestastropy-iers-datarelease at the time of this writing, IERS A has historical data up to February 13, but IERS B has data only up to January 16. Thus, a seemingly innocuous time conversion of, say, February 1 raises a warning on CI but does not raise a warning for a user with the default setting ofiers.conf.auto_download = True.Here's a minimal test example, illustrating the silliness that a just-downloaded IERS A table is subsequently ignored if
iers.conf.auto_download = False:Curiously, the documentation for the configuration parameter correctly states this behavior of looking at only IERS B, but the guide page for
astropy.utils.iersis incorrect and states that IERS A will also be used in addition to IERS B even ifauto_download = False.mhvk commentedon Mar 9, 2024
Indeed, this clearly is a bug - fix like in my comment most welcome -- though it is now clear one would also need to adjust the documentation of the configuration parameter!
ayshih commentedon Mar 11, 2024
Okay, I did a bit of archaeology, and this logic unsurprisingly traces back eight years ago to when auto-downloading of IERS A was implemented (#4436), but there was no expectation that IERS A would get bundled. So,
auto_download = Falseserved two purposes in order to make Astropy 1.2 behave like 1.1:Fast forward to the present day, with IERS A now bundled (#14819), we should definitely fix the bug that
auto_download = Falseignores IERS A. The question on my mind is whetherauto_download = Falseshould still ignore a downloaded IERS A. I see value in forcing code to use the bundled tables, but I think the keyword name is unfortunate (versus something clearer likeuse_bundled = True).pllim commentedon Mar 11, 2024
Is there any real need of ignoring IERS A when it is available anyway? 👀
ayshih commentedon Mar 11, 2024
The argument for ignoring a downloaded IERS A is reproducibility. If
auto_download = Falseforces code to use the bundled IERS A instead of any downloaded IERS A, then it's possible to reproduce a computation by knowing only the version ofastropy-iers-data.mhvk commentedon Mar 11, 2024
I think we should ensure that
auto_downloadjust does what its name suggest - not download anything. If people want a specific IERS file, they can just open that file explicitly. (But clearly, this will be not just a bug fix but a API change, even if implicit).