-
Notifications
You must be signed in to change notification settings - Fork 74
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
Consolidate Cubeviz parser conversions #3221
Conversation
|
||
meta = standardize_metadata({'_orig_spatial_wcs': None}) | ||
s3d = Spectrum1D(flux=flux, meta=meta) | ||
|
||
# convert data loaded in flux units to a per-square-pixel surface | ||
# brightness unit (e.g Jy to Jy/pix**2) | ||
if not check_if_unit_is_per_solid_angle(s3d.unit): | ||
file_obj = convert_spectrum1d_from_flux_to_flux_per_pixel(s3d) |
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 assigning file_obj
here is actually a bug as file_obj
does not get used after this line.
@@ -580,67 +574,3 @@ def _get_data_type_by_hdu(hdu): | |||
else: | |||
data_type = '' | |||
return data_type | |||
|
|||
|
|||
def convert_spectrum1d_from_flux_to_flux_per_pixel(spectrum): |
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.
This is now unnecessary, as Clare requested.
@@ -194,15 +194,15 @@ def test_numpy_cube(cubeviz_helper): | |||
assert data.label == 'Array' | |||
assert data.shape == (4, 3, 2) # x, y, z | |||
assert isinstance(data.coords, PaddedSpectrumWCS) | |||
assert flux.units == 'ct' | |||
assert flux.units == 'ct / 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.
I think this fixes a bug where pure numpy cube does not get that PIX2 assigned like all the other stuff loaded into Cubeviz, right?
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.
Nice catch! I just checked this on main and it wasn't being coerced
@cshanahan1 , does this look about right? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3221 +/- ##
==========================================
- Coverage 88.56% 88.55% -0.01%
==========================================
Files 125 125
Lines 18755 18739 -16
==========================================
- Hits 16610 16595 -15
+ Misses 2145 2144 -1 ☔ 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.
looks good- tested it on a bunch of units loaded and it works as intended, no comments. thanks!
@@ -522,15 +521,15 @@ def _parse_ndarray(app, file_obj, data_label=None, data_type=None, | |||
flux = file_obj | |||
|
|||
if not hasattr(flux, 'unit'): | |||
flux = flux << u.count | |||
flux = flux << (u.count / 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.
Can we rename the file_obj
parameter to flux
in the method signature?
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.
We can but it is out of scope.
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.
All the parser changes are concise, I tested the different input cubes for the parsers that were updated and all results are as expected, great work!
Thanks for the reviews! |
Description
This pull request is leverages the following specutils PRs
to simplify Cubeviz parser unit conversion logic. I also refactored it a bit to streamline the flow because things are looking a bit chaotic with different people inserting parts of this and that in the parser.
As a result, I might have also fixed bugs in some uncommon cases that we test for but users do not usually encounter.
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.