-
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
Speed up histogram in plot options (alternative to #2763) #2771
Speed up histogram in plot options (alternative to #2763) #2771
Conversation
128f5b8
to
86ee25c
Compare
Hmm. I installed those upstream branches you mentioned and installed Jdaviz from this PR branch. After I load that 8 GB image from Cami, I saw a non-sensible histogram for a second (just one bar) and then it self-refreshed and got stuck in the loading circle of death. All I did was load that image and then open Plot Options plugin, scroll down, and waited. |
Also looks like this patch broke the spline thingy?
|
@pllim could you send me a link to the 8Gb file? Thanks! |
@astrofrog , Cami has reached out to you separately about the file. FYI. |
@pllim - could you try and run the following Python script using pyinstrument and let me know the output? from jdaviz import Imviz
imviz = Imviz()
viewer = imviz.default_viewer
imviz.load_data("egs_all_acs_wfc_f814w_030mas_v1.9_drz.fits")
imviz.plugins["Plot Options"]._obj._update_stretch_histogram() With this PR and the two glue ones, the total time for the script goes down from 40s to 10s and a lot of that is the loading of the FITS file which has 27634 entries in the header? |
I tried calling
And after I hack-patched those on the installed astropy, it gave me this from a package I know nothing about:
Am I doing it wrong? Please advise. Thanks! |
FWIW, with this PR's current state, rebased on top of |
@pllim huh very weird - could you let me know what you get for:
Thanks! |
9dadc8d
to
e7a7589
Compare
pyproject.toml
Outdated
@@ -125,7 +125,6 @@ text_file_format = "rst" | |||
addopts = "--doctest-rst --import-mode=append" | |||
xfail_strict = true | |||
filterwarnings = [ | |||
"error", |
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 should not be deleted.
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.
Oops
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.
Fixed
224aa4e
to
6257bb8
Compare
…pacetelescope#2735)" This reverts commit fbef31f.
…s and image statistics, and remove code to handle NaN values that caused the whole array to be loaded into memory.
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
6257bb8
to
30a4707
Compare
@pllim - ready for another review |
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.
Thanks! LGTM.
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.
Thanks! LGTM. Edit: Wow I didn't realize this was character-for-character exactly what @pllim said 😆
… (spacetelescope#2771) * Revert "BUG: Always downsample histogram for Imviz in Plot Options (spacetelescope#2735)" This reverts commit fbef31f. * Use glue's ability to randomly sample values when computing histograms and image statistics, and remove code to handle NaN values that caused the whole array to be loaded into memory. * Use order='K' in ravel() to avoid copy * Avoid calling ravel() since this causes a copy for cutouts * Add comment to explain percentile values * Fix issue when array len() match but .shape doesn't * Adjust reference values for test * Bumped minimum required version of glue-core and glue-jupyter * Fix case where data is not a Numpy array * Add change log
Description
Like #2763, this starts off by reverting #2735, and then makes use of:
to speed up the histogram calculation. I also removed:
which was causing the whole array to get loaded into memory - this isn't needed anyway because glue's histogram viewer deals fine with NaN values. Finally, I also updated the calculation of the percentile limits to use glue, also with random sampling, otherwise PercentileLimits caused the whole array to be loaded into memory and caused slowdowns.
With these changes, I was able to load an 8Gb memory-mapped array and have the histogram update within a second or so. We might want to play with the random subset size a little to see what is a good compromise with real-world data.
I wonder whether it might make sense to consider having some kind of performance benchmark for this kind of functionality, because it's easy to accidentally introduce regressions that cause all the data to be used.
This requires the two glue PRs to be merged and released before merging this PR.
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.