-
Notifications
You must be signed in to change notification settings - Fork 75
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
Aperture photometry in Cubeviz #2666
Conversation
4e3fcf5
to
97f6679
Compare
@@ -53,7 +53,7 @@ def test_fits_image_hdu_with_microns(image_cube_hdu_obj_microns, cubeviz_helper) | |||
flux_unit_str = "erg / (Angstrom cm2 s)" | |||
else: | |||
flux_unit_str = "erg / (Angstrom s cm2)" | |||
assert label_mouseover.as_text() == (f'Pixel x=00.0 y=00.0 Value +1.00000e+00 1e-17 {flux_unit_str}', # noqa | |||
assert label_mouseover.as_text() == (f'Pixel x=00.0 y=00.0 Value +5.00000e+00 1e-17 {flux_unit_str}', # noqa |
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 modified the test data so I can use it for photometry test. This change is expected.
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 need to attach WCS to collapsed data for consistent aperture photometry behavior. If this is somehow yet another ticket, please let me know.
@@ -170,7 +180,7 @@ def _save_collapsed_spec_to_fits(self, overwrite=False, *args): | |||
return | |||
|
|||
filename = str(filename) | |||
CCDData(self.collapsed_spec).write(filename) |
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.
Weird that you don't assign CCDData at creation but only at writing it out. I fixed it.
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.
Again, I needed to fix the WCS here for consistent photometry behavior.
if hasattr(reg, 'to_pixel'): | ||
sky_center = reg.center | ||
xcenter, ycenter = data.coords.world_to_pixel(sky_center) | ||
if self.config == "cubeviz" and data.ndim > 2: | ||
ycenter, xcenter = w.world_to_pixel( |
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.
Note: I tried to be lazy here, i.e., extracting just the wcs.celestial
component and then use it without wavelength input, but the answer came out wrong, probably because of the specutils transpose, so let's just do it the hard way here.
jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue
Outdated
Show resolved
Hide resolved
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.
If you want to run the new tests I wrote interactively, they are identical to the ones I put in this notebook. Feel free to use this for review if you don't have anything better.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2666 +/- ##
==========================================
+ Coverage 90.84% 90.92% +0.07%
==========================================
Files 162 163 +1
Lines 21140 21356 +216
==========================================
+ Hits 19205 19418 +213
- Misses 1935 1938 +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.
Seems to work quite well and thanks for the thorough test coverage of different input cases!
For cube/slice support, we might want:
- either a read-only indication of the slice being used, a message that the current slice is used, or an input that is two-way synced to the slider?
- a column in the resulting output table that stores the slice number?
jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue
Outdated
Show resolved
Hide resolved
jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.vue
Outdated
Show resolved
Hide resolved
cd2d876
to
f85ec71
Compare
I think I have addressed all the comments, @kecnry and @camipacifici . |
This comment was marked as resolved.
This comment was marked as resolved.
See here - this already has some rules for slice expecting an integer.... so maybe we shouldn't call this slice or will need extra rules here for this case (checking unit as well or something like that). Maybe we even want to just adhere to |
This comment was marked as resolved.
This comment was marked as resolved.
Precision on GUI table is fixed. And replace slice index with wavelength on GUI as well. Good now? |
c7d10df
to
60a564b
Compare
slice_val = self._cube_wave | ||
else: | ||
slice_val = u.Quantity(np.nan, self._cube_wave.unit) | ||
phot_table.add_column(slice_val, name="slice_wave", index=29) |
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.
is this going to conflict when we add display-unit support in cubeviz that allows changing between wavelength and frequency units? We probably can defer and change the name (and possibly handle needing to move units to its own column) at that point, but we'll need a follow-up ticket/issue.
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 won't be the only conflict when the unit changing stuff happens (flux conversion, anyone?). So yeah, can be dealt with later because a lot of other stuff would also need to change together with it.
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.
(Unfortunate though because QTable is supposed to make storing Quantity easier.)
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.
ok, since this is getting in before that, I made a ticket for handling all of that linking back here 🐱
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.
Just two remaining thoughts mentioned above, but probably can be dealt with after merge, so I'll approve so someone else can start reviewing. Thanks!
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.
Diff looks good and plugin works well, nice! Only have two comments: it would be convenient if the slice/wavelength at which the chart was calculated was shown above it or close by and another QOL feature would be what @kecnry implemented in spectral extraction where the subset you are using is highlighted in the viewer. Both of those can be deferred to a future PR if that makes more sense though.
that should be here now since that is already merged and I see it in my screenshots above. Is it not working for you? |
Wavelength is there. I originally implemented slice index but people asked for wavelength. It is uneditable text field below the data drop-down. Did you not see it? |
Wavelength in
|
Add tests and documentation. Attach WCS to some Cubeviz 2D products, where it is needed but missing. Minor clean-ups.
for cubeviz
Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
and do not display slice for cubeviz 2D data, as requested.
for Cubeviz phot table.
and display slice wavelength instead of index in read-only text field.
60a564b
to
bbb5fad
Compare
* Implement Cubeviz aperture photometry. Add tests and documentation. Attach WCS to some Cubeviz 2D products, where it is needed but missing. Minor clean-ups. * Add slice info to aper phot plugin for cubeviz * Clarify slice field in aper phot Co-authored-by: Kyle Conroy <kyleconroy@gmail.com> * Fix plugin data menu bug * Implement slice in output table and do not display slice for cubeviz 2D data, as requested. * Add doc for new slice column for Cubeviz phot table. * Fix table GUI for slice wavelength and display slice wavelength instead of index in read-only text field. * Display slice_wave in plot and text results --------- Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
Description
This pull request is to unleash Imviz aperture photometry on Cubeviz.
I need:
VAR andMASK cubes.self.dataset.add_filter(my_filter_callable)
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.