Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This will fail and raise OSError if the file is not in the cache.
"""
if IERS_A_in_cache():
table = iers.IERS_Auto.open()
# Use polar motion flag to identify last observation before predictions
index_of_last_observation = ''.join(table['PolPMFlag_A']).index('IP')
time_of_last_observation = Time(table['MJD'][index_of_last_observation],
format='mjd')
time_since_last_update = Time.now() - time_of_last_observation
# If the IERS bulletin is more than `warn_update` days old, warn user
if warn_update < time_since_last_update:
warnmsg = ("Your version of the IERS Bulletin A is {:.1f} days "
"old. ".format(time_since_last_update.to(u.day).value) +
IERS_A_WARNING)
warnings.warn(warnmsg, OldEarthOrientationDataWarning)
return table
else:
raise OSError("No IERS A table has been downloaded.")
def _low_precision_utc_to_ut1(self, jd1, jd2):
"""
When no IERS Bulletin A is available (no internet connection), use low
precision time conversion by assuming UT1-UTC=0 always.
This method mimics `~astropy.coordinates.builtin_frames.utils.get_dut1utc`
"""
try:
if self.mjd*u.day not in iers.IERS_Auto.open()['MJD']:
warnings.warn(IERS_A_WARNING, OldEarthOrientationDataWarning)
return self.delta_ut1_utc
except (AttributeError, ValueError):
warnings.warn(IERS_A_WARNING, OldEarthOrientationDataWarning)
return np.zeros(self.shape)