From 3a820655794c6f27cfb536db667637bb59b67baa Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 28 Mar 2024 14:24:50 +0000 Subject: [PATCH] Properly handle image limit units in layer artist --- glue/viewers/image/layer_artist.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/glue/viewers/image/layer_artist.py b/glue/viewers/image/layer_artist.py index abee0cad2..badef124d 100644 --- a/glue/viewers/image/layer_artist.py +++ b/glue/viewers/image/layer_artist.py @@ -21,6 +21,7 @@ PixelAlignedDataChangedMessage) from glue.viewers.image.frb_artist import imshow from glue.core.fixed_resolution_buffer import ARRAY_CACHE, PIXEL_CACHE +from glue.core.units import UnitConverter class BaseImageLayerArtist(MatplotlibLayerArtist, HubListener): @@ -160,8 +161,18 @@ def _update_visual_attributes(self): else: self.composite.mode = 'color' + # As the levels may be specified in a different unit we should convert + # them to the native data units. + + converter = UnitConverter() + + clim = tuple(converter.to_native(self.state.layer, + self.state.attribute, + np.hstack([self.state.v_min, self.state.v_max]), + self.state.attribute_display_unit)) + self.composite.set(self.uuid, - clim=(self.state.v_min, self.state.v_max), + clim=clim, visible=self.state.visible, zorder=self.state.zorder, color=self.state.color,