-
Notifications
You must be signed in to change notification settings - Fork 75
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
Unit conversion: Specviz silently ignoring spectrum with almost compatible units #2459
Comments
The What did you expect should happen? An outright traceback? |
I would have expected a warning. The logger was all green. |
Actually the fix would have to be deep in glue-core. The unit conversion happens here: And I think this silently skips any incompatible unit: xref glue-viz/glue#2296 |
That said, we could probably have a workaround in our own parser to check unit in advance and throw exception, but I feel like that defeats the purpose of glue-core implementation. |
This might be an issue beyond just unit conversion that in general incompatible layers are not really indicated in any way? (basically whether the layer artist |
You mean it is automatically matched to the template spectrum in However as @pllim pointed out, |
So should |
All sensible (or rather physically possible) unit conversions seem already enabled, e.g. if I manually set the template as I_lambda spec_unit = u.Unit('erg / (cm^2*s*Angstrom*steradian)')
# Create Spectrum1D object
template = Spectrum1D(spectral_axis=(template['col1'] * u.Angstrom).to(u.um),
flux=template['col2'] * 1E8 * template['col1']**-2 * spec_unit) it is correctly plotted with |
@dhomeier , do you have any idea how to do that in a way that is acceptable by glue-core? I don't want to waste time working on a patch only to find out it is too specific to Jdaviz or something. |
I think warnings about incompatible units would be generally useful enough, just not sure how to communicate them to the
I suppose that could also be generally useful enough, though I don't know how such exceptions would typically look like. |
@dhomeier , you are right. I cannot get warning or exception to raise from that line. Now I question reality. Digging more. |
Okay, sorry that I led you down the wrong rabbit hole. It turns out we never link the flux anyway, so the converter is not getting used (as far as I can understand). This might be something we have to patch here in Jdaviz after all. Here is a minimal test case: from astropy import units as u
from specutils import Spectrum1D
from jdaviz import Specviz
wav = [1.1, 1.2, 1.3] * u.um
sp1 = Spectrum1D(flux=[1, 1.1, 1] * (u.MJy / u.sr), spectral_axis=wav)
sp2 = Spectrum1D(flux=[1, 1, 1.1] * (u.MJy), spectral_axis=wav)
flux3 = ([1, 1.1, 1] * u.MJy).to(u.erg / u.s / u.cm / u.cm / u.AA, u.spectral_density(wav))
sp3 = Spectrum1D(flux=flux3, spectral_axis=wav)
specviz = Specviz()
specviz.show()
specviz.load_data(sp2, data_label="2") # OK
specviz.load_data(sp1, data_label="1") # Not OK
specviz.load_data(sp3, data_label="3") # OK |
@astrofrog or @dhomeier , is #2485 sufficient or is there a better way? |
Reporter: Camilla Pacifici
I am playing with the redshift notebook to include unit conversion in specviz.
The observed spectrum is in
MJy/sr
which is almost compatible withf_lam
units (erg/s/cm2/A
). If I pass the observed spectrum to Specviz first and then a template spectrum inf_lam
, Specviz silently accepts the spectrum (it is in the data menu), but it does not visualize it.If I pass the observed spectrum in Jy, everything works beautifully!
🐱
DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter.
The text was updated successfully, but these errors were encountered: