-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix bug in translating 3D Spectrum1D with only spectral axis defined #61
Conversation
…(rather than full WCS)
Codecov Report
@@ Coverage Diff @@
## main #61 +/- ##
==========================================
- Coverage 95.80% 94.56% -1.24%
==========================================
Files 15 15
Lines 1145 1123 -22
==========================================
- Hits 1097 1062 -35
- Misses 48 61 +13
Continue to review full report at Codecov.
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@astrofrog I was working on the route you suggested of using NDCube's |
This comment was marked as resolved.
This comment was marked as resolved.
Okay. I got it. With this PR, it works if I pass in only the flux like this |
https://github.com/glue-viz/glue-astronomy/blob/7f3229d01bdc2bff64fdb1a83738447cf696c59d/glue_astronomy/translators/tests/test_spectrum1d.py#L204-#234 |
Is there a way to push this forward? I need this for spacetelescope/jdaviz#1040 . |
I could go ahead with adapting the tests, but @astrofrog and I are quite uncertain at this point what the logic of reordering axes here again is. specutils as far as I see it is consistent in using the last dimension as spectral axis, so it's rather confusing to have the glue loader swap this again, and (only?) for [G]WCS spectra. |
In our FITS data, the spectral axis seems to be in NAXIS3, which in Python-speak, is |
|
Yes, I think @rosteen mentioned that it would be nice if specutils is flexible enough to allow specutils in whatever axis but that's unlikely to happen any time soon. :( |
def world_axis_names(self): | ||
return (UCD_TO_SPECTRAL_NAME[self.spectral_wcs.world_axis_physical_types[0]], 'Offset') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing the label
of the returned components in the 2d example to 'World 0'
,'World 1'
, breaking test_spectrum1d_2d_data
further down. Maybe the new naming is more logical, but that should be documented somewhere (and at least World 1
does not sound like an improvement over Frequency
).
85f121c
to
312a840
Compare
@rosteen I have changed the expected labels in the test for now, so it can progress further, but does not necessarily mean they should remain like this. |
What does this error mean?
|
Per my speculation above, it's two levels further down ;-)
This apparently already when trying to access the |
Definitely something is still wonky here, unfortunately. Even if you ignore the >>> s, o = data.coords.pixel_to_world(1, 2)
AttributeError: 'PaddedSpectrumWCS' object has no attribute 'pixel_to_world' and >>> px, py = data.coords.world_to_pixel(s, o)
AttributeError: 'PaddedSpectrumWCS' object has no attribute 'world_to_pixel' The |
Maybe subclassing from |
Yea, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per PO feedback at sprint review today, they want the spectral axis to be dimensionless rather than pixels. Is it possible to do that upstream here? If not, I'll have to hack something up downstream in Jdaviz.
def __init__(self, spectral_wcs, n_extra_axes): | ||
self.spectral_wcs = spectral_wcs | ||
frame1 = CoordinateFrame(n_extra_axes, ['SPATIAL']*n_extra_axes, | ||
np.arange(n_extra_axes), unit=[u.pix]*n_extra_axes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.arange(n_extra_axes), unit=[u.pix]*n_extra_axes, | |
np.arange(n_extra_axes), unit=[u.dimensionless_unscaled]*n_extra_axes, |
np.arange(n_extra_axes), unit=[u.pix]*n_extra_axes, | ||
name="Dummy1") | ||
frame2 = CoordinateFrame(n_extra_axes, ['SPATIAL']*n_extra_axes, | ||
np.arange(n_extra_axes), unit=[u.pix]*n_extra_axes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.arange(n_extra_axes), unit=[u.pix]*n_extra_axes, | |
np.arange(n_extra_axes), unit=[u.dimensionless_unscaled]*n_extra_axes, |
I seem to remember a decision specifically not to handle dimensionless "spectral" axes in specutils, with the compromise that we'd handle pixel units. I could be remembering wrong though, I'll look back through some notes/git discussion. Btw, thanks @dhomeier and @pllim for looking at this, I left it in a state where I'd run into the limit of my WCS knowledge. I'm trying to find time this sprint to get back to it. |
Okay, just keep it as pixel here. I dealt with that part downstream. Thanks! |
This can be closed without merged. Superseded by #68 |
Description
If a 3D flux is input to a
Spectrum1D
along with aspectral_axis
(rather than a full 3D WCS), the resulting object will have a spectral GWCS of only one dimension. Personally I think this behavior is not ideal and might need rethinking at some point, but in either case this fix will stop the translator from trying to swap axes on the WCS in this case, thus fixing (I hope) the bug @pllim ran into in spacetelescope/jdaviz#1040 (comment).Fixes #60