[AstroPy] Time/IERS Question
Josh Walawender
jmwalawender at gmail.com
Tue Dec 1 18:10:59 EST 2015
Hi all,
I’m getting some behavior I don’t understand from astropy.time. I’m trying to make a quick tool for printing out the current time in UT, MJD, and sidereal (LMST). When I run it, I get an error on the step of calculating the sidereal time:
LST_string = now.sidereal_time('mean').to_string(sep=':', precision=1)
Traceback (most recent call last):
File "time_example.py", line 20, in <module>
LST_string = now.sidereal_time('mean').to_string(sep=':', precision=1)
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 523, in sidereal_time
gst = self._erfa_sidereal_time(available_models[model.upper()])
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 539, in _erfa_sidereal_time
for jd_part in ('jd1', 'jd2')]
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 704, in __getattr__
tm._set_scale(attr)
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 372, in _set_scale
args.append(get_dt(jd1, jd2))
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 834, in _get_delta_ut1_utc
delta = iers_table.ut1_utc(jd1, jd2)
File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/utils/iers/iers.py", line 234, in ut1_utc
raise IndexError('(some) times are outside of range covered '
IndexError: (some) times are outside of range covered by IERS table.
When I go ahead and download the IERS table using the tools in astroplan:
from astroplan import download_IERS_A
download_IERS_A()
the code works. But I need to do this download every time I run the code which is time consuming on code that I want to run many times. Shouldn’t this be cached?
Any idea why the download is needed every time?
thanks!
Josh
P.S. Entire code is pasted in below:
from datetime import datetime as dt
from astropy.time import Time
from astropy.coordinates import EarthLocation
import astropy.units as u
# from astroplan import download_IERS_A
# download_IERS_A()
utnow = dt.utcnow()
subaru = EarthLocation.from_geodetic(-155.476111111*u.degree,\
19.8255555556*u.degree,\
height=4139.0*u.meter)
now = Time(utnow, location=subaru)
UTC_string = utnow.strftime('%H:%M:%S.%f')
print(UTC_string)
MJD_string = '{:20.8f}'.format(now.mjd)
print(MJD_string)
LST_string = now.sidereal_time('mean').to_string(sep=':', precision=1)
print(LST_string)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20151201/80dd671a/attachment.html>
More information about the AstroPy
mailing list