Skip to content

Adding redshift and radial velocity properties to SpectrumCollection - #1332

Merged
rosteen merged 7 commits into
astropy:mainfrom
rosteen:redshift-for-spectrum-collection
Jun 17, 2026
Merged

Adding redshift and radial velocity properties to SpectrumCollection#1332
rosteen merged 7 commits into
astropy:mainfrom
rosteen:redshift-for-spectrum-collection

Conversation

@rosteen

@rosteen rosteen commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Currently only allow scalar values (rather than an array of values matching the number of spectra), and allows shifting the spectral axes with shift_spectrum_to like Spectrum does. I also added some clarification to the narrative docs about what exactly is happening when you access a single spectrum from a SpectrumCollection. Allowing array redshifts (one per spectrum in the collection) requires some upstream work in Astropy first.

Closes #1318.

@rosteen rosteen added this to the 2.5.0 milestone Jun 10, 2026
@rosteen
rosteen requested a review from eteq as a code owner June 10, 2026 21:31
@rosteen rosteen added the data objects Core data objects like Spectrum1D or SpectralCollection label Jun 10, 2026
@rosteen
rosteen requested a review from keflavich as a code owner June 10, 2026 21:31

@keflavich keflavich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have some minor wording suggestions.

I'm not sure it is ever right to adopt the first redshift out of a collection if they're not all equal

Comment thread docs/spectrum_collection.rst Outdated
Comment thread specutils/spectra/spectrum_collection.py Outdated
Comment thread specutils/spectra/spectrum_collection.py Outdated
Comment on lines +81 to +83
if redshift is not None and not (isinstance(redshift, (int, float)) or
(isinstance(redshift, u.Quantity) and redshift.ndim == 0)):
raise ValueError("Only single-value redshifts are supported at this time.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe np.isscalar can replace this logic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it doesn't work on Quantities, so it can't replace everything here.

Comment thread specutils/spectra/spectrum_collection.py Outdated
Co-authored-by: Adam Ginsburg <keflavich@gmail.com>
@rosteen

rosteen commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@keflavich I addressed your comments and fixed the failing docs build, I think this is ready for another look.

@rosteen
rosteen merged commit 4e0c822 into astropy:main Jun 17, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data objects Core data objects like Spectrum1D or SpectralCollection enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How do I apply shift_spectrum_to(radial_velocity=...) to a SpectrumCollection?

2 participants