-
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
Spectrum1D translator update for NDCube version #36
Conversation
Codecov Report
@@ Coverage Diff @@
## master #36 +/- ##
==========================================
- Coverage 96.40% 94.77% -1.63%
==========================================
Files 15 15
Lines 1002 1034 +32
==========================================
+ Hits 966 980 +14
- Misses 36 54 +18
Continue to review full report at Codecov.
|
@javerbukh it would be great if you could test this out with your Edit: see javerbukh/jdaviz#7 |
Are you able to load data with this branch and jdaviz#547 + your additions? |
I am. You also need the dev version of |
Ah, gotcha. |
Excellent. What about the data looks off? The only problem I noticed initially was that the slider is broken (which isn't a If you could also check that the data round-trips correctly by pulling it back out into the notebook, that would probably be sufficient for this PR. |
Looks like RA and Dec are flipped: https://jdaviz.readthedocs.io/en/latest/cubeviz/displaycubes.html#defining-spatial-regions |
Ah, right, they probably are. Could you install specutils from astropy/specutils#822 and see if that fixes the RA/Dec swap? Lots of dev versions/PRs to get this all working nicely at the moment, unfortunately. |
That works! I'll have to update the jdaviz PR to have the slider use the correct axis. |
@astrofrog @eteq I can't tag reviewers here, would one of you take a look at this and approve/merge if it looks good to you (or comment if it doesn't)? I believe the non-codecov test failures are due to failed tox invocations, not something due to this PR. Of course now that I mention codecov...I should add a test of round tripping a 3d Spectrum1D. I'll see if I have time for that today. |
0278e6e
to
7e2cc09
Compare
Codecov is angry because the added tests don't run right now, since they require NDCube 2.0. |
7e2cc09
to
48a4fbe
Compare
Can we merge? |
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.
Looks good in general, just a couple of requests
# Glue expects spectral axis first for cubes (opposite of specutils). | ||
# Swap the spectral axis to first here. to_object doesn't need this because | ||
# Spectrum1D does it automatically on initialization. | ||
if len(obj.flux.shape) == 3: |
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.
What about cases where the data has 2 dimensions? (for example a 2D spectrum)
CHANGES.rst
Outdated
0.1 (2020-09-17) | ||
---------------- | ||
|
||
- Initial release |
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.
Could you rebase so as not to include this commit? You'll then need to add a 0.3 section and a changelog entry.
else: | ||
# Don't use the dummy GWCS created by Spectrum1D initialized with spectral_axis | ||
if isinstance(obj.wcs, GWCS): | ||
data = Data(coords=SpectralCoordinates(obj.spectral_axis)) |
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.
We don't really need this anymore, Data coords can be a GWCS as far as I know.
data['flux'] = obj.flux | ||
data.get_component('flux').units = str(obj.unit) | ||
|
||
# Glue expects spectral axis first for cubes (opposite of specutils). |
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.
In addition to the above comments it would be good to clarify here whether you mean for the WCS or Numpy array. The data array and WCS will have axes in opposite order - spectral cubes read with plain Astropy FITS and WCS or with SpectralCube are often stored in spectral,dec,ra for the Numpy data array and ra,dec,spectral for the WCS.
Glue can handle any axis order as long as x_att and y_att are set correctly but it would indeed be good to make sure SpectralCube and Spectrum1D return a similar glue data object.
Fix to use SpectralCoordinate
Working on better 3D Spectrum1D tests
Finish setting up new Spectrum1D tests Fix codestyle errors Allow test to run on 2.0.dev
I have rebased this and will merge and address my comments in a follow-up PR (I need to make further changes to this to support 2D Spectrum1D instances. |
48a4fbe
to
7a01dbf
Compare
The test failure with dev dependencies is related as I think it's a recent change in specutils but I will merge and address in a separate PR. |
@astrofrog , I think this causing failure in jdaviz dev job, see spacetelescope/jdaviz#821 . |
This updates the
Spectrum1D
translator to handle 3DSpectrum1D
objects, currently applicable to the dev version ofspecutils
which subclassesSpectrum1D
off ofNDCube
. I also tested with the current releases ofspecutils
andjdaviz
and this doesn't break back-compatibility, so it should be fine to merge it now.This also supersedes #29 .