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

Moment units redux #2588

Merged
merged 13 commits into from
Dec 14, 2023
Merged

Moment units redux #2588

merged 13 commits into from
Dec 14, 2023

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Dec 5, 2023

Updates the recent Moment Maps unit work to better align with PO specs by displaying the actual physical units (including flux units for moment 0), and giving the option to reduce all higher moments to velocity rather than velocity^N.

@kecnry
Copy link
Member

kecnry commented Dec 5, 2023

Looks like tests need updating for the new reduced units. The TypeError: __init__() got an unexpected keyword argument 'out' error is unrelated though and caused by the recent release of glue/glue-jupyter.

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 5, 2023

I'm also still debugging something I found after opening the PR, I'll fix tests once I'm done that.

@rosteen rosteen added this to the 3.9 milestone Dec 5, 2023
@rosteen
Copy link
Collaborator Author

rosteen commented Dec 5, 2023

Here's a quick demo of what this looks like now:

Screen.Recording.2023-12-05.at.4.12.10.PM.mov

Comment on lines +149 to +177
# Filter what we want based on n_moment
if self.n_moment == 0:
self.output_radio_items = [self.output_unit_items[0],]
elif self.n_moment == 1:
self.output_radio_items = self.output_unit_items[1:3]
else:
self.output_radio_items = self.output_unit_items[2:]
Copy link
Member

Choose a reason for hiding this comment

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

how does this look to the user using the API?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The user still sees the full options list in the API.

Copy link
Member

Choose a reason for hiding this comment

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

If anything isn't valid, we should raise errors in calculate_moment then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a check for that.

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

One fix below.

jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py Outdated Show resolved Hide resolved
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.

This seems quite intuitive from the UI when changing moment (it remembers the user selection when it still exists, but defaults to a new value when it doesn't).

Screen.Recording.2023-12-07.at.12.46.54.PM.mov

From the API, there are still a few weird cases, but those handled by the error checking in calculate_moment, which should be sufficient.

Comment on lines 87 to 89
# Initialize extra key in items dictionary
for item in self.output_unit_items:
item["unit_str"] = ""
Copy link
Member

Choose a reason for hiding this comment

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

this might not be necessary since vue should handle the key missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like you're right, I'll remove this.

jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py Outdated Show resolved Hide resolved
@click:action="calculate_moment"
></plugin-add-results>

<v-row v-if="n_moment > 0 && output_unit_selected === 'Velocity' && reference_wavelength === 0">
<v-row v-if="n_moment > 0 && output_unit_selected !== 'Spectral Unit' && reference_wavelength === 0">
<span class="v-messages v-messages__message text--secondary" style="color: red !important">
Cannot calculate moment: Must set reference wavelength for output in velocity units.
Copy link
Member

Choose a reason for hiding this comment

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

I can get this same error message by setting n_moment to 1 and output_unit to Flux... granted that is only possible by the UI, so I'm not sure its worth an extra case here to show the correct error message or not.

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (97fcb2d) 91.55% compared to head (5beaede) 91.54%.
Report is 1 commits behind head on main.

Files Patch % Lines
...configs/cubeviz/plugins/moment_maps/moment_maps.py 97.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2588      +/-   ##
==========================================
- Coverage   91.55%   91.54%   -0.01%     
==========================================
  Files         161      161              
  Lines       19842    19932      +90     
==========================================
+ Hits        18166    18247      +81     
- Misses       1676     1685       +9     

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

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.

One comment remaining above, but I won't insist if it isn't easy! Thanks!

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 7, 2023

One comment remaining above, but I won't insist if it isn't easy! Thanks!

I added a separate case in the vue template for this, good suggestion to make this more accurate.

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

Approving so that my prior requested-changes do not block merge.

rosteen and others added 2 commits December 14, 2023 10:51
@rosteen rosteen merged commit dfaf076 into spacetelescope:main Dec 14, 2023
13 of 15 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants