desihub / desisurvey

Code for desi survey planning and implementation
BSD 3-Clause "New" or "Revised" License
2 stars 7 forks source link

Astropy/6.0.0 issue with coordinates breaks test units for jura production #157

Closed araichoor closed 4 months ago

araichoor commented 5 months ago

Unit tests for the jura production currently fail:

FAILED py/desisurvey/test/test_utils.py::TestUtils::test_get_airmass_always_visible
FAILED py/desisurvey/test/test_utils.py::TestUtils::test_get_airmass_lowest
FAILED py/desisurvey/test/test_utils.py::TestUtils::test_get_observer_to_sky

From the log, it s the same failure for all three cases and, If I m correct, the reason is astropy/6.0.0. And, actually, in astropy/5.2.1, there is a WARNING, saying that the considered call won t be supported in the future.

e.g.:

this works fine with astropy/5.2.1 (but raises a WARNING):

import astropy
astropy.__version__
# => '5.2.1'
from astropy import units as u
from desisurvey import utils
t = astropy.time.Time('2020-01-01')
o = utils.get_observer(t, alt=90 * u.deg, az=0 * u.deg)
o.__class__, astropy.coordinates.ICRS.__class__
# => (<class 'astropy.coordinates.builtin_frames.altaz.AltAz'>, <class 'abc.ABCMeta'>)
o.transform_to(astropy.coordinates.ICRS)
# =>
WARNING: AstropyDeprecationWarning: Transforming a frame instance to a frame class (as opposed to another frame instance) will not be supported in the future.  Either explicitly instantiate the target frame, or first convert the source frame instance to a `astropy.coordinates.SkyCoord` and use its `transform_to()` method. [astropy.coordinates.baseframe]
<ICRS Coordinate: (ra, dec) in deg
    (348.28121199, 31.85415575)>

but fails with astropy/6.0.0 (same error than what s reported in the unit tests log):

import astropy
astropy.__version__
# => '6.0.0'
from astropy import units as u
from desisurvey import utils
t = astropy.time.Time('2020-01-01')
o = utils.get_observer(t, alt=90 * u.deg, az=0 * u.deg)
o.__class__, astropy.coordinates.ICRS.__class__
# => (<class 'astropy.coordinates.builtin_frames.altaz.AltAz'>, <class 'abc.ABCMeta'>)
o.transform_to(astropy.coordinates.ICRS)
# =>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/global/common/software/desi/perlmutter/desiconda/20240322-2.2.0/conda/lib/python3.10/site-packages/astropy/coordinates/baseframe.py", line 1272, in transform_to
    raise ConvertError(msg.format(self.__class__, new_frame.__class__))
astropy.coordinates.errors.ConvertError: Cannot transform from <class 'astropy.coordinates.builtin_frames.altaz.AltAz'> to <class 'abc.ABCMeta'>

@schlafly , @weaverba137 : I m not super-familiar with those subtleties, so it would be great if you can have a look at that; thanks!

if useful:

schlafly commented 5 months ago

I think this is addressed in #158 but I had to loosen the tolerances there a little bit, which is awkward.