[AstroPy] Time/IERS Question

Erik Bray embray at stsci.edu
Wed Dec 16 15:19:11 EST 2015


On 12/16/2015 01:23 PM, Erik Tollerud wrote:
> 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...


Indeed, the astropy download cache is rather lacking in sophisticated features. 
  If the download cache is used, it will prevent re-downloading a file at the 
same URL if it has already been downloaded (so unless the cache is manually 
cleared, or caching is disabled, it will always reused the IERS A table last 
downloaded to the cache).

The main thing astropy's download cache lacks is use of standard(ish) mechanisms 
to detect if a file/resource at a URL has been updated since it was last 
downloaded and cached.  For more background on this issue and hints as to the 
work that needs to be done on it, see this issue:

https://github.com/astropy/astropy/issues/3961

If anyone would like to work on this, it would make for a lovely contribution to 
astropy that doesn't require getting into any of the astro-specific code.

Erik B.


> On Tue, Dec 1, 2015 at 6:10 PM, Josh Walawender <jmwalawender at gmail.com
> <mailto: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 <mailto:AstroPy at scipy.org>
>     https://mail.scipy.org/mailman/listinfo/astropy
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
>




More information about the AstroPy mailing list