-
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
expanded support of SB/Flux translations #2940
Conversation
jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py
Outdated
Show resolved
Hide resolved
…rt, styling changes
to not require spectrum, so nothing to centralize now. Fix devdeps Simplify flux_conversion logic and other minor fixes. Add flux conversion tests. Clarify which one should be reverted in the future
because moment map always in SB
jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.vue
Outdated
Show resolved
Hide resolved
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.
Are all the calls to reset_limits
still needed (I thought the limits were now being translated correctly)?
Translating |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2940 +/- ##
==========================================
- Coverage 88.78% 88.78% -0.01%
==========================================
Files 111 111
Lines 17276 17372 +96
==========================================
+ Hits 15338 15423 +85
- Misses 1938 1949 +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.
Just a few more comments and then I think this can go in and we can iterate as needed to build on top of it. Thanks for working through all of this!
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
After testing some more, I noticed that if we ever select the ST from the flux units, conversion from ST to any other flux seems to fail. |
I can't reproduce this, can you send me the traceback and I can track down where that is coming from |
It had to do with my env. I don't see it anymore after re-installing the branch. All good. |
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.
Here is technical review. I will do functional review next week once I know what was the conclusion from the 1PM meeting today with Cami w.r.t. UI changes. Thanks!
jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py
Outdated
Show resolved
Hide resolved
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.
Here is the rest of technical review since Kyle says I should unskip some files. 😆
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
self.app.data_collection[0] and | ||
self.app.config == 'specviz' | ||
): | ||
if check_if_unit_is_per_solid_angle(self.app.data_collection[0].get_object()._unit): |
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.
Are we confident that get_object()
would always return an object with _unit
attribute for the first loaded data? What assumption are we making here?
With all the talks about "free-form," are we shooting ourselves in our future foot?
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.
If there is a safer way to attain the units from the data item that keeps us more open to enable free-form in the future .
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.
Accessing a hidden _unit
(leading underscore usually hints that it is private and should not be used externally). I think you are basically trying to find flux unit, so any reason to not use a more public get_object().flux.unit
(since this is limited to specviz so you are getting Spectrum1D back). Where did _unit
come from anyway?
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 like it is buried within specutils class mixin. @rosteen , what is the difference between Spectrum1D._unit
and Spectrum1D.flux.unit
?
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.
It's not from the specutils class mixin as far as I can tell, I suspect it's inherited from a couple layers upstream. I'd just use flux.unit
.
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
|
||
yunit = _valid_glue_display_unit(flux_or_sb, self.spectrum_viewer, 'y') | ||
# may need to be updated if translations in other configs going to be supported | ||
if not self.flux_unit.choices and self.app.config == 'cubeviz': |
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.
Should this check happen much earlier in this method to avoid unnecessary computations?
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.
I don't see why it can't happen earlier, let me test it out earlier in the _on_flux_unit_changed
and I'll make the change bearing no behavioral change occurs!
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.
I do get an AttributeError: 'UnitConversion' object has no attribute 'flux_unit' if I move it further up. I can spend some time seeing if/what I can change the conditional to to have the same behavior.
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.
you can add a if not hasattr(self, 'flux_unit'): return
to the top of the method if you'd like. The observe on flux_unit_selected
can get triggered when the traitlet is created but before the plugin's init has created the flux_unit
object itself, and there's no need to run all this logic at that point.
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.
Does this mean self.flux_unit.choices
changes all the time throughout the logic in this method?
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.
I thought I had tried the not hasattr before, but irregardless that seemed to do the trick and it is now at the top of the function. Just running through tests locally now to make sure it.
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 flux_unit
can be created, but the self.flux_unit.choices
isn't populated yet causing one of the AttributeErrors, but the actually choices don't change once populated.
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py
Outdated
Show resolved
Hide resolved
In terms of functionality (part 2: otherviz):
|
Can you check on main and if its there as well, file a tech debt ticket please?
All of these are separate follow-up tickets already discussed and assigned. For aperture photometry, this will be limited to the results table displaying in the user-preferred units, with no need to convert SB<>flux.
This is by design - afaik, we don't have access to PIXAR_SR in pipeline extracted spectra. |
The 1D spectra from JWST come with 2 columns for flux, one in surface brightness and one in flux (I do not remember if this depends of the source being defined as point or extended). So technically, specviz has all the information to display one or the other. I will double check what it is actually loading...I do not remember anymore. |
@camipacifici , it is here: https://github.com/astropy/specutils/blob/a6fd06f975306b1c7a15337461e1e3873fe178a7/specutils/io/default_loaders/jwst_reader.py#L350-L360 Looks like specutils made the choice for you. |
That's what I thought, thank you! |
There was already a request in specutils to make the choice at load time in |
If we load both into glue (when loading from a file), we could easily swap out the columns... but we'll still need to handle detecting when we can and cannot do that. Perhaps an idea for future expansion? |
Performance seems normal on |
Can you give steps to reproduce? Is this only after changing the display units? That could be something to report upstream in glue if the units of the subset need to be mapped to the viewer or something. |
If no one else sees this, then never mind. |
I can't reproduce anything significant. Do you see the same thing on main when switching from wavelength to frequency for the spectral axis? If so, I think we can say this PR isn't to blame and investigate separately. |
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.
LGTM. Since Cami already has performance as a broad goal at some point, we can defer the lag I saw.
Description
This pull request is to address separating flux_or_sb_unit into flux_unit or sb_unit. Four total drop downs are now present in the Unit Conversion plugin (spectral unit, flux or surface brightness, flux unit, surface brightness unit).
Some units that are included in main for surface brightness/flux are incapable of being translated, and fail silently. These units have either been removed, or if one of these flux units is selected, conversion is capable within the same physical type, but translation is disabled until the unit is converted to a unit that is translatable.
Screen.Recording.2024-07-08.at.12.52.58.PM.mov
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.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.