Skip to content

1.2RC1 - test failure in astropy/time/formats.py #5098

Closed

Description

@saimn
___________________________________________ test_scale_conversion ____________________________________________

    def test_scale_conversion():
        if INTERNET_OFF:
            # With internet off (which is the default for testing) then this will
            # fall back to the bundled IERS-B table and raise an exception.  But when
            # testing with --remote-data the IERS_Auto class will get the latest IERS-A
            # and this works.
            with pytest.raises(ScaleValueError):
                Time(Time.now().cxcsec, format='cxcsec', scale='ut1')
        else:
>           Time(Time.now().cxcsec, format='cxcsec', scale='ut1')

astropy/time/tests/test_basic.py:907: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/time/core.py:213: in __init__
    precision, in_subfmt, out_subfmt)
astropy/time/core.py:263: in _init_from_vals
    precision, in_subfmt, out_subfmt)
astropy/time/core.py:301: in _get_time_fmt
    return FormatClass(val, val2, scale, precision, in_subfmt, out_subfmt)
astropy/time/formats.py:337: in __init__
    in_subfmt, out_subfmt, from_jd)
astropy/time/formats.py:131: in __init__
    self.set_jds(val1, val2)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <astropy.time.formats.TimeCxcSec object at 0x7ff27a39f150>, val1 = array(582365171.0633501)
val2 = array(0.0)

    def set_jds(self, val1, val2):
        """
            Initialize the internal jd1 and jd2 attributes given val1 and val2.
            For an TimeFromEpoch subclass like TimeUnix these will be floats giving
            the effective seconds since an epoch time (e.g. 1970-01-01 00:00:00).
            """
        # Form new JDs based on epoch time + time from epoch (converted to JD).
        # One subtlety that might not be obvious is that 1.000 Julian days in
        # UTC can be 86400 or 86401 seconds.  For the TimeUnix format the
        # assumption is that every day is exactly 86400 seconds, so this is, in
        # principle, doing the math incorrectly, *except* that it matches the
        # definition of Unix time which does not include leap seconds.

        # note: use divisor=1./self.unit, since this is either 1 or 1/86400,
        # and 1/86400 is not exactly representable as a float64, so multiplying
        # by that will cause rounding errors. (But inverting it as a float64
        # recovers the exact number)
        day, frac = day_frac(val1, val2, divisor=1. / self.unit)

        jd1 = self.epoch.jd1 + day
        jd2 = self.epoch.jd2 + frac

        # Create a temporary Time object corresponding to the new (jd1, jd2) in
        # the epoch scale (e.g. UTC for TimeUnix) then convert that to the
        # desired time scale for this object.
        #
        # A known limitation is that the transform from self.epoch_scale to
        # self.scale cannot involve any metadata like lat or lon.
        try:
            tm = getattr(Time(jd1, jd2, scale=self.epoch_scale,
                              format='jd'), self.scale)
        except Exception as err:
            raise ScaleValueError("Cannot convert from '{0}' epoch scale '{1}'"
                                  "to specified scale '{2}', got error:\n{3}"
                                  .format(self.name, self.epoch_scale,
>                                         self.scale, err))
E           ScaleValueError: Cannot convert from 'cxcsec' epoch scale 'tt'to specified scale 'ut1', got error:
E           (some) times are outside of range covered by IERS table.

astropy/time/formats.py:374: ScaleValueError
___________________________________________ test_scale_conversion ____________________________________________

    def test_scale_conversion():
        if INTERNET_OFF:
            # With internet off (which is the default for testing) then this will
            # fall back to the bundled IERS-B table and raise an exception.  But when
            # testing with --remote-data the IERS_Auto class will get the latest IERS-A
            # and this works.
            with pytest.raises(ScaleValueError):
                Time(Time.now().cxcsec, format='cxcsec', scale='ut1')
        else:
>           Time(Time.now().cxcsec, format='cxcsec', scale='ut1')

astropy/time/tests/test_basic.py:907: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/time/core.py:213: in __init__
    precision, in_subfmt, out_subfmt)
astropy/time/core.py:263: in _init_from_vals
    precision, in_subfmt, out_subfmt)
