Issue 1119 changing spectral axis#1136
Open
astrofle wants to merge 3 commits into
Open
Conversation
set_spectral_axis modifies the units, frame or Doppler convention of the spectrum. with_spectral_axis_unit adds the observer and target attributes back to the new spectrum object to make it compatible with dysh.spectra.Spectrum objects.
Adds set_spectral_axis to the user guide.
mpound
requested changes
Jun 24, 2026
mpound
left a comment
Collaborator
There was a problem hiding this comment.
The example fails for me because specutil.Spectrum.with_spectral_axis_unit uses velocity_convention as the keyword not doppler_convention so passing *args raises an exception.
Cell In[6], line 4
2 s1 = Spectrum.fake_spectrum()
3 s1.set_spectral_axis(unit="km/s", doppler_convention="radio") # Changes the Spectrum in place.
----> 4 s2 = s1.with_spectral_axis_unit("km/s", doppler_convention="optical") # Creates a new Spectrum.
File /bigdisk/src/dysh/src/dysh/spectra/spectrum.py:1101, in Spectrum.with_spectral_axis_unit(self, *args, **kwargs)
1100 def with_spectral_axis_unit(self, *args, **kwargs):
-> 1101 spec = super().with_spectral_axis_unit(*args, **kwargs)
1102 spec._observer = self.observer.copy()
1103 spec._spectral_axis.observer = self.spectral_axis.observer.copy()
TypeError: OneDSpectrumMixin.with_spectral_axis_unit() got an unexpected keyword argument 'doppler_convention'
specutils.__version is '2.3.0'
The tests pass, though.
53b397b to
22f426f
Compare
mpound
reviewed
Jun 28, 2026
| # Keep docstring empty to re-use the one from specutils. | ||
| # Keeping the specutils doc introduces yet another name | ||
| # for what we call `doppler_convention`, `velocity_convention`. | ||
| # This is a source of frustration... |
Collaborator
There was a problem hiding this comment.
Because specutils does not follow the astropy parameter name 'doppler_convention' in SpectralQuantity
mpound
reviewed
Jun 28, 2026
Collaborator
There was a problem hiding this comment.
Cell 6: sdfits["CTYPE1"][0] returns nan
Collaborator
There was a problem hiding this comment.
Also, sometimes notebook plots just hang but I don't belive that has anything to do with this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Spectrum set_spectral_axis and with_spectral_axis_unit (overloads the specutils method).
set_spectral_axismodifies the units, frame or Doppler convention of the spectrum.with_spectral_axis_unitadds the observer and target attributes back to the new spectrum object to make it compatible withdysh.spectra.Spectrumobjects.Example: