Skip to content

IERS-A data emitted IERSDegradedAccuracyWarning in astropy 5.3.3 but throws ValueError in astropy 7 or later #19823

Closed

Description

@pllim

From https://groups.google.com/g/astropy-dev/c/m8pKTPvetF0

Heiko S.

We use astropy for user scripts in a telescope control system, otherwise erfa in the CS code. A change of Linux distribution brought us an upgrade of astropy from 5.3.3 to 7.01.

Our IERS data update strategy is to download IERS-A data regularly. So we aim for the highest precision. But if that fails (e.g. due to network access restrictions), and cached data is older than auto_max_age, then we would like to get only warnings logged by astropy.

This worked fine in the old version of astropy, with setting iers.conf.iers_degraded_accuracy = "warn", which yielded an IERSDegradedAccuracyWarning. It seems that with the inclusion of IERS-A data in astropy (commit 2da17a6 from #16187 that was follow-up for #14819), this config attribute is no longer applied to cached IERS-A data, but only to the IERS data that came already with the astropy installation. Instead of printing the warnings, astropy now fails with ValueError, which we don't want.

A possible workaround would be to set a very large auto_max_age, but then we don't even get the warnings that we actually like to see.

My question is, would it be possible to add a new config attribute that applies to cached IERS-A data, e.g. iers.conf.iers_degraded_accuracy_cached? Or to apply the existing attribute iers_degraded_accuracy to all IERS data sources (installation, previous download)? Or maybe I'm lacking imagination and one could get the old behavior back in a different way, without change in astropy?

Tim. Pickering

That data is now managed by the astropy-iers-data package. so to keep the data up to date, use pip to upgrade that package regularly. For our systems, I run a daily cron job to do that.

Marten van Kerkwijk

I think you are right that the different sources of IERS A data should be treated the same way, i.e., that the regression you are seeing should be considered a bug that we should fix.

(Indeed, if you are willing and able to write a PR that applies the existing iers_degraded_accuracy also to co-installed data, that would be very welcome!)

Activity

  1. RadeshL commented on May 31, 2026

    @RadeshL

    hey! I would love to contribute to this issue.

    going through the issue, at first I thought that, I might need to write a new test file to verify this issue. However on running the astropy/utils/iers/tests/test_iers.py file I got this output, which pinpoints to the issue currently being faced. Heres the screenshot of it:

    Image

    I ran it with this command :
    python -m pytest astropy/utils/iers/tests/test_iers.py -k test_iers_download_error_handling --remote-data -v

    this is the code in the test_iers.py file that handles the iers_degraded_accuracy:

    iers.conf.set_temp("iers_degraded_accuracy", "ignore"):
                (now + 400 * u.day).ut1

    So it is clear that, even after setting it to "ignore", the test throws out a value error.

    Here is what I did to solve this issue:

    in the astropy/utils/iers/iers.py file I've added code for configuration handling before raising an exception. Heres the code of the implemented block:

    if conf.iers_degraded_accuracy == "error":
                    raise ValueError(INTERPOLATE_ERROR.format(auto_max_age))
    elif conf.iers_degraded_accuracy == "ignore":
                    pass

    While looking through the file, I also noticed that there is another configuration supported named "warn" in the astropy/utils/iers/iers.py file :

    iers_degraded_accuracy = _config.ConfigItem(
            ["error", "warn", "ignore"],
            "IERS behavior if the range of available IERS data does not "
            "cover the times when converting time scales, potentially leading "
            "to degraded accuracy.  Applies also when using cached IERS-A data.",
        )

    I am not sure as to how do you want to display the warning message, is this the right way to do it:

          warn(
                        INTERPOLATE_ERROR.format(auto_max_age),
                        IERSDegradedAccuracyWarning,
                    )

    After the changes made in the code, there is no value error being thrown. This is the output of test:

    Image




    I also want to higligh that this failure was present both before and after my changes, so it seems unrelated to the iers_degraded_accuracy issue and may be outside the scope of this PR.

    Image




    Could you please confirm whether the proposed handling for the "warn" configuration is right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions