-
Notifications
You must be signed in to change notification settings - Fork 80
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
FEAT: Radial profile in Imviz simple aperture photometry plugin #1030
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1030 +/- ##
==========================================
+ Coverage 74.58% 74.71% +0.13%
==========================================
Files 77 77
Lines 5835 5874 +39
==========================================
+ Hits 4352 4389 +37
- Misses 1483 1485 +2 ☔ View full report in Codecov by Sentry. |
@@ -145,6 +155,7 @@ def vue_do_aper_phot(self, *args, **kwargs): | |||
npix = np.sum(aper_mask) * u.pix | |||
img = aper_mask.get_values(comp_no_bg, mask=None) | |||
aper_mask_stat = reg.to_mask(mode='center') | |||
comp_no_bg_cutout = aper_mask_stat.cutout(comp_no_bg) |
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.
@PatrickOgle et al. -- You do want radial profile of background subtracted data, right? If not, I can change this to plot raw data. Please confirm.
radial_img = comp_no_bg_cutout.ravel() | ||
with quantity_support(): | ||
fig, ax = plt.subplots() | ||
ax.plot(radial_r, radial_img, 'k.') |
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.
@larrybradley , I hope I got this right. Would be nice if you double check if I am using regions
correctly for the radial plot. Thanks!
Here are some tweaks that will help with the UX:
Happy to discuss these on a call to further explain. Thanks! |
Thanks, @Jenneh !
I don't know what this is. Maybe @kecnry or @havok2063 can help?
Makes sense but hard to do with matplotlib. We are going to replace matplotlib with bqplot anyway, so I am going to hold this off for now. But I will keep this in mind. |
@pllim @Jenneh - the MAST table component is a great idea, but I would suggest we handle that across the entire app at once instead of just for this plugin. I also agree about the padding - if bqplot ends up being a no-go, then we should fix this for matplotib, but there's no sense in doing it yet 🤞 |
Re: MAST vuetify component -- @Jenneh or @havok2063 , does it automatically handle dark theme? If it does not, might be non-starter. |
We have added style overrides on the table so I think it should look the same regardless of which theme. |
I cannot think of a good caption. The most important info is already captured in the title above the plot and X/Y-axis labels. Do you mean I move the title from top of the plot to the bottom? |
@Jenneh , I think I already cut down on the significant figures formatting. Are you sure you are using the latest version of this feature branch? |
08a20d9
to
1f185a0
Compare
This comment has been minimized.
This comment has been minimized.
jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py
Outdated
Show resolved
Hide resolved
jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py
Outdated
Show resolved
Hide resolved
1f185a0
to
6f277c0
Compare
6c52ccb
to
ae64b7a
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.
Running this in jupyter-lab, when I press calculate
my browser seems to freeze up and I get a popup asking if I want to kill the page or wait. If I press wait
, eventually it finishes calculating. It would be nice to have something indicating that the calculation is ongoing, or making the radial profile optional since it seems to make the application lag once it appears.
I am out of my depths as far as the science goes but the implementation (not sure if optimization is possible/in-scope) and design looks good to me!
@javerbukh @pllim - we could do a plugin spinner similar to #1060... but maybe that should be a separate effort (to apply across all plugins that take time and need some feedback that current shown results are out-of-date). |
It is not supposed to take that long. It is just basically doing simple stat along different radii from center. How big was your image and how big was the Subset? |
The model fitting plugin uses a Snackbar message with a spinning symbol during cube fitting to indicate that it's running, so that's another possibility here. |
Do we really need a spinner? Like I said, normal use case will only do this on a small subset area. 💭 |
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 have one concern about this, which is that it doesn't seem to behave well if you've linked by WCS before applying a subset. In the below screenshot I've linked by WCS, which shifts the second image to match the first (reference) image. Then, when I apply the subset to the radial calculation, it seems to be applying the subset to the unshifted data, such that the radial profile isn't properly centered. This conflicts with what the user sees in the viewer, which shows the subset centered on the star.
Oh, dear. If the radial profile is wrong, that means the photometry is wrong too, since they all use the same subset! Is this not the right way to extract Subset associated with the selected Data? # event is the Subset label
for lyr in viewer.layers:
if lyr.layer.label == event and lyr.layer.data.label == self._selected_data.label:
subset = lyr.layer
self._selected_subset = subset.data.get_selection_definition(
subset_id=event, format='astropy-regions') |
I'm looking into it, but the initial thing I found is that there seem to be two "Subset 1" layers...so it might be grabbing the wrong one of the two.
Edit: I wrote this before realizing that your lyr.layer.data.label check might cover this. |
Actually the problem is that
|
This might be a good thing to delve into for our SME hack day... 😅 |
Oh... I remember now! I opened an issue about this a few months ago: |
Well, yikes. Other than writing a known issue, I am not sure what to do here. Until the upstream bug is fixed, one should never try to do photometry on anything other than the reference data when images are dithered. |
Yeha, rough. I suspect that the root cause may be in |
Address some comments from Jenneh review
Co-authored-by: Kyle Conroy <[email protected]>
to enable radial plot resizing
And clarify phot doc
1561be4
to
ea0a204
Compare
@rosteen et al., I rebased and added documentation about the dither bug. |
Doh, I even wrote it into the test... 😹 jdaviz/jdaviz/configs/imviz/tests/test_simple_aper_phot.py Lines 66 to 68 in 9d35f7f
|
jdaviz/app.py
Outdated
tray_obj = self.widgets.get(tray_item['widget'].split('IPY_MODEL_')[1]) | ||
for bqplot_fig in tray_obj.bqplot_figs_resize: | ||
bqplot_fig.layout.height = '99.9%' | ||
bqplot_fig.layout.height = '100&' |
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 checking - is this really supposed to be 100&
, not 100%
?
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.
Hmm, @kecnry would know.
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.
Good catch, yes it should be 100%
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.
Okay, I pushed a commit to fix it. Makes me wonder what it was doing before. I didn't see anything weird in manual testing. Does this setting even do anything?
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.
That's unclear to me 😆 . It also raises the question of whether there's a reason that one is 99.9% and the other is 100% (not that I didn't say a good reason, it could be an obtuse javascript thing).
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.
@kecnry put that in when I noticed the radial plot won't resize when I resize the plugin tray.
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.
It likely was defaulting to interpreting that as 100% anyways (I'm guessing/hoping?). This block is just forcing the layout to re-adjust to the changed size of the container (its kind of hacky by making a small change in the height the figure readjusts the width to fill the space - but its the same logic that already exists to handle viewer figure resizing).
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.
Approving, since the bug I noticed is documented and requires an upstream fix.
Thanks for the thorough reviews! Please let me know which one is next so I can rebase that one. |
Description
This pull request is to add radial plot to simple aperture photometry plugin in Imviz.
Close #962
🐱
TODO
matplotlib
withbqplot
.AwaitingUse findings from @kecnry .Screenshots (bqplot)
HST/ACS data (dark mode):
JWST simulated data:
photutils
example data (no WCS nor unit):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.CHANGES.rst
?