def spherical_beam(self, coordinate, bls, thetamax=10 * u.deg): if self.ordering.upper() == 'RING': nest = False else: nest = True v1 = coord2vec(coordinate) nside2 = 4 * self.nside npix2 = hp.nside2npix(nside2) beam_map = np.zeros(npix2) listpix = hp.query_disc(nside2, v1, thetamax.to(u.rad).value, inclusive=True, nest=nest) for pixel in listpix: v2 = hp.pix2vec(nside2, pixel, nest=nest) d = hp.rotator.angdist(v1, v2) * u.rad d = d.value beam_map[pixel] = hp.bl2beam(bls, d) beam_map = hp.ud_grade(beam_map, self.nside, order_in=self.ordering) beam_map = beam_map / beam_map.max() return Fitsmap(beam_map, self.mask, self.header, self.ordering)
def test_bl2beam(self): """ Test bl2beam against analytical transform of Gaussian beam. """ theta = np.linspace(0, np.radians(3.), 1000) sigma = np.radians(1.) / np.sqrt(8. * np.log(2.)) gaussian_beam = np.exp(-.5 * (theta / sigma) ** 2) / (2 * np.pi * sigma ** 2) ell = np.arange(2048 + 1.) gaussian_window = np.exp(-.5 * ell * (ell + 1) * sigma ** 2) beam = hp.bl2beam(gaussian_window, theta) np.testing.assert_allclose(gaussian_beam, beam, rtol=1e-3)
def test_bl2beam(self): """ Test bl2beam against analytical transform of Gaussian beam. """ theta = np.linspace(0, np.radians(3.0), 1000) sigma = np.radians(1.0) / np.sqrt(8.0 * np.log(2.0)) gaussian_beam = np.exp(-0.5 * (theta / sigma) ** 2) / (2 * np.pi * sigma ** 2) ell = np.arange(2048 + 1.0) gaussian_window = np.exp(-0.5 * ell * (ell + 1) * sigma ** 2) beam = hp.bl2beam(gaussian_window, theta) np.testing.assert_allclose(gaussian_beam, beam, rtol=1e-3)
def flat_beam(self, coordinate, bls, npix=512, deltatheta_deg=14.658): p0 = self.patch(coordinate, npix * 4, deltatheta_deg=deltatheta_deg) dmap = np.zeros(p0.datos.shape) cent = [x // 2 for x in p0.size] for i in range(npix * 4): for j in range(i, npix * 4): d = p0.angular_distance(cent[0], cent[1], i, j)[0].to(u.rad).value dmap[i, j] = d dmap[j, i] = d p1 = Imagen(hp.bl2beam(bls, dmap), p0.centro, p0.size, p0.pixsize) p2 = p1.downsample(factor=4, func=np.mean) return p2