Skip to content

Commit

Permalink
update histogram according to stretch_global
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Apr 17, 2024
1 parent e3c0ffa commit d9dbfda
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ def state_attr_for_line_visible(state):
'stretch_preset_value', 'stretch_preset_sync',
state_filter=is_image)
self.stretch_global = PlotOptionsSyncState(self, self.viewer, self.layer, 'global_limits',
'stretch_global_value', 'stretch_global_sync',
state_filter=is_image_cube)
'stretch_global_value', 'stretch_global_sync',
state_filter=is_image_cube)
self.stretch_vmin = PlotOptionsSyncState(self, self.viewer, self.layer, 'v_min',
'stretch_vmin_value', 'stretch_vmin_sync',
state_filter=is_image)
Expand Down Expand Up @@ -902,7 +902,7 @@ def _update_stretch_hist_sync(self, msg={}):
'mixed': bool(np.any([sync.get('mixed', False) for sync in all_syncs]))} # noqa

@observe('is_active', 'layer_selected', 'viewer_selected',
'stretch_hist_zoom_limits')
'stretch_hist_zoom_limits', 'stretch_global_value')
@skip_if_no_updates_since_last_active()
@with_spinner('stretch_hist_spinner')
def _update_stretch_histogram(self, msg={}):
Expand Down Expand Up @@ -986,6 +986,8 @@ def _update_stretch_histogram(self, msg={}):
y_min = max(y_limits.min(), 0)
y_max = y_limits.max()
arr = comp.data[y_min:y_max, x_min:x_max]
if hasattr(viewer, 'slice') and not self.stretch_global_value:
arr = arr.take(viewer.slice, viewer.slice_index)
if self.config == "imviz":
# Downsample input data to about 400px (as per compass.vue) for performance.
xstep = max(1, round(arr.shape[1] / 400))
Expand Down Expand Up @@ -1018,7 +1020,10 @@ def _update_stretch_histogram(self, msg={}):
arr = comp[::ystep, ::xstep]
else:
# include all data, regardless of zoom limits
arr = comp.data
if hasattr(viewer, 'slice') and not self.stretch_global_value:
arr = comp.data.take(viewer.slice, viewer.slice_index)
else:
arr = comp.data
sub_data = arr.ravel()

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

0 comments on commit d9dbfda

Please sign in to comment.