astropy/time/core.py:301: in _get_time_fmt
    return FormatClass(val, val2, scale, precision, in_subfmt, out_subfmt)
astropy/time/formats.py:337: in __init__
    in_subfmt, out_subfmt, from_jd)
astropy/time/formats.py:131: in __init__
    self.set_jds(val1, val2)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <astropy.time.formats.TimeCxcSec object at 0x7ff2793c0510>, val1 = array(582365211.867949)
val2 = array(0.0)

    def set_jds(self, val1, val2):
        """
            Initialize the internal jd1 and jd2 attributes given val1 and val2.
            For an TimeFromEpoch subclass like TimeUnix these will be floats giving
            the effective seconds since an epoch time (e.g. 1970-01-01 00:00:00).
            """
        # Form new JDs based on epoch time + time from epoch (converted to JD).
        # One subtlety that might not be obvious is that 1.000 Julian days in
        # UTC can be 86400 or 86401 seconds.  For the TimeUnix format the
        # assumption is that every day is exactly 86400 seconds, so this is, in
        # principle, doing the math incorrectly, *except* that it matches the
        # definition of Unix time which does not include leap seconds.

        # note: use divisor=1./self.unit, since this is either 1 or 1/86400,
        # and 1/86400 is not exactly representable as a float64, so multiplying
        # by that will cause rounding errors. (But inverting it as a float64
        # recovers the exact number)
        day, frac = day_frac(val1, val2, divisor=1. / self.unit)

        jd1 = self.epoch.jd1 + day
        jd2 = self.epoch.jd2 + frac

        # Create a temporary Time object corresponding to the new (jd1, jd2) in
        # the epoch scale (e.g. UTC for TimeUnix) then convert that to the
        # desired time scale for this object.
        #
        # A known limitation is that the transform from self.epoch_scale to
        # self.scale cannot involve any metadata like lat or lon.
        try:
            tm = getattr(Time(jd1, jd2, scale=self.epoch_scale,
                              format='jd'), self.scale)
        except Exception as err:
            raise ScaleValueError("Cannot convert from '{0}' epoch scale '{1}'"
                                  "to specified scale '{2}', got error:\n{3}"
                                  .format(self.name, self.epoch_scale,
>                                         self.scale, err))
E           ScaleValueError: Cannot convert from 'cxcsec' epoch scale 'tt'to specified scale 'ut1', got error:
E           (some) times are outside of range covered by IERS table.

astropy/time/formats.py:374: ScaleValueError

