Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpectralCoord can't handle pixel units #1109

Open
jradavenport opened this issue Nov 17, 2023 · 0 comments
Open

SpectralCoord can't handle pixel units #1109

jradavenport opened this issue Nov 17, 2023 · 0 comments

Comments

@jradavenport
Copy link

When I have 2 Spectrum1D objects, which are not wavelength calibrated and have pixels for the spectral unit, I cannot do e.g. addition or subtraction of my spectra. This is an issue for doing things like co-adding spectra, doing sky subtraction, etc.

Here is a MRE:

from specutils import Spectrum1D
import numpy as np
import astropy.units as u
t1 = Spectrum1D(spectral_axis=np.arange(100)*u.pixel, flux=np.random.normal(size=100)*u.adu)
t2 = Spectrum1D(spectral_axis=np.arange(100)*u.pixel, flux=np.random.normal(size=100)*u.adu)
t1-t2

which throws this error:
UnitTypeError: SpectralCoord instances require units equivalent to '(Unit("Hz"), Unit("m"), Unit("J"), Unit("1 / m"), Unit("km / s"))', so cannot set it to 'pix'.

I believe the workaround here is to do:

t1.subtract(t2, compare_wcs=None)

Could we expose this easier to users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant