[AstroPy] Time/IERS Question

Erik Tollerud erik.tollerud at gmail.com
Wed Dec 16 13:23:20 EST 2015


Hi Josh,

The short answer here is that it probably should work just the way you're
thinking, but that hasn't been implemented yet. See
https://github.com/astropy/astropy/issues/3275 for some background.

The longer answer is that it's not entirely clear how *often* they should
be downloaded.  In *theory* it should be downloaded every time, because the
IERS A predictions are based on earth-based observations, and so they are
updated at irregular intervals (~1 week).  For almost all applications, the
predictions are more than good enough up to the end of when they're valid
(I think that's 21 days, although I can't recall for sure).

So probably the best solution, and one that would be *nice* to have in
Astropy would be to have the IERS A be cached in a way that expires after
maybe a week or so, and is only re-downloaded after that.  Unfortunately,
that requires some changes to the caching machinery, which we simply
haven't had time to do.  But certainly anyone is welcome to take a shot at
getting this in for Astropy 1.2 - I would love to see it, personally, and
might get to it, but I say that about a lot of things...





---
Erik T

On Tue, Dec 1, 2015 at 6:10 PM, Josh Walawender <jmwalawender at gmail.com>
wrote:

> 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)
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20151216/508d254f/attachment.html>


More information about the AstroPy mailing list