def get_projected_map(self, header): map_shape = (header["naxis2"], header["naxis1"]) iy, ix = np.indices(map_shape) wcs = pywcs.WCS(header) phi, theta = wcs.wcs_pix2sky(ix, iy, 0) if self._coord is not None: from pywcsgrid2.wcs_helper import coord_system_guess, sky2sky map_coord = coord_system_guess(header["ctype1"], header["ctype2"], equinox=header["equinox"]) if (map_coord is not None) and (map_coord != self._coord): warnings.warn(" doing the conversion " + map_coord) phi, theta = sky2sky(map_coord, self._coord)(phi, theta) if self._flipy: theta -= 90 theta *= -np.pi/180. else: theta += 90 theta *= np.pi/180. phi *= np.pi/180 if self._nested: ang2pix = healpy._healpy_pixel_lib._ang2pix_nest else: ang2pix = healpy._healpy_pixel_lib._ang2pix_ring # some values could be NaNs. Maske those out before calling # ang2pix and recover them. mask = np.isfinite(theta) & np.isfinite(theta) ipix = ang2pix(self._nside, theta[mask], phi[mask]) map_data_ = self._data[ipix] map_data = np.empty(map_shape, dtype=map_data_.dtype) map_data.fill(np.nan) map_data.flat[mask] = map_data_ return map_data
def get_projected_map(self, header): map_shape = (header["naxis2"], header["naxis1"]) iy, ix = np.indices(map_shape) wcs = pywcs.WCS(header) phi, theta = wcs.wcs_pix2sky(ix, iy, 0) if self._coord is not None: from pywcsgrid2.wcs_helper import coord_system_guess, sky2sky map_coord = coord_system_guess(header["ctype1"], header["ctype2"], equinox=header["equinox"]) if (map_coord is not None) and (map_coord != self._coord): warnings.warn(" doing the conversion " + map_coord) phi, theta = sky2sky(map_coord, self._coord)(phi, theta) if self._flipy: theta -= 90 theta *= -np.pi / 180. else: theta += 90 theta *= np.pi / 180. phi *= np.pi / 180 if self._nested: ang2pix = healpy._healpy_pixel_lib._ang2pix_nest else: ang2pix = healpy._healpy_pixel_lib._ang2pix_ring # some values could be NaNs. Maske those out before calling # ang2pix and recover them. mask = np.isfinite(theta) & np.isfinite(theta) ipix = ang2pix(self._nside, theta[mask], phi[mask]) map_data_ = self._data[ipix] map_data = np.empty(map_shape, dtype=map_data_.dtype) map_data.fill(np.nan) map_data.flat[mask] = map_data_ return map_data
def get_projected_map(self, header): map_shape = (header["naxis2"], header["naxis1"]) iy, ix = np.indices(map_shape) wcs = pywcs.WCS(header) phi, theta = wcs.wcs_pix2sky(ix, iy, 0) if self._coord is not None: from pywcsgrid2.wcs_helper import coord_system_guess, sky2sky map_coord = coord_system_guess(header["ctype1"], header["ctype2"], equinox=header["equinox"]) if (map_coord is not None) and (map_coord != self._coord): warnings.warn(" doing the conversion " + map_coord) phi, theta = sky2sky(map_coord, self._coord)(phi, theta) if self._flipy: theta -= 90 theta *= -np.pi/180. else: theta += 90 theta *= np.pi/180. phi *= np.pi/180 if self._nested: ang2pix = healpy._healpy_pixel_lib._ang2pix_nest else: ang2pix = healpy._healpy_pixel_lib._ang2pix_ring ipix = ang2pix(self._nside, theta, phi) map_data = self._data[ipix].reshape(map_shape) return map_data