Beispiel #1
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            # In the following we force the color and linewith of the WCSAxes
            # frame to be restored after calling reset_wcs. This can be removed
            # once we support Astropy 1.3.1 or later.
            color = self._axes.coords.frame.get_color()
            linewidth = self._axes.coords.frame.get_linewidth()
            self._axes.reset_wcs(wcs)
            self._axes.coords.frame.set_color(color)
            self._axes.coords.frame.set_linewidth(linewidth)
            del color, linewidth

        self._im = imshow(self._axes, image, norm=self._norm, cmap='gray', **kwargs)
        self._im_array = image
        self._wcs = wcs
        self._redraw()
Beispiel #2
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            # In the following we force the color and linewith of the WCSAxes
            # frame to be restored after calling reset_wcs. This can be removed
            # once we support Astropy 1.3.1 or later.
            color = self._axes.coords.frame.get_color()
            linewidth = self._axes.coords.frame.get_linewidth()
            self._axes.reset_wcs(wcs)
            self._axes.coords.frame.set_color(color)
            self._axes.coords.frame.set_linewidth(linewidth)
            del color, linewidth

        self._im = imshow(self._axes,
                          image,
                          norm=self._norm,
                          cmap='gray',
                          **kwargs)
        self._im_array = image
        self._wcs = wcs
        self._redraw()
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        self._composite.set('image',
                            array=image,
                            color=colormaps.members[0][1])
        self._im = imshow(self._axes, self._composite, **kwargs)
        self._im_array = image
        self._set_norm(self._contrast_mode)

        if 'extent' in kwargs:
            self.axes.set_xlim(kwargs['extent'][:2])
            self.axes.set_ylim(kwargs['extent'][2:])
        else:
            ny, nx = image.shape
            self.axes.set_xlim(-0.5, nx - 0.5)
            self.axes.set_ylim(-0.5, ny - 0.5)

        # FIXME: for a reason I don't quite understand, dataLim doesn't
        # get updated immediately here, which means that there are then
        # issues in the first draw of the image (the limits are such that
        # only part of the image is shown). We just set dataLim manually
        # to avoid this issue. This is also done in ImageViewer.
        self.axes.dataLim.intervalx = self.axes.get_xlim()
        self.axes.dataLim.intervaly = self.axes.get_ylim()

        self._redraw()
Beispiel #4
0
    def __init__(self, axes, viewer_state, layer_state=None, layer=None):

        super(ImageSubsetLayerArtist, self).__init__(axes, viewer_state,
                                                     layer_state=layer_state, layer=layer)

        self.subset_array = ImageSubsetArray(self._viewer_state, self)

        self.image_artist = imshow(self.axes, self.subset_array,
                                   origin='lower', interpolation='nearest',
                                   vmin=0, vmax=1, aspect=self._viewer_state.aspect)
        self.mpl_artists = [self.image_artist]
Beispiel #5
0
 def __init__(self, session, parent=None, state=None):
     super(ImageViewer, self).__init__(session, parent=parent, wcs=True, state=state)
     self.axes.set_adjustable('datalim')
     self.state.add_callback('x_att', self._set_wcs)
     self.state.add_callback('y_att', self._set_wcs)
     self.state.add_callback('slices', self._on_slice_change)
     self.state.add_callback('reference_data', self._set_wcs)
     self.axes._composite = CompositeArray()
     self.axes._composite_image = imshow(self.axes, self.axes._composite,
                                         origin='lower', interpolation='nearest')
     self._set_wcs()
Beispiel #6
0
 def __init__(self, session, parent=None, state=None):
     super(ImageViewer, self).__init__(session, parent=parent, wcs=True, state=state)
     self.axes.set_adjustable('datalim')
     self.state.add_callback('x_att', self._set_wcs)
     self.state.add_callback('y_att', self._set_wcs)
     self.state.add_callback('slices', self._set_wcs)
     self.state.add_callback('reference_data', self._set_wcs)
     self.axes._composite = CompositeArray()
     self.axes._composite_image = imshow(self.axes, self.axes._composite,
                                         origin='lower', interpolation='nearest')
     self._set_wcs()
Beispiel #7
0
 def setup_callbacks(self):
     self._wcs_set = False
     self._changing_slice_requires_wcs_update = None
     self.axes.set_adjustable('datalim')
     self.state.add_callback('x_att', self._set_wcs)
     self.state.add_callback('y_att', self._set_wcs)
     self.state.add_callback('slices', self._on_slice_change)
     self.state.add_callback('reference_data', self._set_wcs)
     self.axes._composite = CompositeArray()
     self.axes._composite_image = imshow(self.axes, self.axes._composite,
                                         origin='lower', interpolation='nearest')
     self._set_wcs()
