def test_make_equiangular_grid_contains_both_poles(self, resolution): """Equiangular grid must contain both poles.""" _, colatitude = sphere_utils.make_equiangular_grid(resolution) with self.subTest("North pole"): self.assertAllClose(colatitude[0], np.zeros_like(colatitude[0])) with self.subTest("South pole"): self.assertAllClose(colatitude[-1], np.full_like(colatitude[-1], np.pi))
def test_spherical_harmonics_backward(self, width, ell, m): r"""ISWSFT is Y_m^\ell when the only nonzero coeffs is 1. at (ell, m).""" n_coeffs = (width // 2)**2 coeffs = np.zeros(n_coeffs, dtype='complex128') coeffs[np_spin_spherical_harmonics._get_swsft_coeff_index(ell, m)] = 1 sphere = np_spin_spherical_harmonics.swsft_backward_naive(coeffs, 0) phi_g, theta_g = sphere_utils.make_equiangular_grid(width) sphere_gt = scipy.special.sph_harm(m, ell, phi_g, theta_g) self.assertAllClose(sphere, sphere_gt)
def test_spin_weighted_spherical_harmonics_forward(self, width): r"""SWSFT of sY_m^\ell has only one nonzero coefficient, at (ell, m).""" longitude_g, colatitude_g = sphere_utils.make_equiangular_grid(width) # We use some known expressions for spin-weighted spherical harmonics. # spin=1, ell=1, m=0: 1Y_0^1(a, b) \propto sin(b) Y110 = np.sin(colatitude_g) # pylint: disable=invalid-name coeffs = np_spin_spherical_harmonics.swsft_forward_naive(Y110, 1) self._check_nonzero_harmonic_coeffs(coeffs, 1, 0) # spin=1, ell=1, m=1: 1Y_1^1(a, b) \propto (1-cos(b))exp(ia) Y111 = (1 - np.cos(colatitude_g)) * np.exp(1j * longitude_g) # pylint: disable=invalid-name coeffs = np_spin_spherical_harmonics.swsft_forward_naive(Y111, 1) self._check_nonzero_harmonic_coeffs(coeffs, 1, 1) # spin=1, ell=1, m=-1: 1Y_{-1}^1(a, b) \propto (1+cos(b))exp(-ia) Y11m1 = (1 + np.cos(colatitude_g)) * np.exp(-1j * longitude_g) # pylint: disable=invalid-name coeffs = np_spin_spherical_harmonics.swsft_forward_naive(Y11m1, 1) self._check_nonzero_harmonic_coeffs(coeffs, 1, -1)
def test_spherical_harmonics_forward(self, width, ell, m): r"""SWSFT of Y_m^\ell has only one nonzero coefficient, at (ell, m).""" longitude_g, colatitude_g = sphere_utils.make_equiangular_grid(width) sphere = scipy.special.sph_harm(m, ell, longitude_g, colatitude_g) coeffs = np_spin_spherical_harmonics.swsft_forward_naive(sphere, 0) self._check_nonzero_harmonic_coeffs(coeffs, ell, m)