Skip to content

Commit

Permalink
Debugging spectral extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Jan 6, 2025
1 parent 31653e2 commit a818259
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions jdaviz/configs/cubeviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit a818259

Please sign in to comment.