-
Notifications
You must be signed in to change notification settings - Fork 79
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
Cubeviz spectral regions fixes #1046
Conversation
This is ready for review, but will require astropy/specutils#911 for the tests to pass. I'm hoping to do a specutils release early next week so we can merge this before the end of the week. |
Should I withhold review until specutils is released then? |
I was thinking that it's reviewable now, we can just wait to hit the merge button until tests pass. |
But we have to install astropy/specutils#911 to review this, right? |
No, unless you have an overriding urge to use the Unit Conversion plugin to change units to frequency space before testing it. |
Oh, you mean this? 😸 |
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.
Seems to work well and as expected (pending tests passing) and is definitely a huge improvement over returning a messy nested object.
Note that the scope here only applies to spectral regions - image regions work when adding multiple subregions but still break when using "remove" logic, for instance.
jdaviz/app.py
Outdated
continue | ||
elif subset_type == "spatial" and this_type == RangeSubsetState: | ||
continue | ||
if subset_type == "spectral" or viewer_reference == "spectrum-viewer": |
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.
is hardcoding the viewer-reference string ever going to cause issues (also in line 618)? (See #1038, for example). As far as I can tell, we always currently use "spectrum-viewer" for spectrum viewers. We could check if viewer
is a SpecvizProfileView
instance, but I'm not sure if that's better or not.
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 long as @havok2063 does not overwrite this on MAST side, we should be 99% safe...
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 currently don't override anything within the viewer-area
section of the configurations. I don't think we have any plans to but one never knows. Items in settings
, toolbar
, and tray
we do reconfigure.
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.
Checking for SpecvizProfileView
seems like it's probably the more stable solution for now.
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.
Actually, better to look for BqplotProfileView
. I'll make that change shortly.
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.
Is Cubeviz moment map plugin the only thing affected by this? Seems like a very significant change. No other plugins currently access this API and expecting the old object class?
CHANGES.rst
Outdated
@@ -30,6 +30,9 @@ Bug Fixes | |||
Cubeviz | |||
^^^^^^^ | |||
|
|||
- Subsets from the spectrum viewer are now returned as SpectralRegion objects, and |
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.
The first entry is technically API change, not just a bug fix. I propose we split this entry into different "API change" and "Bug fix" entries.
temp_data = self.get_data_from_viewer(viewer_reference, value.label) | ||
if isinstance(temp_data, Spectrum1D): | ||
# Note that we look for mask == False here, rather than True above, | ||
# because specutils masks are the reverse of Glue (of course) |
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.
FWIW, specutils
at least follows Numpy masked array convention (where mask==True
means the pixel is masked). 🤷
p.s. You said this fixes "multiple subregions" use case. Maybe add a test for that? 😅 Thanks! |
25c0e73
to
3211fbd
Compare
@pllim I merged your suggestions and added a test for a two-region Subset, as well as updating the specutils pin to the new release. I think this is good for final review. |
There is a conflict in the change log, so this needs rebasing. Thanks! |
3211fbd
to
e445fbd
Compare
Rebased! |
Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Fix codestyle
e445fbd
to
0cd349d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1046 +/- ##
==========================================
+ Coverage 74.03% 74.22% +0.18%
==========================================
Files 75 75
Lines 5639 5637 -2
==========================================
+ Hits 4175 4184 +9
+ Misses 1464 1453 -11 ☔ View full report in Codecov by Sentry. |
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.
Works as advertised. Thanks!
Description
This allows Cubeviz to successfully return spectral regions with multiple subregions via
app.get_subsets_from_viewer
. It also makes the returned spectral regions from CubevizSpectralRegion
s, to match the output when the method is used in Specviz. Some changes were also required to the moment maps plugin to work with this change - the rest of the plugins seemed ok, but I'm leaving this as draft for now because I think this may be a good time to make one or two other subset-related tweaks to the moment maps UI (and potentially other plugins).Fixes #959
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.CHANGES.rst
?