Activity

  1. astrofrog commented on Jun 15, 2016

    @astrofrog
    Member

    @taldcroft - could you take a look at this and let us know if this is release-critical?

  2. taldcroft commented on Jun 15, 2016

    @taldcroft
    Member

    @saimn - are you running tests with --remote-data? What platform and package configuration?

  3. saimn commented on Jun 15, 2016

    @saimn
    ContributorAuthor
  4. taldcroft commented on Jun 15, 2016

    @taldcroft
    Member

    Somewhat grasping at straws... I will try running on CentOS-6 later today (but have to run right now). I think that in testing you should have a clean local cache, but just the same you did you entirely wipe your cache in .astropy? I assume tests pass without remote data?

  5. saimn commented on Jun 15, 2016

    @saimn
    ContributorAuthor

    Yes, tests pass without remote data. And same failures after cleaning the cache.

  6. taldcroft commented on Jun 15, 2016

    @taldcroft
    Member

    Hmm... tests pass on my CentOS-6 platform for Py2.7 and Py3.5.1, for remote and not remote data.

  7. taldcroft commented on Jun 15, 2016

    @taldcroft
    Member

    Can you run Time(Time.now().cxcsec, format='cxcsec', scale='ut1') from an IPython session with your 1.2rc1 installation?

    Another piece of diagnostic info is to run the failing test with --pdb and then:

    from astropy.utils import iers
    ie = iers.IERS_Auto.open()
    t = ie.iers_table
    t.meta
    t[0]
    t[-1]
    
  8. astrofrog commented on Jun 15, 2016

    @astrofrog
    Member

    Tried reproducing this, but I don't see this failure on CentOS 7

  9. 1 remaining item

  10. saimn commented on Jun 16, 2016

    @saimn
    ContributorAuthor

    So first issue is that I get a timeout from http://maia.usno.navy.mil/ser7/finals2000A.all (I can download it but it takes longer than the 3 sec timout). And second issue is that ie.iers_table is None.

    In [1]: from astropy.utils import iers
    
    In [2]: ie = iers.IERS_Auto.open()
    WARNING: failed to download http://maia.usno.navy.mil/ser7/finals2000A.all, using local IERS-B: <urlopen error timed out> [astropy.utils.iers.iers]
    
    In [3]: ie
    Out[3]: 
    <IERS_B length=19840>
     year month  day    MJD      PM_x     PM_y   ...  e_PM_x  e_PM_y e_UT1_UTC  e_LOD   e_dX_2000A e_dY_2000A
                         d      arcsec   arcsec  ...  arcsec  arcsec     s        s       arcsec     arcsec  
    int64 int64 int64 float64  float64  float64  ... float64 float64  float64  float64   float64    float64  
    ----- ----- ----- ------- --------- -------- ... ------- ------- --------- -------- ---------- ----------
     1962     1     1 37665.0   -0.0127    0.213 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     2 37666.0   -0.0159   0.2141 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     3 37667.0    -0.01ie.iers_table9   0.2152 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     4 37668.0 -0.021999 0.216301 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     5 37669.0 -0.024799 0.217301 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     6 37670.0 -0.027599 0.218301 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     7 37671.0 -0.030199 0.219301 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     8 37672.0 -0.032798 0.220202 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1     9 37673.0 -0.035198 0.221102 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
     1962     1    10 37674.0 -0.037498 0.222002 ...    0.03    0.03     0.002   0.0014   0.004774      0.002
       ...   ...   ...     ...       ...      ... ...     ...     ...       ...      ...        ...        ...
     2016     4    23 57501.0  0.024089 0.460209 ... 4.2e-05 3.7e-05   6.1e-06 1.97e-05    2.6e-05    2.6e-05
     2016     4    24 57502.0  0.025818 0.461888 ... 4.2e-05 3.7e-05   6.1e-06 1.96e-05    2.8e-05    2.7e-05
     2016     4    25 57503.0  0.027086 0.463482 ... 4.1e-05 3.7e-05   6.1e-06 1.95e-05    2.9e-05    2.8e-05
     2016     4    26 57504.0  0.028079 0.465372 ... 4.1e-05 3.7e-05   6.1e-06 1.95e-05      3e-05      3e-05
    
    In [4]: ie.iers_table
  11. saimn commented on Jun 16, 2016

    @saimn
    ContributorAuthor

    After looking a bit more in detail, all I can say is that I'm confused by the mix between inheritance (IERS_Auto/IERS_B/IERS), class methods and the iers_table class attribute ...

  12. astrofrog commented on Jun 16, 2016

    @astrofrog
    Member

    Should we increase the timeout? 3 seconds seems pretty small

  13. eteq commented on Jun 16, 2016

    @eteq
    Member

    @saimn - have you tried boosting the timeout? You can do this by doing something like

    from astropy.utils import data, iers
    
    with data.Conf.remote_timeout.set_temp(10):
            ie = iers.IERS_Auto.open()
    

    The perhaps non-obvious item here is that the timeout is 3 seconds to open the connection, not the amount of time to complete the download. So we don't want to make people wait too long because then their code will hang for a long time if they have the internet off or whatever (depending on their network setup...)

  14. eteq commented on Jun 16, 2016

    @eteq
    Member

    That is, if setting that configuration item resolves @saimn's error, it might mean that we should just add a note to do that instead of hard-coding a special timeout just for IERS.

  15. saimn commented on Jun 17, 2016

    @saimn
    ContributorAuthor

    @eteq - Increasing the timeout indeed does the job:

    In [1]: from astropy.utils import data, iers
    
    In [2]: ie = iers.IERS_Auto.open()
    WARNING: failed to download http://maia.usno.navy.mil/ser7/finals2000A.all, using local IERS-B: <urlopen error timed out> [astropy.utils.iers.iers]
    
    In [3]: ie.iers_table
    
    In [4]: with data.Conf.remote_timeout.set_temp(10):
       ...:     ie = iers.IERS_Auto.open()
       ...:     
    Downloading http://maia.usno.navy.mil/ser7/finals2000A.all
    |========================================================================| 3.0M/3.0M (100.00%)         0s
    
    In [5]: ie.iers_table                                                              
    Out[5]: 
    <IERS_Auto length=16245>
     year month  day    MJD   PolPMFlag_A  PM_x_A  ... dY_2000A_B  UT1_UTC   UT1Flag   PM_x     PM_y   PolPMFlag
                         d                 arcsec  ...  marcsec       s               arcsec   arcsec           
    int64 int64 int64 float64     str1    float64  ...  float64    float64     str1  float64  float64     str1  
    ----- ----- ----- ------- ----------- -------- ... ---------- ---------- ------- -------- -------- ---------
       73     1     2 41684.0           I 0.120679 ...     -3.667  0.8078584       B   0.1235    0.123         B
       73     1     3 41685.0           I 0.118926 ...     -3.571  0.8051525       B   0.1223    0.121         B
       73     1     4 41686.0           I 0.117173 ...     -3.621  0.8024015       B 0.120901 0.119001         B
       73     1     5 41687.0           I 0.115419 ...     -3.769  0.7995416       B 0.119601 0.117101         B
       73     1     6 41688.0           I 0.113663 ...     -3.868  0.7965306       B 0.118201 0.115201         B
    ...

    But there is still the issue of why the fallback is not working: IERS_B_FILE (data/eopc04_IAU2000.62-now) is correctly read, but then ie.iers_table is None (which is the root of the other failures, from @taldcroft 's comment ?).

  16. taldcroft commented on Jun 17, 2016

    @taldcroft
    Member

    After looking a bit more in detail, all I can say is that I'm confused by the mix between inheritance (IERS_Auto/IERS_B/IERS), class methods and the iers_table class attribute ...

    This is all quite confusing indeed even to me.... I realize that you should not be looking at the ie.iers_table attribute at all, but instead just ie. The former is just the cached version and is allowed to be None, and probably should have been a private attribute all along. Sorry for the misdirection.

    The problem with iers_table being None is a latent issue in the original code:

    In [1]: from astropy.utils import data, iers
    In [2]: ie = iers.IERS.open()
    In [3]: print(ie.iers_table)
    None
    

    In your case this could be fixed by having the Auto class fall through to loading via the IERS_B class directly instead of IERS. I think this is a corner case that can wait.

    I would say that the suggested documentation update would be the right thing right now. I probably won't have time to do this today because of other commitments.

    In order to make the changes for auto-downloading be back-compatible, it is layered on top of the existing IERS / IERS_A / IERS_B infrastructure. As mentioned this module is pretty confusing. Hopefully most users and devs just won't have to deal with it going forward, or else we need to consider a bigger re-write in the future.

  17. taldcroft commented on Jun 17, 2016

    @taldcroft
    Member

    The experience of @saimn does make me wonder if it would be worth increasing the timeout for IERS download to maybe 5 or 10 seconds so we have fewer of these issues pop up in the wild.

  18. astrofrog commented on Jun 17, 2016

    @astrofrog
    Member

    👍 - 3 seconds is low

  19. taldcroft commented on Jun 17, 2016

    @taldcroft
    Member

    See #5111.

  20. saimn commented on Jun 17, 2016

    @saimn
    ContributorAuthor

    Increasing the timeout for this file seems a good solution. 👍

  21. saimn commented on Jun 17, 2016

    @saimn
    ContributorAuthor

    Also, I will not be able to test this before Monday, here at home I don't have the timeout issue ...

  22. eteq commented on Jun 18, 2016

    @eteq
    Member

    @saimn - no worries - whenever you get a chance please give it a shot, and if it's now working post-#5111, go ahead and close this.

  23. saimn commented on Jun 20, 2016

    @saimn
    ContributorAuthor

    Fixed with #5111 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions