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 Spatial Collapsed Spectrum selection to Line Analysis #1583

Merged
merged 20 commits into from
Sep 8, 2022

Conversation

duytnguyendtn
Copy link
Collaborator

@duytnguyendtn duytnguyendtn commented Aug 18, 2022

Description

Previously, it was not possible to perform line analysis on the spectrum generated by Cubeviz' autocollapse for spatial subsets. This PR adds that feature.

BIG THANKS to @pllim for fixing the mysterious test failure!

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 change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set?
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@duytnguyendtn duytnguyendtn added this to the 2.9 milestone Aug 18, 2022
Comment on lines 104 to 108
self.spatial_subset = SubsetSelect(self,
'spatial_subset_items',
'collapsed_spectrum_selected',
default_text='Entire Cube Spectrum',
allowed_type='spatial')
Copy link
Member

Choose a reason for hiding this comment

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

I'd advocate for using the same traitlet names and default text as in model fitting so there is a consistent UX and API for the user between the two. If there are subtle differences that we want to capture in the UI, then the hint might be the easiest place to make that distinction. (Or we can always change model fitting to match if there is a good reason to make changes).

Copy link
Member

Choose a reason for hiding this comment

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

I'd still like to see this addressed/discussed before approving/merging!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was going to address this in my "review phase" now that the CI is passing. I think I've mellowed on my original intent, so I'm happy to switch it back! Let me do that first and I'll rerequest review

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not familiar with model fitting, so maybe @rosteen or @javerbukh would have opinions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Effectively the distinction I tried to make is between selecting the spatial subset itself, or the spectrum generated from the spatial subset. Effectively, it looks identical on the front end, but it's slightly different here in the backend

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kecnry I've reverted those changes so they should match; let me know if it's sufficient, or if I missed something!

Copy link
Member

Choose a reason for hiding this comment

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

I do see your point, but just really want to strive for self-consistency across plugins, especially with attribute names and options since we're looking to expose these directly in #1401. This still differs from model fittings spatial dropdown (which is the same use-case: acting on the spectrum corresponding to the referenced spatial subset), in that model fitting has "Entire Cube" and this has "Entire Cube Spectrum". I definitely think they should be the same, and personally would vote for "Entire Cube" and add any clarification to the user in the dropdown hint and/or docs. But if others prefer being more verbose, then let's also make the change to model fitting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh, I misinterpreted your concern to be about the actual traitlets, not realizing you were also concerned about the labeling. I can understand your concern; I'll revert the labeling as well and we can defer this discussion to another day

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I changed the default text/labeling as well. I reworked the hint to try and make it explicit. How does that look @kecnry ?

@duytnguyendtn duytnguyendtn force-pushed the linesubset branch 3 times, most recently from e9e3328 to 6566513 Compare August 19, 2022 21:58
@rosteen rosteen modified the milestones: 2.9, 2.10 Aug 24, 2022
@pllim pllim modified the milestones: 2.10, 2.11 Aug 26, 2022
@pllim pllim mentioned this pull request Sep 7, 2022
9 tasks
@pllim
Copy link
Contributor

pllim commented Sep 7, 2022

I rewrote your test and it passed on CI, so hopefully it will continue to pass and that wasn't a transient happy accident. 🤞

See duytnguyendtn#1

The original test case is perhaps too unrealistic to the point of triggering some edge case behavior where sometimes the calculation would give you a number and sometimes a NaN. I also found that even with the new test case, I need to reduce the width to avoid NaN.

TST: Use a slightly more realistic test case
@duytnguyendtn duytnguyendtn marked this pull request as ready for review September 7, 2022 17:21
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Minor change log typo aside, it did work as advertised while I was investigating the CI failure, so approving. Thanks!

CHANGES.rst Outdated Show resolved Hide resolved
Co-authored-by: P. L. Lim <[email protected]>
@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Base: 86.35% // Head: 86.37% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (8bb5178) compared to base (1c9fef2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1583      +/-   ##
==========================================
+ Coverage   86.35%   86.37%   +0.02%     
==========================================
  Files          94       94              
  Lines        9410     9417       +7     
==========================================
+ Hits         8126     8134       +8     
+ Misses       1284     1283       -1     
Impacted Files Coverage Δ
...igs/specviz/plugins/line_analysis/line_analysis.py 97.75% <100.00%> (+0.53%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +240 to +248
if self.config == 'cubeviz' and self.spatial_subset_selected != 'Entire Cube Spectrum':
# then we're acting on the auto-collapsed data in the spectrum-viewer
# of a spatial subset. In the future, we may want to expose on-the-fly
# collapse options... but right now these will follow the settings of the
# spectrum-viewer itself
full_spectrum = self.app.get_data_from_viewer('spectrum-viewer',
self.spatial_subset_selected)
else:
full_spectrum = self.dataset.selected_obj
Copy link
Member

Choose a reason for hiding this comment

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

this is currently duplicated logic from model fitting (I believe). That's probably fine for now, but if we start extending this pattern to more plugins, we should consider something like self.dataset.get_spatial_spectrum(self.spatial_subset_selected) to move the logic to a shared location.

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, thanks! (womp, womp, same CI failure that I thought was fixed by @pllim - as long as fixing that doesn't affect the implementation, I think this is ready to merge once CI passes).

@duytnguyendtn
Copy link
Collaborator Author

Oops something broke, one sec

@duytnguyendtn
Copy link
Collaborator Author

Ok that should fix it (at least it's passing locally). Let's merge once these tests pass

@duytnguyendtn duytnguyendtn merged commit e9df543 into spacetelescope:main Sep 8, 2022
@duytnguyendtn
Copy link
Collaborator Author

duytnguyendtn commented Sep 8, 2022

Thanks so much for the reviews @kecnry @pllim !!

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.

4 participants