Skip to content

Conversation

@rosteen
Copy link
Contributor

@rosteen rosteen commented Nov 26, 2025

Fixes #1268, and additionally improves the behavior of the shift_spectrum_to method.

Previously, the spectral axis was updated when applying a redshift with shift_spectrum_to, but the original WCS was kept on the Spectrum, which led to some annoying behavior and workarounds (and was potentially confusing to the user). Now the WCS will be updated along with the spectral axis - in the case of a FITS WCS, the relevant header values will be updated in place, while a GWCS will be replaced with a new lookup table GWCS. In the latter case, the original WCS will be stored in an _original_wcs attribute so no information is lost (e.g., spatial coordinates for a cube). This obviously isn't an ideal solution for the GWCS case but I hope it suffices while I investigate better ways to handle the GWCS case.

@rosteen rosteen added this to the 2.3 milestone Nov 26, 2025
@rosteen rosteen added bug data objects Core data objects like Spectrum1D or SpectralCollection labels Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.95%. Comparing base (a747841) to head (f5ab161).

Files with missing lines Patch % Lines
specutils/spectra/spectrum.py 82.14% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1287   +/-   ##
=======================================
  Coverage   86.94%   86.95%           
=======================================
  Files          63       63           
  Lines        4873     4891   +18     
=======================================
+ Hits         4237     4253   +16     
- Misses        636      638    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rosteen rosteen marked this pull request as ready for review November 28, 2025 21:46
@rosteen
Copy link
Contributor Author

rosteen commented Dec 3, 2025

Test failures are unrelated timeouts.

@rosteen rosteen force-pushed the no-redshift-arithmetic branch from 07cc017 to 8e472c4 Compare December 8, 2025 20:54
@rosteen rosteen force-pushed the no-redshift-arithmetic branch from 8e472c4 to b96dc77 Compare December 8, 2025 21:13
@rosteen rosteen force-pushed the no-redshift-arithmetic branch from 3b21bf5 to f5ab161 Compare December 8, 2025 22:47
@rosteen
Copy link
Contributor Author

rosteen commented Dec 8, 2025

@keflavich I added the comment you suggested, and also improved test coverage and addressed a couple problems that revealed (mainly that I forgot to update CDELT and that PCx_x will only be there for multidimensional spectra).

Copy link
Contributor

@cshanahan1 cshanahan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable to me

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

Labels

bug data objects Core data objects like Spectrum1D or SpectralCollection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected Behavior for Arithmetic with Spectrum Objects

3 participants