How can I locally backup downloaded data files?

When I first run some of Astropy’s functions it will trigger downloads of data such as https://datacenter.iers.org/data/9/finals2000A.all

These downloads can occasionally fail. I would like to have local copies instead where my team can take responsibility for periodically updating them.

I can run my program such that all the files are downloaded.
But I have two challenges. First how do I locate the full set of downloaded files and second how do I tell astropy to use local copies?

The specific file you call out is the IERS-A table, and there is a recommended workflow:

  • Set a configuration parameter that disables the downloading of updated IERS-A tables (see IERS data access (astropy.utils.iers) — Astropy v7.0.0), which will tell astropy to always use the IERS-A table from the corresponding astropy-iers-data package
  • Update the astropy-iers-data package as appropriate so that the updated IERS-A table is available locally

I believe this workflow also works for the leap-second file.

Are there other files that concern you?

Thanks @ayshih I didn’t realize that page existed.
To be clear if I want to pull the most recent set and then use them offline I just need to call

pip install astropy-iers-data
and then set
iers.conf.auto_download = False

astropy-iers-data should already be installed because it is an astropy dependency, so you will likely need to specify --upgrade/-U in the pip command.

@ayshih I tried this approach and my astropy-iers-data package is now up to date, but it’s not clear that astropy is actually using it.

If I disable downloads I get the error

WARNING: IERSStaleWarning: leap-second file is expired. [astropy.utils.iers.iers]                                                                           WARNING: Tried to get polar motions for times after IERS data is valid. Defaulting to polar motion from the 50-yr mean for those. This may affect precision at the arcsec level. Please check your astropy.utils.iers.conf.iers_auto_url and point it to a newer version if necessary. [astropy.coordinates.builtin_frames.utils]                                                                                                                                                   WARNING: (some) times are outside of range covered by IERS table. Cannot convert with full accuracy. To allow conversion with degraded accuracy set astropy.utils.iers.conf.iers_degraded_accuracy to "warn" or "silent". For more information about setting this configuration parameter or controlling its value globally, see the Astropy configuration system documentation https://docs.astropy.org/en/stable/config/index.html. Assuming UT1-UTC=0 for coordinate transformations. [astropy.coordinates.builtin_frames.utils]

But if I leave downloads on this error doesn’t occur.
Also running find

sudo find / -name "Leap_Second.dat"
/usr/local/lib/python3.8/dist-packages/astropy_iers_data/data/Leap_Second.dat
/usr/local/lib/python3.8/dist-packages/astropy/utils/iers/data/Leap_Second.dat

shows two Leap_Second.dat files present on the system. One is 2025 the other is 2023

Hmm, what version of astropy are you using? Since you are apparently running Python 3.8, you are probably using a version of astropy this is at least two years old (astropy 5.2.x or earlier), which means it predates the use of astropy-iers-data (which started with astropy 6.0). I would highly recommend that you update to a much more recent release of astropy, preferably 7.0, not only for the use of astropy-iers-data, but also because there have been various improvements to how the IERS tables are handled when auto_download=False.

(astropy 5.2 was the last release that supported Python 3.8, so upgrading astropy will require you to upgrade Python as well)

Thanks, I didn’t realize our version was so out of date. I’ll look into upgrading.