Skip to content

Commit

Permalink
BUG: Always downsample histogram for Imviz
Browse files Browse the repository at this point in the history
because really there is no reason to sample everything.
  • Loading branch information
pllim committed Feb 27, 2024
1 parent 20de93b commit b790011
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Cubeviz
Imviz
^^^^^

- Histogram in Plot Options no longer stalls for a very large image. [#2735]

Mosviz
^^^^^^

Expand Down
16 changes: 13 additions & 3 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,12 @@ def _update_stretch_histogram(self, msg={}):
x_max = x_limits.max()
y_min = max(y_limits.min(), 0)
y_max = y_limits.max()

arr = comp.data[y_min:y_max, x_min:x_max]
if self.config == "imviz":

Check warning on line 977 in jdaviz/configs/default/plugins/plot_options/plot_options.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/default/plugins/plot_options/plot_options.py#L977

Added line #L977 was not covered by tests
# Downsample input data to about 400px (as per compass.vue) for performance.
xstep = max(1, round(arr.shape[1] / 400))
ystep = max(1, round(arr.shape[0] / 400))
arr = arr[::ystep, ::xstep]

Check warning on line 981 in jdaviz/configs/default/plugins/plot_options/plot_options.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/default/plugins/plot_options/plot_options.py#L979-L981

Added lines #L979 - L981 were not covered by tests
sub_data = arr.ravel()

else:
Expand All @@ -995,8 +999,14 @@ def _update_stretch_histogram(self, msg={}):
sub_data = comp.data[inds].ravel()

else:
# include all data, regardless of zoom limits
arr = comp.data
if self.config == "imviz":
# Downsample input data to about 400px (as per compass.vue) for performance.
xstep = max(1, round(data.shape[1] / 400))
ystep = max(1, round(data.shape[0] / 400))
arr = comp[::ystep, ::xstep]
else:
# include all data, regardless of zoom limits
arr = comp.data
sub_data = arr.ravel()

# filter out nans (or else bqplot will fail)
Expand Down

0 comments on commit b790011

Please # to comment.