def convert_to_cached_wcs(self, hpx_in, sum_ebins=False, normalize=True):
        """ Make a WCS object and convert HEALPix data into WCS projection

        Parameters
        ----------
        hpx_in     : `~numpy.ndarray`
           HEALPix input data
        sum_ebins  : bool
           sum energy bins over energy bins before reprojecting
        normalize  : bool
           True -> perserve integral by splitting HEALPix values between bins

        returns (WCS object, np.ndarray() with reprojected data)
        """
        if self._hpx2wcs is None:
            raise Exception('HpxMap.convert_to_cached_wcs() called '
                            'before make_wcs_from_hpx()')

        if len(hpx_in.shape) == 1:
            wcs_data = np.ndarray(self._hpx2wcs.npix)
            loop_ebins = False
            hpx_data = hpx_in
        elif len(hpx_in.shape) == 2:
            if sum_ebins:
                wcs_data = np.ndarray(self._hpx2wcs.npix)
                hpx_data = hpx_in.sum(0)
                loop_ebins = False
            else:
                wcs_data = np.ndarray((self.counts.shape[0],
                                       self._hpx2wcs.npix[0],
                                       self._hpx2wcs.npix[1]))
                hpx_data = hpx_in
                loop_ebins = True
        else:
            raise Exception('Wrong dimension for HpxMap %i' %
                            len(hpx_in.shape))

        if loop_ebins:
            for i in range(hpx_data.shape[0]):
                self._hpx2wcs.fill_wcs_map_from_hpx_data(
                    hpx_data[i], wcs_data[i], normalize)
                pass
            wcs_data.reshape((self.counts.shape[0], self._hpx2wcs.npix[
                             0], self._hpx2wcs.npix[1]))
            # replace the WCS with a 3D one
            wcs = self.hpx.make_wcs(3, proj=self._wcs_proj,
                                    energies=np.log10(self.hpx.ebins),
                                    oversample=self._wcs_oversample)
        else:
            self._hpx2wcs.fill_wcs_map_from_hpx_data(
                hpx_data, wcs_data, normalize)
            wcs_data.reshape(self._hpx2wcs.npix)
            wcs = self._wcs_2d

        return wcs, wcs_data
def convert_to_cached_wcs ( self , hpx_in , sum_ebins = False , normalize = True ) : if self . _hpx2wcs is None : raise Exception ( 'HpxMap.convert_to_cached_wcs() called ' 'before make_wcs_from_hpx()' ) if len ( hpx_in . shape ) == 1 : wcs_data = np . ndarray ( self . _hpx2wcs . npix ) loop_ebins = False hpx_data = hpx_in elif len ( hpx_in . shape ) == 2 : if sum_ebins : wcs_data = np . ndarray ( self . _hpx2wcs . npix ) hpx_data = hpx_in . sum ( 0 ) loop_ebins = False else : wcs_data = np . ndarray ( ( self . counts . shape [ 0 ] , self . _hpx2wcs . npix [ 0 ] , self . _hpx2wcs . npix [ 1 ] ) ) hpx_data = hpx_in loop_ebins = True else : raise Exception ( 'Wrong dimension for HpxMap %i' % len ( hpx_in . shape ) ) if loop_ebins : for i in range ( hpx_data . shape [ 0 ] ) : self . _hpx2wcs . fill_wcs_map_from_hpx_data ( hpx_data [ i ] , wcs_data [ i ] , normalize ) pass wcs_data . reshape ( ( self . counts . shape [ 0 ] , self . _hpx2wcs . npix [ 0 ] , self . _hpx2wcs . npix [ 1 ] ) ) wcs = self . hpx . make_wcs ( 3 , proj = self . _wcs_proj , energies = np . log10 ( self . hpx . ebins ) , oversample = self . _wcs_oversample ) else : self . _hpx2wcs . fill_wcs_map_from_hpx_data ( hpx_data , wcs_data , normalize ) wcs_data . reshape ( self . _hpx2wcs . npix ) wcs = self . _wcs_2d return wcs , wcs_data
Make a WCS object and convert HEALPix data into WCS projection

        Parameters
        ----------
        hpx_in     : `~numpy.ndarray`
           HEALPix input data
        sum_ebins  : bool
           sum energy bins over energy bins before reprojecting
        normalize  : bool
           True -> perserve integral by splitting HEALPix values between bins

        returns (WCS object, np.ndarray() with reprojected data)