Beispiel #8
0
 def setup_callbacks(self):
     self._wcs_set = False
     self._changing_slice_requires_wcs_update = None
     self.axes.set_adjustable('datalim')
     self.state.add_callback('x_att', self._set_wcs)
     self.state.add_callback('y_att', self._set_wcs)
     self.state.add_callback('slices', self._on_slice_change)
     self.state.add_callback('reference_data', self._set_wcs)
     self.axes._composite = CompositeArray()
     self.axes._composite_image = imshow(self.axes,
                                         self.axes._composite,
                                         origin='lower',
                                         interpolation='nearest')
     self._set_wcs()
Beispiel #9
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            self._axes.reset_wcs(wcs)
        self._im = imshow(self._axes, image, norm=self._norm, cmap='gray', **kwargs)
        self._im_array = image
        self._wcs = wcs
        self._redraw()
Beispiel #10
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            self._axes.reset_wcs(wcs)
        self._im = imshow(self._axes, image, norm=self._norm, cmap='gray', **kwargs)
        self._im_array = image
        self._wcs = wcs
        self._redraw()
Beispiel #11
0
    def __init__(self, axes, viewer_state, layer_state=None, layer=None):

        super(ImageSubsetLayerArtist, self).__init__(axes,
                                                     viewer_state,
                                                     layer_state=layer_state,
                                                     layer=layer)

        self.subset_array = ImageSubsetArray(self._viewer_state, self)

        self.image_artist = imshow(self.axes,
                                   self.subset_array,
                                   origin='lower',
                                   interpolation='nearest',
                                   vmin=0,
                                   vmax=1,
                                   aspect=self._viewer_state.aspect)
        self.mpl_artists = [self.image_artist]
Beispiel #12
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            # In the following we force the color and linewith of the WCSAxes
            # frame to be restored after calling reset_wcs. This can be removed
            # once we support Astropy 1.3.1 or later.
            color = self._axes.coords.frame.get_color()
            linewidth = self._axes.coords.frame.get_linewidth()
            self._axes.reset_wcs(wcs)
            self._axes.coords.frame.set_color(color)
            self._axes.coords.frame.set_linewidth(linewidth)
            del color, linewidth

        self._composite.set('image',
                            array=image,
                            color=colormaps.members[0][1])
        self._im = imshow(self._axes, self._composite, **kwargs)
        self._im_array = image
        self._set_norm(self._contrast_mode)

        if 'extent' in kwargs:
            self.axes.set_xlim(kwargs['extent'][:2])
            self.axes.set_ylim(kwargs['extent'][2:])
        else:
            ny, nx = image.shape
            self.axes.set_xlim(-0.5, nx - 0.5)
            self.axes.set_ylim(-0.5, ny - 0.5)

        # FIXME: for a reason I don't quite understand, dataLim doesn't
        # get updated immediately here, which means that there are then
        # issues in the first draw of the image (the limits are such that
        # only part of the image is shown). We just set dataLim manually
        # to avoid this issue. This is also done in ImageViewer.
        self.axes.dataLim.intervalx = self.axes.get_xlim()
        self.axes.dataLim.intervaly = self.axes.get_ylim()

        self._redraw()
Beispiel #13
0
    def set_image(self, image=None, wcs=None, **kwargs):
        """
        Update the image shown in the widget
        """
        if self._im is not None:
            self._im.remove()
            self._im = None

        kwargs.setdefault('origin', 'upper')

        if wcs is not None:
            # In the following we force the color and linewith of the WCSAxes
            # frame to be restored after calling reset_wcs. This can be removed
            # once we support Astropy 1.3.1 or later.
            color = self._axes.coords.frame.get_color()
            linewidth = self._axes.coords.frame.get_linewidth()
            self._axes.reset_wcs(wcs)
            self._axes.coords.frame.set_color(color)
            self._axes.coords.frame.set_linewidth(linewidth)
            del color, linewidth

        self._composite.set('image', array=image, color=colormaps.members[0][1])
        self._im = imshow(self._axes, self._composite, **kwargs)
        self._im_array = image
        self._set_norm(self._contrast_mode)

        if 'extent' in kwargs:
            self.axes.set_xlim(kwargs['extent'][:2])
            self.axes.set_ylim(kwargs['extent'][2:])
        else:
            ny, nx = image.shape
            self.axes.set_xlim(-0.5, nx - 0.5)
            self.axes.set_ylim(-0.5, ny - 0.5)

        # FIXME: for a reason I don't quite understand, dataLim doesn't
        # get updated immediately here, which means that there are then
        # issues in the first draw of the image (the limits are such that
        # only part of the image is shown). We just set dataLim manually
        # to avoid this issue. This is also done in ImageViewer.
        self.axes.dataLim.intervalx = self.axes.get_xlim()
        self.axes.dataLim.intervaly = self.axes.get_ylim()

        self._redraw()