Exemple #1
0
    def load_nddata(self, nddata):
        """
        Load an ``NDData`` object into the viewer.

        .. todo:: Add flag/masking support, etc.

        Parameters
        ----------
        nddata : `~astropy.nddata.NDData`
            ``NDData`` with image data and WCS.

        """
        from ginga.util.wcsmod.wcs_astropy import AstropyWCS

        image = AstroImage(logger=self.logger)
        image.set_data(nddata.data)
        _wcs = AstropyWCS(self.logger)
        if nddata.wcs:
            _wcs.load_header(nddata.wcs.to_header())

        try:
            image.set_wcs(_wcs)
        except Exception as e:
            print('Unable to set WCS from NDData: {}'.format(str(e)))
        self._viewer.set_image(image)
Exemple #2
0
    def _mtv(self, image, mask=None, wcs=None, title=""):
        """Display an Image and/or Mask on a ginga display"""
        self._erase()
        self._canvas.delete_all_objects()

        Aimage = AstroImage(inherit_primary_header=True)
        Aimage.set_data(image.getArray())

        self._gingaViewer.set_image(Aimage)

        if wcs is not None:
            _wcs = AstropyWCS(self.logger)
            Aimage.lsst_wcs = WcsAdaptorForGinga(wcs)
            _wcs.pixtoradec = Aimage.lsst_wcs.pixtoradec
            _wcs.pixtosystem = Aimage.lsst_wcs.pixtosystem
            _wcs.radectopix = Aimage.lsst_wcs.radectopix

            Aimage.set_wcs(_wcs)
            Aimage.wcs.wcs = Aimage.lsst_wcs

        if mask:
            maskColorFromName = {
                'BAD': 'red',
                'SAT': 'green',
                'INTRP': 'green',
                'CR': 'magenta',
                'EDGE': 'yellow',
                'DETECTED': 'blue',
                'DETECTED_NEGATIVE': 'cyan',
                'SUSPECT': 'yellow',
                'NO_DATA': 'orange',
                'CROSSTALK': None,
                'UNMASKEDNAN': None
            }
            maskDict = dict()
            for plane, bit in mask.getMaskPlaneDict().items():
                color = maskColorFromName.get(plane, None)
                if color:
                    maskDict[1 << bit] = color
            # CZW: This value of 0.9 is pretty thick for the alpha.
            self.overlay_mask(mask, maskDict, self._maskTransparencyAlpha)
        self._flush()