Skip to content
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

Update the mouse over units by listening to the unit-conversion plugin #2931

Merged
merged 18 commits into from
Jul 30, 2024

Conversation

haticekaratay
Copy link
Contributor

@haticekaratay haticekaratay commented Jun 28, 2024

Description

This pull request adds the functionality for the mouse over on the image viewers to listen to the unit conversion plugin.

Screenshot 2024-07-26 at 11 08 25 PM Screenshot 2024-07-26 at 11 08 43 PM

Fixes #

Change log entry

  • Is a change log needed? If yes, is it added to 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, maintainer
    should 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.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@github-actions github-actions bot added imviz plugin Label for plugins common to multiple configurations labels Jun 28, 2024
@haticekaratay haticekaratay added this to the 4.0 milestone Jul 12, 2024
@haticekaratay haticekaratay changed the title WIP: Respond to changed unit and display on the UI Update the mouse over units by listening to the unit-conversion plugin Jul 25, 2024
@rosteen
Copy link
Collaborator

rosteen commented Jul 26, 2024

It looks to me like the remaining test failures are because current_unit is getting initialized to MJy/sr, so if no unit conversion is done that's the unit getting shown in the label no matter what the unit of the data is. So you're getting things like moments in km/s getting shown in the coord info display with the correct value, but MJy/sr for the unit.

@haticekaratay haticekaratay marked this pull request as ready for review July 27, 2024 03:12
Copy link

codecov bot commented Jul 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.91%. Comparing base (143cd8d) to head (14928f6).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2931      +/-   ##
==========================================
+ Coverage   88.78%   88.91%   +0.12%     
==========================================
  Files         111      111              
  Lines       17372    17386      +14     
==========================================
+ Hits        15424    15459      +35     
+ Misses       1948     1927      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jdaviz/utils.py Outdated Show resolved Hide resolved
@gibsongreen
Copy link
Contributor

gibsongreen commented Jul 29, 2024

The code is clean and the tests make sure the data is being converted from sb to sb. The only thing that I’m seeing is what Ricky pointed out.

There is one thing that I hadn’t considered and so definitely not in the scope of your ticket. When we create subsets, depending on what viewer it I would think we would want the unit of that subset to be based on what viewer it was created in. Right now I think it is listening to that data collection (which doesn’t update from conversions or translation). That could get messy if the user creates subsets with a bunch of different units, but I'll look into this.

jdaviz/utils.py Outdated Show resolved Hide resolved
jdaviz/utils.py Outdated Show resolved Hide resolved
jdaviz/utils.py Outdated Show resolved Hide resolved
jdaviz/utils.py Show resolved Hide resolved
value = self._get_cube_value(
image, arr, x, y, viewer
)
if self.current_unit is not None and self.current_unit.is_equivalent(unit):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be the logic that keeps velocity mouseover working for moment maps. Just a note that we'll need to rethink this if/when we have velocity display units as well, since we'll then need to have per-viewer image units based on each viewers "physical type" and its corresponding display units 🤔

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thanks!

Comment on lines -282 to +286
self.hub.broadcast(GlobalDisplayUnitChanged('flux',
flux_or_sb,
sender=self))
self.hub.broadcast(
GlobalDisplayUnitChanged(
"flux" if name == "flux_unit_selected" else "sb", flux_or_sb, sender=self
)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibsongreen - does this affect you in #3111? Will we need to emit messages for (flux AND surface brightness) OR (solid angle AND surface brightness)?

Copy link
Contributor

@gibsongreen gibsongreen Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it will be solid_angle and flux, but in my PR solid_angle isn't computed/changed in this function currently (since it is either /sr if surface brightness, or, / pix is the cube loaded is flux (which really should spaxel). Right now it is computed here:

self.angle_unit.choices = create_angle_equivalencies_list(dc_unit)

When enabling changes to the solid_angle unit then there would be addition of something like solid_angle_unit_selected that would need to be observed in this function

Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now, thanks!

jdaviz/configs/imviz/plugins/coords_info/coords_info.py Outdated Show resolved Hide resolved
@haticekaratay haticekaratay merged commit a126296 into spacetelescope:main Jul 30, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imviz plugin Label for plugins common to multiple configurations Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants