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

Add option to calculate higher-order moments in velocity #2584

Merged
merged 13 commits into from
Dec 4, 2023

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Nov 29, 2023

This currently works for moment 1, but I need to add handling for higher orders since those will end up as m2/s2 (for order 2) and so on. Also still need to add tests.

@rosteen rosteen added this to the 3.9 milestone Nov 29, 2023
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b715b32) 91.51% compared to head (e23aacf) 91.53%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2584      +/-   ##
==========================================
+ Coverage   91.51%   91.53%   +0.02%     
==========================================
  Files         161      161              
  Lines       19542    19592      +50     
==========================================
+ Hits        17883    17934      +51     
+ Misses       1659     1658       -1     

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

@rosteen rosteen marked this pull request as ready for review November 30, 2023 20:51
@rosteen
Copy link
Collaborator Author

rosteen commented Nov 30, 2023

Tests added, docs updated, good to go (well, ready for review at least).

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.

Seems to work well! Just a few small suggestions and then I can take a final look!

@@ -62,6 +69,11 @@ def __init__(self, *args, **kwargs):

self.moment = None

self.output_unit = SelectPluginComponent(self,
Copy link
Member

@kecnry kecnry Dec 1, 2023

Choose a reason for hiding this comment

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

do we want this - and probably reference_wavelength as well - added to the user API (and docstring, and update tests)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call, I can do that after tagup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.py Outdated Show resolved Hide resolved
jdaviz/configs/cubeviz/plugins/moment_maps/moment_maps.vue Outdated Show resolved Hide resolved
@kecnry
Copy link
Member

kecnry commented Dec 1, 2023

This currently works for moment 1, but I need to add handling for higher orders since those will end up as m2/s2 (for order 2) and so on

Is this still the case?

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 1, 2023

This currently works for moment 1, but I need to add handling for higher orders since those will end up as m2/s2 (for order 2) and so on

Is this still the case?

No, the code works for arbitrary n_moment now.

@rosteen rosteen force-pushed the moments-like-tears-in-velocity branch from eaf0233 to ebc7a2f Compare December 1, 2023 19:59
@@ -35,6 +35,37 @@
></v-text-field>
</v-row>

<div v-if="n_moment > 0 && dataset_spectral_unit !== ''">
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little torn by the fact that this isn't checked for in the API at all, but I think that's probably ok since the idea is that the plugin APIs just let you modify inputs. Something like #2347 would address this concern in general. The other option would be to have changing n_moment to 0, automatically revert output_unit = 'wavelength' under-the-hood, but then that could be confusing from the UI-perspective to see it reset when setting a positive moment again.

Definitely doesn't need to hold up approval/merge, just wanted to leave a papertrail of thoughts.

@@ -51,6 +58,10 @@ class MomentMap(PluginTemplateMixin, DatasetSelectMixin, SpectralSubsetSelectMix
filename = Unicode().tag(sync=True)
moment_available = Bool(False).tag(sync=True)
overwrite_warn = Bool(False).tag(sync=True)
output_unit_items = List().tag(sync=True)
output_unit_selected = Unicode().tag(sync=True)
reference_wavelength = FloatHandleEmpty().tag(sync=True)
Copy link
Member

Choose a reason for hiding this comment

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

this defaults to zero, but since its the original value, does not result in a validation error on the input, and ultimately results in a traceback (to avoid infinites in the velocities) 🤔

We could have this update to the central value of the selected data/subset.. but then that could override a user-provided value unless we had some logic like we do for labels. I think our best bet for now is to validate the inputs at the "calculate" button-level (probably can be done on the vue-side since it just needs reference_wavelength, output_unit_selected and n_moment) and disable the button with explanation text (we usually use <span class="v-messages v-messages__message text--secondary" style="color: red !important"> for situations like this elsewhere).

Copy link
Contributor

@cshanahan1 cshanahan1 left a comment

Choose a reason for hiding this comment

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

i tested this out and it works as expected.

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 4, 2023

i tested this out and it works as expected.

Thanks!

@rosteen rosteen merged commit 90a7f61 into spacetelescope:main Dec 4, 2023
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants