From 66e1046277f61344853cd4dff807db6e95b60ebd Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 24 Oct 2023 15:31:44 +0100 Subject: [PATCH 1/6] Make sure that the stretch histogram has x_att set to 'x' for the histogram dataset, and temporarily change x_att to 'ref' dataset to avoid issues --- .../configs/default/plugins/plot_options/plot_options.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index 89f696e7d6..066cacbfc8 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -706,7 +706,14 @@ def _update_stretch_histogram(self, msg={}): if np.any(np.isnan(sub_data)): sub_data = sub_data[~np.isnan(sub_data)] + # To avoid issues when updating the histogram data, which may or may not + # result in a change of the ComponentID for the x-axis, we temporarily + # change the x_att to the dummy 'ref' dataset then change it back to + # the latest ComponentID after. + + self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['ref'].id['x'] self.stretch_histogram._update_data('histogram', x=sub_data) + self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['histogram'].id['x'] if len(sub_data) > 0: interval = PercentileInterval(95) From 58800ccf987a04e8da06d152076adf6354ee4866 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:38:24 -0400 Subject: [PATCH 2/6] Fix PEP 8 warnings [ci skip] [rtd skip] --- jdaviz/configs/default/plugins/plot_options/plot_options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index 066cacbfc8..260c5b7165 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -711,9 +711,9 @@ def _update_stretch_histogram(self, msg={}): # change the x_att to the dummy 'ref' dataset then change it back to # the latest ComponentID after. - self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['ref'].id['x'] + self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['ref'].id['x'] # noqa: E501 self.stretch_histogram._update_data('histogram', x=sub_data) - self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['histogram'].id['x'] + self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['histogram'].id['x'] # noqa: E501 if len(sub_data) > 0: interval = PercentileInterval(95) From 28485bda0f8d9af07c4d105f325a5e5f1ef68540 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 26 Oct 2023 12:13:09 +0100 Subject: [PATCH 3/6] Remove workarounds related to stretch histogram --- .../default/plugins/plot_options/plot_options.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index 260c5b7165..87226e63aa 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -469,10 +469,6 @@ def state_attr_for_line_visible(state): self.stretch_histogram.tools_nested, ["jdaviz:stretch_bounds"]) - # NOTE: this is a current workaround so the histogram viewer doesn't crash when replacing - # data. Note also that passing x=[0] fails on SOME machines, so we'll pass [0, 1] instead - self.stretch_histogram._add_data('ref', x=[0, 1]) - self.stretch_histogram.layers['ref'].state.visible = False self.stretch_histogram._add_data('histogram', x=[0, 1]) self.stretch_histogram.add_line('vmin', x=[0, 0], y=[0, 1], ynorm=True, color='#c75d2c') @@ -706,14 +702,7 @@ def _update_stretch_histogram(self, msg={}): if np.any(np.isnan(sub_data)): sub_data = sub_data[~np.isnan(sub_data)] - # To avoid issues when updating the histogram data, which may or may not - # result in a change of the ComponentID for the x-axis, we temporarily - # change the x_att to the dummy 'ref' dataset then change it back to - # the latest ComponentID after. - - self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['ref'].id['x'] # noqa: E501 self.stretch_histogram._update_data('histogram', x=sub_data) - self.stretch_histogram.viewer.state.x_att = self.stretch_histogram.app.data_collection['histogram'].id['x'] # noqa: E501 if len(sub_data) > 0: interval = PercentileInterval(95) From 706db5b9e608bebabeb913ee5b6b0385cfb0c88a Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 26 Oct 2023 12:22:46 +0100 Subject: [PATCH 4/6] Bump minimum required version of glue-core to v1.14.1 to include bug fix for stretch histogram --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ef5b9630c5..e410018957 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "traitlets>=5.0.5", "bqplot>=0.12.37", "bqplot-image-gl>=1.4.11", - "glue-core>=1.14", + "glue-core>=1.14.1", "glue-jupyter>=0.19", "echo>=0.5.0", "ipykernel>=6.19.4", From 5d26d9e59fabe8f32727897f4e0c1d0787d93e85 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Tue, 31 Oct 2023 16:21:56 -0400 Subject: [PATCH 5/6] fix percentile and bins when resetting limits requires glue-viz/glue#2455 --- jdaviz/configs/default/plugins/plot_options/plot_options.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index 87226e63aa..41801f3846 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -474,6 +474,8 @@ def state_attr_for_line_visible(state): self.stretch_histogram.add_line('vmin', x=[0, 0], y=[0, 1], ynorm=True, color='#c75d2c') self.stretch_histogram.add_line('vmax', x=[0, 0], y=[0, 1], ynorm='vmin', color='#c75d2c') self.stretch_histogram.add_scatter('colorbar', x=[], y=[], ynorm='vmin', marker='square', stroke_width=33) # noqa: E501 + self.stretch_histogram.viewer.state.update_bins_on_reset_limits = False + self.stretch_histogram.viewer.state.x_limits_percentile = 95 with self.stretch_histogram.figure.hold_sync(): self.stretch_histogram.figure.axes[0].label = 'pixel value' self.stretch_histogram.figure.axes[0].num_ticks = 3 From ee38073e1c9da8e926d1865a264f176a95bae8a2 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 16 Nov 2023 12:07:35 -0500 Subject: [PATCH 6/6] update glue-core pin --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e410018957..36729e4f88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "traitlets>=5.0.5", "bqplot>=0.12.37", "bqplot-image-gl>=1.4.11", - "glue-core>=1.14.1", + "glue-core>=1.16.0", "glue-jupyter>=0.19", "echo>=0.5.0", "ipykernel>=6.19.4",