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

get_data(use_display_units=True) to respect flux or sb selection #3129

Merged
merged 3 commits into from
Aug 5, 2024

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Aug 2, 2024

Description

This pull request fixes viz.get_data(use_display_units=True) on a 1d spectrum to respect the user choice of surface brightness or flux units. This then fixes the previews in line-analysis, which are calling get_data(use_display_units=True) under-the-hood when computing the continuum.

Screen.Recording.2024-08-02.at.10.24.59.AM.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. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 4.0 milestone Aug 2, 2024
@kecnry kecnry force-pushed the line-analysis-prev-disp-units branch from 7ccc93a to 3b77edb Compare August 2, 2024 14:16
Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.82%. Comparing base (b3bbd9f) to head (8a129d0).
Report is 138 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3129      +/-   ##
==========================================
- Coverage   88.85%   88.82%   -0.03%     
==========================================
  Files         112      112              
  Lines       17409    17409              
==========================================
- Hits        15468    15464       -4     
- Misses       1941     1945       +4     

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

@kecnry kecnry force-pushed the line-analysis-prev-disp-units branch 3 times, most recently from d9d1633 to ac1b500 Compare August 2, 2024 16:49
Comment on lines 172 to 175
# get_data(use_display_units=True) should return surface brightness-like units
# NOTE: should be updated to /pix**2 or /sr
assert cubeviz_helper.app._get_display_unit('spectral_y') == u.MJy / u.pix
assert cubeviz_helper.get_data('Spectrum (sum)', use_display_units=True).unit == u.MJy / u.pix
Copy link
Member Author

Choose a reason for hiding this comment

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

@gibsongreen - the first line works (although is inconsistent with the check above which is expecting /sr), and the second line is then failing the assertion by returning in MJy/sr. Is this something going wrong in flux_conversion or do these need to wait for non-per-sr support?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't change any of the extraction code to append u.pix before it gets added to the data collection, so the data item for 'Spectrum (sum)' is in MJy (without a denominator). The test failure I see running it locally is a conversion error between MJy / pix and MJy (which we don't have supported yet with the flux_conversion). The per pixel support right now is only when data loaded in is flux units, and I didn't add full support for it, that goal of #3111 was predicated on support for u.sr (with any other denominator being added in the generalization, and switching denominators possibly in that PR or in a future one).

The y_display_unit test on L166 I believe is actually correct and the data displayed is per sr. There is this assumption in #3111 that the we don't allow change of the angle_unit value. Below is the line where this assumption is made. This support was going to be in the generalization ticket, and since this is the case, when you translate, you still get .pix in this case which for the spectral_y test on L174.

https://github.com/gibsongreen/jdaviz/blob/96b92634efda8551cc83624cb2af7d36b0543fba/jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py#L177

Copy link
Member Author

Choose a reason for hiding this comment

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

@cshanahan1 - we now updated this test to have the input cube be in MJy/sr and then the rest of the logic falls into place. Would your future PR (adding support for non-steradian angle units) be able to re-introduce a test-case with input in flux units, test that they are coerced to flux/pix**2, and then test any of this similar logic that you think needs extra coverage?

@kecnry kecnry force-pushed the line-analysis-prev-disp-units branch from ac1b500 to 8a129d0 Compare August 2, 2024 17:39
@kecnry kecnry marked this pull request as ready for review August 2, 2024 18:12
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.

The code looks reasonable and I could not trigger any tracebacks, so looks good to me! I think it would be worthwhile to have someone check the science implications, however.

Copy link
Contributor

@gibsongreen gibsongreen left a comment

Choose a reason for hiding this comment

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

Everything looks good to me!

@kecnry kecnry merged commit 45734f6 into spacetelescope:main Aug 5, 2024
24 of 25 checks passed
@kecnry kecnry deleted the line-analysis-prev-disp-units branch August 5, 2024 13:49
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.

3 participants