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

spectral extraction: live-preview and export of background spectrum #1682

Merged
merged 4 commits into from
Oct 19, 2022

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Sep 28, 2022

Description

This pull request adds live-visualization and export (UI and API) support for the 1D spectrum representing the background region within the spectral extraction plugin.

NOTE: this requires astropy/specreduce#143 (until then, the new test coverage will fail)

Rendered updated plugin docs

Screen.Recording.2022-09-28.at.12.51.06.PM.mov

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.

New Features > Specviz2d:

Spectral extraction plugin now supports visualizing and exporting the 1D spectrum associated with the background region.

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?
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 2.11 milestone Sep 28, 2022
@kecnry kecnry force-pushed the spec-extract-bg-spec branch from 78863b2 to 414c479 Compare September 28, 2022 17:04
@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Base: 87.63% // Head: 87.64% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (9652679) compared to base (8667847).
Patch coverage: 92.30% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1682   +/-   ##
=======================================
  Coverage   87.63%   87.64%           
=======================================
  Files          95       95           
  Lines       10131    10154   +23     
=======================================
+ Hits         8878     8899   +21     
- Misses       1253     1255    +2     
Impacted Files Coverage Δ
...plugins/spectral_extraction/spectral_extraction.py 90.66% <92.30%> (+0.03%) ⬆️

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.

@kecnry kecnry force-pushed the spec-extract-bg-spec branch 3 times, most recently from 7b8582d to 3d6ae9b Compare September 29, 2022 19:25
@kecnry kecnry marked this pull request as ready for review October 4, 2022 20:56
@kecnry kecnry force-pushed the spec-extract-bg-spec branch 3 times, most recently from 0eb2392 to af873d4 Compare October 7, 2022 15:11
@camipacifici
Copy link
Contributor

How about a thicker solid line for the extracted spectrum and a thin solid line for the background spectrum?

@kecnry
Copy link
Member Author

kecnry commented Oct 10, 2022

@camipacifici @PatrickOgle - I actually like the thinner line idea, what do you think? (Here are videos for the dotted and thin styling and how they both react to zooming)

Screen.Recording.2022-10-10.at.2.48.12.PM.mov
Screen.Recording.2022-10-10.at.2.51.36.PM.mov

@camipacifici
Copy link
Contributor

I like the thin line too!

@rosteen rosteen modified the milestones: 2.11, 3.1 Oct 10, 2022
Copy link
Contributor

@ojustino ojustino left a comment

Choose a reason for hiding this comment

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

The code changes seem reasonable to me. A few observations:

  1. I am fine with the solid line, too. However, depending on the placement of the initial background region(s), it may not be noticeable if you aren't already looking for it. How do you feel about giving it a different color?

  2. When I choose the "Manual" option, I don't see a preview line and the 2D viewer takes 2-3 seconds to adjust when I change the center pixel. (The lag is also present in main.) Exporting a spectrum having chosen "Manual" brings up the "background regions overlapped" error from specreduce. "TwoSided" and "OneSided" are snappy and don't raise any errors for me.

  3. Sometimes when I export the background 1D spectrum and then scroll up to change its appearance in Plot Options, the preview line persists in the 1D viewer:

image

The preview disappears if I scroll back into the Trace or Extraction sections of the Spectral Extraction plugin, so it looks like the trigger is leaving the Spectral Extraction plugin without registering a mouse move (e.g., pressing "Extract" and immediately scrolling up). I'm not sure how many would run into this but thought I'd mention it.

docs/specviz2d/plugins.rst Outdated Show resolved Hide resolved
docs/specviz2d/plugins.rst Outdated Show resolved Hide resolved
@kecnry
Copy link
Member Author

kecnry commented Oct 13, 2022

How do you feel about giving it a different color?

I would like to avoid this, if possible. We use the same color for all "temporary" previews from plugins at the moment.

When I choose the "Manual" option, I don't see a preview line and the 2D viewer takes 2-3 seconds to adjust when I change the center pixel.

I've come across this a few times as well, but is unrelated to this PR (feel free to open an issue if one doesn't already exist).

Sometimes when I export the background 1D spectrum and then scroll up to change its appearance in Plot Options, the preview line persists in the 1D viewer

I suspect the mousemove isn't triggering a change in the "section", but so long as the plugin is opened, I would expect the previews to stay visible, in general. If you moused over a different "section" of the plugin and that wasn't registered, then that may be a bug, although again unrelated to this PR.

@kecnry kecnry requested a review from bmorris3 as a code owner October 13, 2022 17:16
@kecnry kecnry force-pushed the spec-extract-bg-spec branch from 8d6cb8e to 9dfdefb Compare October 13, 2022 17:18
@ojustino
Copy link
Contributor

When I choose the "Manual" option, I don't see a preview line and the 2D viewer takes 2-3 seconds to adjust when I change the center pixel.

I've come across this a few times as well, but is unrelated to this PR (feel free to open an issue if one doesn't already exist).

I can see how the lag is unrelated, but do you have thoughts on the "Manual" type's lack of a live preview line and the error upon exporting a spectrum?

@kecnry
Copy link
Member Author

kecnry commented Oct 13, 2022

but do you have thoughts on the "Manual" type's lack of a live preview line and the error upon exporting a spectrum?

Addressed in #1737 (and independently upstream in astropy/specreduce#146). Good catch!

@kecnry kecnry force-pushed the spec-extract-bg-spec branch from 9dfdefb to 2f801b4 Compare October 13, 2022 19:11
Copy link
Contributor

@ojustino ojustino left a comment

Choose a reason for hiding this comment

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

Great, I merged this branch with #1737 and the result fixes both the lag and export error issues with using a "Manual" trace for the background.

Would you consider adjusting the starting pixel for the trace when you select the "Manual" background type? With the image in the example notebook, it starts on the cross-dispersion pixel with the highest flux. This scenario exacerbates the color issue I mentioned earlier since the background's live preview starts off with more flux than the extraction's live preview.

I'll create a separate issue for the persisting preview line.

@kecnry
Copy link
Member Author

kecnry commented Oct 14, 2022

Would you consider adjusting the starting pixel for the trace when you select the "Manual" background type? With the image in the example notebook, it starts on the cross-dispersion pixel with the highest flux.

Yes, this currently starts at the same default position that is determined for the initial trace, which probably isn't ideal. I put a proposed improvement to that logic in #1738 (seemed like it should have its own change log entry since it isn't directly related to this PR, even though they're both dealing with the background subtraction step).

Copy link
Contributor

@ojustino ojustino left a comment

Choose a reason for hiding this comment

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

Now that the tests are passing and the spinoff issues are underway, I say this branch is ready for a merge.

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.

Just a very minor nitpick. Code looks like code but should second approval come from a PO?

CHANGES.rst Show resolved Hide resolved
@pllim
Copy link
Contributor

pllim commented Oct 19, 2022

Ooops change log has conflict now.

@kecnry kecnry force-pushed the spec-extract-bg-spec branch from 0901564 to bad9681 Compare October 19, 2022 17:38
@kecnry kecnry force-pushed the spec-extract-bg-spec branch from bad9681 to 9652679 Compare October 19, 2022 19:33
@kecnry kecnry merged commit a64f1a5 into spacetelescope:main Oct 19, 2022
@kecnry kecnry deleted the spec-extract-bg-spec branch October 19, 2022 20:31
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.

5 participants