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

BUG: Simple Aperture Photometry plugin to update when Subset updates #1447

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Jul 4, 2022

Description

This pull request is to ensure Simple Aperture Photometry plugin is aware of Subset that is updated after it is created, if relevant to calculations. Most things will not recalculate until user presses "Calculate" but the background is calculated "live" before the button is pressed. There are 3 dropdowns. The dataset dropdown already triggers all recalculations, so I don't think it is affected but this bug.

This patch fixes the following cases:

  1. When aperture is selected, editing the aperture Subset will cause: (a) background to update immediately in "Annulus" mode, and (b) the rest to update when pressing "Calculate".
  2. When background is from Subset, editing the background Subset till cause the background to update immediately.

Fixes #1443

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)?

@pllim pllim added the bug Something isn't working label Jul 4, 2022
@pllim pllim added this to the 2.7 milestone Jul 4, 2022
@github-actions github-actions bot added the imviz label Jul 4, 2022
@@ -249,6 +250,13 @@ def test_annulus_background(imviz_helper):
phot_plugin.bg_annulus_width = 5
assert_allclose(phot_plugin.background_value, 4.894003242594493)

# Move the last created Subset (ellipse) and make sure background updates
imviz_helper.app.session.edit_subset_mode.mode = ReplaceMode
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Devs, I am not familiar with the edit mode syntax, so please let me know if it is correct to test this way.

Would also be nice if you can tell me how to programmatically control which Subset to put in ReplaceMode.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

To programmatically set the subset in replace mode, you can do something like:

imviz_helper.app.session.edit_subset_mode.edit_subset = [imviz_helper.app.data_collection.subset_groups[0]]

@codecov
Copy link

codecov bot commented Jul 4, 2022

Codecov Report

Merging #1447 (6b8e0b9) into main (050b62d) will decrease coverage by 0.00%.
The diff coverage is 81.81%.

@@            Coverage Diff             @@
##             main    #1447      +/-   ##
==========================================
- Coverage   85.16%   85.15%   -0.01%     
==========================================
  Files          91       91              
  Lines        8359     8369      +10     
==========================================
+ Hits         7119     7127       +8     
- Misses       1240     1242       +2     
Impacted Files Coverage Δ
...imviz/plugins/aper_phot_simple/aper_phot_simple.py 91.83% <81.81%> (-0.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 050b62d...6b8e0b9. Read the comment docs.

@pllim pllim marked this pull request as ready for review July 4, 2022 22:08
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.

Confirmed that this fixes the two use-cases explained in the PR description.

Someday I'd like to see this type of logic supported directly in the subset dropdown component, but the implementation here is pretty lightweight as-is, so let's defer that until/unless another plugin needs something similar (basically plugin-callbacks when the underlying data of the selected object changes).

@kecnry kecnry merged commit 92a7c47 into spacetelescope:main Jul 6, 2022
@pllim pllim deleted the unbreak-my-subset branch July 6, 2022 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simple Aperture Photometry: Recalculation breaks after Subset is edited
3 participants