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

refactor unit conversion messaging #3192

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Sep 12, 2024

Description

This pull request refactors and simplifies the messaging within unit conversion. This currently is branched off of #3156, so should be moved onto main after that is merged.

TODO

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 Sep 12, 2024
@github-actions github-actions bot added cubeviz specviz testing imviz plugin Label for plugins common to multiple configurations labels Sep 12, 2024
@kecnry kecnry changed the title refactor unit conv messaging refactor unit conversion messaging Sep 12, 2024
@kecnry kecnry force-pushed the unit-conv-messaging branch 8 times, most recently from 405a11d to cee44db Compare September 16, 2024 15:43
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.

Don't grok most of the stuff. Just a general review. Thanks.

jdaviz/app.py Outdated
@@ -86,7 +86,16 @@ def equivalent_units(self, data, cid, units):
'erg / (s sr cm2)', 'erg / (Hz s sr cm2)',
'erg / (Angstrom s sr cm2)',
'ph / (Angstrom s sr cm2)', 'ph / (Hz s sr cm2)'
])
]
+ [
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the + operators to chain multiple static lists here? This introduces unnecessary list math, no?

jdaviz/configs/cubeviz/plugins/parsers.py Outdated Show resolved Hide resolved
assert flux_sci.units == flux_unit_str
# now that the flux cube was loaded into cubeviz, there will be a factor
# of pix2 applied to the flux unit
assert flux_sci.units == flux_unit_str + ' / pix2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert flux_sci.units == flux_unit_str + ' / pix2'
assert flux_sci.units == f'{flux_unit_str} / pix2'

Copy link
Contributor

Choose a reason for hiding this comment

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

changed this in 3156

# If unit is flux per pix2, the type will be 'unknown' rather
# than surface brightness, so have to multiply the pix2 part out
# and check if the numerator is a spectral flux density
if check_if_unit_is_per_solid_angle(unit, return_unit=True) == u.pix*u.pix:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move PIX2 higher up and re-use it throughout the package instead of u.pix*u.pix?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll do this after all these PRs are merged to avoid conflicts

@@ -15,6 +15,8 @@

PHOTUTILS_LT_1_12_1 = not minversion(photutils, "1.12.1.dev")

PIX2 = u.pix * u.pix
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not need to re-define this in multiple places if we move it higher up.

jdaviz/utils.py Outdated Show resolved Hide resolved
jdaviz/utils.py Outdated Show resolved Hide resolved
Comment on lines +312 to +314

elif axis == 'time':
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed?

Suggested change
elif axis == 'time':
pass

Copy link
Member Author

Choose a reason for hiding this comment

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

probably not, I can replace with a comment if you'd rather. It's here just to remind us that time is not currently handled (even though it can exist).

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment would be less confusing unless you intend to throw warning or exception.

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 specviz testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants