-
Notifications
You must be signed in to change notification settings - Fork 76
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
improve stretch histogram performance (downsampling and decorator) #2408
Conversation
* to use traitlet directly since it does not interact with any glue state objects
if size > 400**2: | ||
xstep = max(1, round(arr.shape[1] / 400)) | ||
ystep = max(1, round(arr.shape[0] / 400)) | ||
arr = arr[::ystep, ::xstep] |
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.
@pllim - this code block essentially exists in three places in jdaviz now (compass and twice here). Do you think it's worth moving somewhere reusable? Maybe in utils?
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 sure. If you want this to turn into utility function, then you have to make sure that function is not making accidental copies (everything must pass by reference where it matters and must return a view) and maybe a way to adjust sampling factor and maybe even indices (for generic ndim support). Something to think about.
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 you want to refactor in this PR? If so, I will wait before reviewing.
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 had some of those same concerns, so let's leave this as-is for now and consider moving the logic up higher if we need it anywhere else in the future.
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 a bad feeling that we might have to revisit this as more and more new analysis stuff get requested. Should we open a ticket pre-emptively for the future?
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
Great improvement, thank you! |
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 it is unavoidable to decrease the accuracy of histogram to make it not lag so much. I tried comparing like this and while I see some difference, it is good enough. This is an example using the first image in Imviz Example Notebook when zoomed in and only show data within display window.
# Approx X/Y limits from imviz.default_viewer.state.x/y_min/max
pf = fits.open(f'{data_dir}/jw02727-o002_t062_nircam_clear-f090w_i2d.fits')
plt.hist(pf[1].data[2131:3523, 1699:3244].ravel(),
bins=25, range=(0, 0.5852748259901993),
rwidth=0.9, color="gray")
plt.axvline(0, color="red")
plt.axvline(0.5852748259901993, color="red")
But can we make the blue info box a little smaller?
So does histogram even need Y tick marks at this point? The numbers on Y axis do not mean much here. |
* takes less space and shows in popout
Not much meaning when it is subsampling. I guess it is fine if you want to keep the numbers but I fear they might confuse more than help. Unless you want to normalize to max of 1. Then it can be like percentage but in decimal form. |
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.
Cami is happy. Code looks like code.
Y-axis discussions is technically out of scope, so approving. Thanks!
Description
This pull request improves the performance of the stretch histogram and the stretch curve, especially for large images, by downsampling the data sent to the histogram and by making use of #2386 for the stretch curve introduced in #2390.
Screen.Recording.2023-08-31.at.8.15.01.AM.mov
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.