-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fix "Unit conversion when equivalency needed breaks contours in cubeviz" #3207
base: main
Are you sure you want to change the base?
Conversation
Somehow this one test makes 2 very different tracebacks. Funky.
|
to make sure it still fails before I fix it.
The original exception reported in JIRA also produces |
6c91bce
to
913f80e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3207 +/- ##
==========================================
- Coverage 88.46% 88.45% -0.01%
==========================================
Files 125 125
Lines 18677 18699 +22
==========================================
+ Hits 16522 16541 +19
- Misses 2155 2158 +3 ☔ View full report in Codecov by Sentry. |
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.
In a nutshell, the way all this stuff is set up, it goes through the glue unit conversion machinery that has no access to app data (like cube slice or spectral axis). So the least painful way I can think of is to define the equivalencies (again) where things are broken (as far as this JIRA ticket is concerned). For the background unit conversion, I cannot find any existing equivalencies that would work on the / pix2
stuff so I put in a hack to remove it. Ideas welcome.
if len(values) == spectral_values.size: | ||
eqv = u.spectral_density(spectral_values) | ||
else: | ||
eqv = u.spectral_density(spec.spectral_axis[0]) |
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 actually not sure if grabbing [0]
is entirely correct but I also don't know what is really happening when values
are only an array of 7 elements. I think that is the downsampled version from the viewer but really hard to tell for sure.
# FIXME: Kinda hacky, better solution welcomed. | ||
# Basically we want to forget about PIX2 and do normal conversion. | ||
# Since traitlet does not keep unit, we do not need to reapply PIX2. | ||
if "pix2" in prev_display_unit and "pix2" in self.display_unit: |
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.
can you check if this is the case for steradian as well? i believe you cant convert flux/sr <> flux/sr if there is a u.spectral_density equivalency needed.
you could also leave a note here to pass this through utils.flux_conversion eventually - i'm working on generalizing this function to handle cases like this and it might simplify this code if we want to swap it later on
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 think steradian is already covered by existing equivalencies combo because steradian is a recognized physical unit in astronomy, whereas pixel is very much tied to instrumentation and not well defined in astropy.units
. CI passes without such treatment for u.sr
. Unless you mean somehow the existing test suite does not cover the steradian case already?
Line 519 in fc88465
def _eqv_pixar_sr(pixar_sr): |
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.
Ah, I see the test I unskipped is about Cubeviz unit conversion plugin only. And this code is inside aperture photometry. I can think of how I can expand your test case to go through this line as well tomorrow, maybe. 🤔
Description
This pull request is to unit conversion when equivalency needed breaks contours in cubeviz. Unskips a test added in #3204 .
Probably no need for change log since this is patching unreleased feature, I assume.
Change 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.