-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
BUG: Fix wrong Subset unit when created in 2D spectrum viewer #3201
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b1a3031
BUG: Fix wrong Subset unit in Specviz2d
pllim 9dc6d6e
Add test and change log
pllim fe250fa
cubeviz is so special
pllim e4d6311
Address comment from kecnry
pllim 3e501c0
Merge branch 'main' into specviz2d-subset-unit
pllim eafb391
Move change log to match new milestone
pllim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import pytest | ||
import stdatamodels | ||
from astropy import units as u | ||
from astropy.io import fits | ||
from astropy.utils.data import download_file | ||
from glue.core.edit_subset_mode import NewMode | ||
from glue.core.roi import XRangeROI | ||
|
||
from jdaviz.utils import PRIHDR_KEY | ||
from jdaviz.configs.imviz.tests.utils import create_example_gwcs | ||
|
@@ -134,6 +137,25 @@ def test_2d_1d_parser(specviz2d_helper, mos_spectrum2d, spectrum1d): | |
specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d, spectrum_1d=spectrum1d) | ||
assert specviz2d_helper.app.data_collection.labels == ['Spectrum 2D', 'Spectrum 1D'] | ||
|
||
spec2d_viewer = specviz2d_helper.app.get_viewer("spectrum-2d-viewer") | ||
assert spec2d_viewer.figure.axes[0].label == "x: pixels" # -0.5, 14.5 | ||
spec2d_viewer.apply_roi(XRangeROI(10, 12)) | ||
|
||
spec2d_viewer.session.edit_subset_mode._mode = NewMode | ||
|
||
spec1d_viewer = specviz2d_helper.app.get_viewer("spectrum-viewer") | ||
assert spec1d_viewer.figure.axes[0].label == "Wavelength [Angstrom]" # 6000, 8000 | ||
spec1d_viewer.apply_roi(XRangeROI(7000, 7100)) | ||
|
||
# Subset 1 should follow Spectrum 2D viewer unit. | ||
# Subset 2 should follow Spectrum 1D viewer unit. | ||
subsets = specviz2d_helper.app.get_subsets() | ||
assert len(subsets) == 2 | ||
s1 = subsets["Subset 1"] | ||
s2 = subsets["Subset 2"] | ||
assert s1.lower.unit == s1.upper.unit == u.pix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirmed that this line throws exception on
|
||
assert s2.lower.unit == s2.upper.unit == u.AA | ||
|
||
|
||
def test_parser_no_data(specviz2d_helper): | ||
with pytest.raises(ValueError, match='Must provide spectrum_2d or spectrum_1d'): | ||
|
Oops, something went wrong.
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.
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 have used the API from #3104 but since it is not merged yet, I didn't.
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.
#3104 is now merged but the API is not yet public. Should I keep this as-is or should I use the
helper.plugins['Subset Tools']._obj.import_region(...)
syntax here?