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

Aperture validate after selection #2684

Merged

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Jan 31, 2024

Description

This pull request allows non-apertures as choices in subset dropdowns for aperture photometry and spectral extraction and validates them during selection (or on a change to the underlying subset) with the following behavior:

  • aperture photometry's aperture: only allow apertures (no composite, no annulus) and disable the compute button when not valid
  • aperture photometry's background: allow any subset (in the future if we implement active sections, highlighting will not be done for non-apertures)
  • spectral extraction's aperture: non-apertures disable wavelength dependence (for aperture and background) and subpixel support, with in-plugin warnings
  • spectral extraction's background: non-apertures disable wavelength dependence (background only) and subpixel support, with in-plugin warnings

TODO:

  • raise errors in compute methods, when necessary (including batch aper phot)
  • test/update multiselect support
  • test coverage
Screen.Recording.2024-01-31.at.1.43.40.PM.mov
Screen.Recording.2024-01-31.at.1.52.54.PM.mov
Screen.Recording.2024-01-31.at.2.09.39.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.

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? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 3.9 milestone Jan 31, 2024
@github-actions github-actions bot added cubeviz imviz plugin Label for plugins common to multiple configurations labels Jan 31, 2024
@kecnry kecnry force-pushed the aperture-validate-after-selection branch 3 times, most recently from 9d5faa3 to d7f3c70 Compare February 1, 2024 15:15
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

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

Comparison is base (9373a9e) 90.91% compared to head (acd2d37) 90.89%.
Report is 1 commits behind head on main.

Files Patch % Lines
jdaviz/core/template_mixin.py 90.24% 4 Missing ⚠️
...imviz/plugins/aper_phot_simple/aper_phot_simple.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2684      +/-   ##
==========================================
- Coverage   90.91%   90.89%   -0.02%     
==========================================
  Files         163      163              
  Lines       21348    21387      +39     
==========================================
+ Hits        19408    19440      +32     
- Misses       1940     1947       +7     

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

@kecnry kecnry marked this pull request as ready for review February 2, 2024 14:11
if aperture is not None or dataset is not None:
reg = self.aperture._get_spatial_region(subset=aperture if aperture is not None else self.aperture.selected, # noqa
dataset=dataset if dataset is not None else self.dataset.selected) # noqa
# determine if a valid aperture (since selected_validity only applies to selected entry)
_, _, validity = self.aperture._get_mark_coords_and_validate(selected=aperture)
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot tell which is better. But we can also just grab the 3rd result and not bother with magic underscores.

Suggested change
_, _, validity = self.aperture._get_mark_coords_and_validate(selected=aperture)
validity = self.aperture._get_mark_coords_and_validate(selected=aperture)[2]

Copy link
Member Author

Choose a reason for hiding this comment

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

I find the underscores to be more readable myself 🤷‍♂️

@pllim

This comment was marked as outdated.

@kecnry kecnry force-pushed the aperture-validate-after-selection branch from ee06116 to acd2d37 Compare February 2, 2024 19:07
Comment on lines +2161 to +2162
# if self.scale_factor == 1.0: # this would catch annulus, which might cause confusion
# pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could rewrite it as a comment, but do think we want something here so that we don't accidentally reintroduce it (since it feels like this should be there)

Copy link
Contributor

@javerbukh javerbukh left a comment

Choose a reason for hiding this comment

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

Changing the subset leads to the results you detail in the description, so LGTM, thanks!

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.

Can the snackbar message that is triggered when you try to select a composite subset be avoided?

'Failed to extract Subset 1: AttributeError("'OrState' object has no attribute 'roi'")'

@kecnry
Copy link
Member Author

kecnry commented Feb 2, 2024

Can the snackbar message that is triggered when you try to select a composite subset be avoided?

Not easily since its hard to predict the order that the observes will be evaluated. We could refactor the logic, but I also think the extra warning that an input is unsupported doesn't hurt?

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.

This also works as intended for me, approving

@kecnry kecnry merged commit 4319b64 into spacetelescope:main Feb 2, 2024
18 of 19 checks passed
@kecnry kecnry deleted the aperture-validate-after-selection branch February 2, 2024 21:17
gibsongreen pushed a commit to gibsongreen/jdaviz that referenced this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz imviz plugin Label for plugins common to multiple configurations Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants