<div dir="ltr">Hi Josh,<div><br></div><div>The short answer here is that it probably should work just the way you're thinking, but that hasn't been implemented yet. See <a href="https://github.com/astropy/astropy/issues/3275" target="_blank">https://github.com/astropy/astropy/issues/3275</a> for some background.</div><div><br></div><div>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).</div><div><br></div><div>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...</div><div><br></div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr">---</div><div dir="ltr">Erik T</div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Dec 1, 2015 at 6:10 PM, Josh Walawender <span dir="ltr"><<a href="mailto:jmwalawender@gmail.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=jmwalawender@gmail.com&cc=&bcc=&su=&body=','_blank');return false;">jmwalawender@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div>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:</div><div><br></div><div><div><font face="Monaco">LST_string = now.sidereal_time('mean').to_string(sep=':',  precision=1)</font></div></div><div><br></div><div><br></div><div><div><font face="Monaco">Traceback (most recent call last):</font></div><div><font face="Monaco">  File "time_example.py", line 20, in <module></font></div><div><font face="Monaco">    LST_string = now.sidereal_time('mean').to_string(sep=':',  precision=1)</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 523, in sidereal_time</font></div><div><font face="Monaco">    gst = self._erfa_sidereal_time(available_models[model.upper()])</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 539, in _erfa_sidereal_time</font></div><div><font face="Monaco">    for jd_part in ('jd1', 'jd2')]</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 704, in __getattr__</font></div><div><font face="Monaco">    tm._set_scale(attr)</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 372, in _set_scale</font></div><div><font face="Monaco">    args.append(get_dt(jd1, jd2))</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/time/core.py", line 834, in _get_delta_ut1_utc</font></div><div><font face="Monaco">    delta = iers_table.ut1_utc(jd1, jd2)</font></div><div><font face="Monaco">  File "/Users/joshw/anaconda/lib/python2.7/site-packages/astropy/utils/iers/iers.py", line 234, in ut1_utc</font></div><div><font face="Monaco">    raise IndexError('(some) times are outside of range covered '</font></div><div><font face="Monaco">IndexError: (some) times are outside of range covered by IERS table.</font></div></div><div><br></div><div>When I go ahead and download the IERS table using the tools in astroplan:</div><div><br></div><div><div><font face="Monaco">from astroplan import download_IERS_A</font></div><div><font face="Monaco">download_IERS_A()</font></div></div><div><br></div><div>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?</div><div><br></div><div>Any idea why the download is needed every time?</div><div><br></div><div>thanks!</div><div>Josh</div><div><br></div><div>P.S.  Entire code is pasted in below:</div><div><br></div><div><br></div><div><br></div><div><div><div><font face="Monaco">from datetime import datetime as dt</font></div><div><font face="Monaco">from astropy.time import Time</font></div><div><font face="Monaco">from astropy.coordinates import EarthLocation</font></div><div><font face="Monaco">import astropy.units as u</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco"># from astroplan import download_IERS_A</font></div><div><font face="Monaco"># download_IERS_A()</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">utnow = dt.utcnow()</font></div><div><font face="Monaco">subaru = EarthLocation.from_geodetic(-155.476111111*u.degree,\</font></div><div><font face="Monaco">                                     19.8255555556*u.degree,\</font></div><div><font face="Monaco">                                     height=4139.0*u.meter)</font></div><div><font face="Monaco">now = Time(utnow, location=subaru)</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">UTC_string = utnow.strftime('%H:%M:%S.%f')</font></div><div><font face="Monaco">print(UTC_string)</font></div><div><font face="Monaco">MJD_string = '{:20.8f}'.format(now.mjd)</font></div><div><font face="Monaco">print(MJD_string)</font></div><div><font face="Monaco">LST_string = now.sidereal_time('mean').to_string(sep=':',  precision=1)</font></div><div><font face="Monaco">print(LST_string)</font></div></div></div><div><br></div></div><br>_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@scipy.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=AstroPy@scipy.org&cc=&bcc=&su=&body=','_blank');return false;">AstroPy@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br></blockquote></div><br></div></div>