Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add conical aperture support in the spectral extraction plugin #2679

Merged
merged 56 commits into from
Feb 28, 2024

Conversation

javerbukh
Copy link
Contributor

@javerbukh javerbukh commented Jan 26, 2024

Description

This pull request adds support for fractional pixels using NDData as well as using that feature to create conical apertures in cubeviz using the spectral extraction plugin.

Cone mask at different slices:

Cone mask at slice 100

image

Cone mask at slice 1000

image

Cone mask at slice 3000

image

Not wavelength dependent, wavelength dependent, wavelength dependent at a different slice

cubeviz_cone_aperture_demo_02052024.mp4

TODO:

  • Connect functionality to front-end
  • Extend aperture support to other shapes
  • Add tests
  • Add docs

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.
  • Add conical aperture support to cubeviz in the spectral extraction plugin[2679]

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

@github-actions github-actions bot added cubeviz plugin Label for plugins common to multiple configurations labels Jan 26, 2024
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.86%. Comparing base (b89d91f) to head (7816905).
Report is 52 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2679      +/-   ##
==========================================
- Coverage   90.89%   88.86%   -2.04%     
==========================================
  Files         163      108      -55     
  Lines       21391    15916    -5475     
==========================================
- Hits        19444    14144    -5300     
+ Misses       1947     1772     -175     

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

jdaviz/configs/cubeviz/plugins/parsers.py Outdated Show resolved Hide resolved
@@ -134,12 +134,15 @@
&& (bg_selected === 'None' || bg_selected_validity.is_aperture)
&& dev_subpixel_support">
<v-row>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<v-row>
<v-row v-if="aperture_selected !== 'Entire Cube'">

We should also include an in-line warning if !aperture_selected_validity.is_aperture conflicts with the selection here (for example a composite subset and "subpixel"), disable clicking the extract button, and have checks in the python method that raise an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it currently stands, if you have Subset 1 selected and then you make it a composite subset, the option to make a cone wavelength dependent is removed and you see the following message in the UI: "Subset 1 does not support wavelength dependence (cone support): composite subsets are not supported." Is that sufficient or do you mean to cover another case with this?

Copy link
Member

Choose a reason for hiding this comment

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

oh right - I forgot I did that 😝 That's probably fine for now, and I'll make a note of this in the final UI/UX review (we might instead want to continue showing the dropdown and have an error so that there is a consistent workflow from the API perspective).

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 no good with the vue stuff but now that cylindrical also use the same algorithm as cone, any checks here need updating?

Copy link
Member

Choose a reason for hiding this comment

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

I think this should work with #2684. If anything there needs updating, please open a ticket.

@javerbukh javerbukh marked this pull request as ready for review February 6, 2024 15:28
@rosteen
Copy link
Collaborator

rosteen commented Feb 6, 2024

The cone extraction appears to work really well, impressive! I checked that the displayed aperture scales as expected, and below you can see that the extracted spectrum is lower at the smaller aperture and and higher at the large end compared to the naive sum over the subset, as you would expect:

Screenshot 2024-02-06 at 1 21 08 PM

However, it looks like whatever is populating the aperture masking method menu items is failing:

Screenshot 2024-02-06 at 1 20 07 PM

Once that is fixed (and the failure with no uncertainty as mentioned above) I think this will be ready or at least close - I'll do a little more detailed reading through the code now.

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.

Questions about the test.

@rosteen
Copy link
Collaborator

rosteen commented Feb 8, 2024

I still see "[object Object]" in the masking method menu. Additionally, the "Slice to Reference Wavelength" button's text should probably wrap, currently a lot of the text is cut off at the default width of the plugin for me.

Screenshot 2024-02-08 at 11 01 43 AM

@javerbukh
Copy link
Contributor Author

@rosteen That's strange, I'm not seeing that anymore. Are you sure you have the latest commit?

@pllim
Copy link
Contributor

pllim commented Feb 27, 2024

@bmorris3 , since you requested changes, can you please re-review? Thanks!

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!

# But we still need the mean function for everything except flux
collapsed_as_mean = nddata_reshaped.mean(axis=spatial_axes, **kwargs)

# Then normalize the flux based on the fractional pixel array
Copy link
Contributor

Choose a reason for hiding this comment

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

I was hoping all this would happen inside NDData somewhere. Kinda defeats the purpose of using NDData if we still have to do it ourselves here, no, @bmorris3 ?

jdaviz/conftest.py Outdated Show resolved Hide resolved
Comment on lines -440 to -448


def _move_spectral_axis(wcs, flux, mask=None, uncertainty=None):
"""
Move spectral axis last to match specutils convention. This
function borrows from:
https://github.com/astropy/specutils/blob/
6eb7f96498072882c97763d4cd10e07cf81b6d33/specutils/spectra/spectrum1d.py#L185-L225
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pllim Did you mean to remove all this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is not used anywhere.

and also more clean-ups
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.

I basically co-wrote this PR now, so naturally I am now happy where it stands, so approving. But you should revisit if any vue rules need updating for the GUI checks, see https://github.com/spacetelescope/jdaviz/pull/2679/files#r1506335282

Thanks for your patience, Jesse!

@pllim pllim merged commit c8d6353 into spacetelescope:main Feb 28, 2024
15 of 16 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cubeviz 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.

6 participants