-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: main
Are you sure you want to change the base?
Conversation
4cfaeed
to
9293060
Compare
55c36a8
to
18e1562
Compare
405a11d
to
cee44db
Compare
There was a problem hiding this 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)' | |||
]) | |||
] | |||
+ [ |
There was a problem hiding this comment.
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?
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert flux_sci.units == flux_unit_str + ' / pix2' | |
assert flux_sci.units == f'{flux_unit_str} / pix2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this in 3156
jdaviz/configs/default/plugins/model_fitting/tests/test_plugin.py
Outdated
Show resolved
Hide resolved
# 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: |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
jdaviz/tests/test_utils.py
Outdated
@@ -15,6 +15,8 @@ | |||
|
|||
PHOTUTILS_LT_1_12_1 = not minversion(photutils, "1.12.1.dev") | |||
|
|||
PIX2 = u.pix * u.pix |
There was a problem hiding this comment.
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.
|
||
elif axis == 'time': | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed?
elif axis == 'time': | |
pass |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
91ac1c5
to
d54cef4
Compare
This reverts commit aa0d384.
d54cef4
to
9d04c43
Compare
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
test_spectrum_viewer_axis_labels
from convert flux cubes to per-square-pixel surface brightness cubes #3156PIX2
vsu.pix * u.pix
from convert flux cubes to per-square-pixel surface brightness cubes #3156Change log entry
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, maintainershould 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.
trivial
label.