radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
98 stars 65 forks source link

Spectral-cube uses astropy.coordinates.angle_utilities which is removed in Astropy 6 #892

Closed olebole closed 11 months ago

olebole commented 12 months ago

With Astropy 6.0, the CI tests of spectral-cube no longer pass; there are now many failures like

______________________ test_casa_read_basic[False-False] _______________________

memmap = False, bigendian = False

    @pytest.mark.parametrize(('memmap', 'bigendian'), product((False, True), (False, True)))
    def test_casa_read_basic(memmap, bigendian):
        […]
>       cube.moment0()

/usr/lib/python3/dist-packages/spectral_cube/tests/test_casafuncs.py:133: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3/dist-packages/spectral_cube/spectral_cube.py:1702: in moment0
    return self.moment(axis=axis, order=0, how=how)
/usr/lib/python3/dist-packages/spectral_cube/dask_spectral_cube.py:1069: in moment
    pix_cen = self._pix_cen()[axis]
/usr/lib/python3/dist-packages/spectral_cube/utils.py:18: in wrapper
    self._cache[(func, args)] = func(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = DaskSpectralCube with shape=(3, 4, 5) and unit=Jy / beam and chunk size (3, 4, 5):
 n_x:      5  type_x: RA---SIN  uni...9.934094 deg:   29.935778 deg
 n_s:      3  type_s: FREQ      unit_s: Hz     range: 1421917021.146 Hz:1421929254.325 Hz

    @cached
    def _pix_cen(self):
        """…"""
        # Start off by extracting the world coordinates of the pixels
        _, lat, lon = self.world[0, :, :]
        spectral, _, _ = self.world[:, 0, 0]
        spectral -= spectral[0] # offset from first pixel

        # Convert to radians
        lon = np.radians(lon)
        lat = np.radians(lat)

        # Find the dx and dy arrays
>       from astropy.coordinates.angle_utilities import angular_separation
E       ModuleNotFoundError: No module named 'astropy.coordinates.angle_utilities'

/usr/lib/python3/dist-packages/spectral_cube/spectral_cube.py:1456: ModuleNotFoundError

full test log

Reason is that angle_utilities was deprecated in Astropy 4.2 and removed in 6.0:

Removed deprecated angle parsing and formatting utilities from angle_utilities. Use the functions from angle_formats instead. [#14675]

keflavich commented 12 months ago

See also https://github.com/astropy/astropy/issues/15666

NithyaSathyan commented 11 months ago

While doing FERMI LAT data analysis using fermipy , I encountered similar error which is given below : WARNING: FITSFixedWarning: RADECSYS= 'FK5 ' the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs] WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2001-01-01T00:01:04.184' from MJDREF. Set MJD-OBS to 54682.655283 from DATE-OBS. Set MJD-END to 59852.000000 from DATE-END'. [astropy.wcs.wcs] Traceback (most recent call last): File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py", line 5196, in setup self._bexp = Map.read(self.files['bexpmap'], hdu=hpxhduname) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/core.py", line 240, in read return Map.from_hdulist( File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/core.py", line 308, in from_hdulist map_type = Map._get_map_type(hdulist, hdu) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/core.py", line 339, in _get_map_type header = hdu_list[hdu_name].header File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/astropy/io/fits/hdu/hdulist.py", line 390, in getitem super().getitem, self._positive_index_of(key) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/astropy/io/fits/hdu/hdulist.py", line 857, in _positive_index_of index = self.index_of(key) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/astropy/io/fits/hdu/hdulist.py", line 839, in index_of raise KeyError(f"Extension {key!r} not found.") KeyError: "Extension 'HPXEXPOSURES' not found."

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/dell/data backup ubuntu dell mint/Documents/low_z_BLLACs/1ES1959+650/xx.py", line 3, in gta.setup() File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py", line 1087, in setup c.setup(overwrite=overwrite) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py", line 5198, in setup self._bexp = Map.read(self.files['bexpmap']) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/core.py", line 240, in read return Map.from_hdulist( File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/core.py", line 315, in from_hdulist return cls_out.from_hdulist( File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/wcs/core.py", line 142, in from_hdulist wcs_map = cls.from_hdu(hdu, hdu_bands, format=format) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/wcs/ndmap.py", line 88, in from_hdu geom = WcsGeom.from_header(hdu.header, hdu_bands, format=format) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/wcs/geom.py", line 485, in from_header axes = MapAxes.from_table_hdu(hdu_bands, format=format) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/axes.py", line 1962, in from_table_hdu return cls.from_table(table, format=format) File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/axes.py", line 1980, in from_table from gammapy.irf.io import IRF_DL3_AXES_SPECIFICATION File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/irf/init.py", line 6, in from .background import Background2D, Background3D File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/irf/background.py", line 10, in from .core import IRF File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/irf/core.py", line 17, in from .io import IRF_DL3_HDU_SPECIFICATION, IRF_MAP_HDU_SPECIFICATION, gadf_is_pointlike File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/irf/io.py", line 4, in from gammapy.data.hdu_index_table import HDUIndexTable File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/data/init.py", line 3, in from .data_store import DataStore File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/data/data_store.py", line 15, in from .observations import Observation, ObservationChecker, Observations File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/data/observations.py", line 22, in from .event_list import EventList, EventListChecker File "/home/dell/miniconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/data/event_list.py", line 8, in from astropy.coordinates.angle_utilities import angular_separation ModuleNotFoundError: No module named 'astropy.coordinates.angle_utilities'

Firestar-Reimu commented 6 months ago

Same issue, still not fixed?

Sorry, the spectral-cube on conda-forge is still 0.6.3, it needs to be updated to 0.6.5

Do you maintain the conda-forge package?

keflavich commented 6 months ago

@Firestar-Reimu indeed, see https://github.com/conda-forge/spectral-cube-feedstock/pull/16

Firestar-Reimu commented 6 months ago

Quick Reply, Thanks!

I can change /home/firestar/.miniconda/lib/python3.12/site-packages/spectral_cube/spectral_cube.py manually for now.

Bash exited with code '1'.

I still do not know why it cannot be merged, what a pity.

Firestar-Reimu commented 6 months ago

https://anaconda.org/conda-forge/spectral-cube

now its good.