diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 451cfab1b9..d1450659c1 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -219,6 +219,8 @@ def _return_spectrum_with_correct_units(flux, wcs, metadata, data_type=None, target_wave_unit = u.Unit(hdr[cunit_key]) found_target = True break + print(f"Target wave unit: {target_wave_unit}") + print(f"Current unit: {sc.spectral_axis.unit}") if target_wave_unit == sc.spectral_axis.unit: target_wave_unit = None diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index 71235b3daf..a6db319ce1 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -560,8 +560,10 @@ def _extract_from_aperture(self, cube, uncert_cube, mask_cube, aperture, collapsed_nddata = collapsed_nddata.multiply(aperture_area, propagate_uncertainties=True) # Convert to Spectrum, with the spectral axis in correct units: + print(self.spectral_axis_index) if hasattr(spectral_cube.coords, 'spectral_wcs'): - target_wave_unit = spectral_cube.coords.spectral_wcs.world_axis_units[2-self.spectral_axis_index] + print(f"Has spectral_wcs: {spectral_cube.coords.spectral_wcs.world_axis_units}") + target_wave_unit = spectral_cube.coords.spectral_wcs.world_axis_units[self.spectral_axis_index] else: collapsed_nddata = getattr(nddata_reshaped, selected_func)( axis=self.spatial_axes, **kwargs @@ -572,9 +574,9 @@ def _extract_from_aperture(self, cube, uncert_cube, mask_cube, aperture, def _return_extracted(self, cube, wcs, collapsed_nddata): # Convert to Spectrum1D, with the spectral axis in correct units: if hasattr(cube.coords, 'spectral_wcs'): - target_wave_unit = cube.coords.spectral_wcs.world_axis_units[2-self.spectral_axis_index] + target_wave_unit = cube.coords.spectral_wcs.world_axis_units[self.spectral_axis_index] elif hasattr(cube.coords, 'spectral'): - target_wave_unit = cube.coords.spectral.world_axis_units[2-self.spectral_axis_index] + target_wave_unit = cube.coords.spectral.world_axis_units[self.spectral_axis_index] else: target_wave_unit = None