Beispiel #1
0
def test_rot(complex_coeffs, order):
    gamma = np.pi / 5
    beta = np.pi / 7
    alpha = -np.pi / 3

    ssht_rot = ssht.rotate_flms(complex_coeffs, alpha, beta, gamma, order)
    ducc0_rot = ssht.rotate_flms(complex_coeffs,
                                 alpha,
                                 beta,
                                 gamma,
                                 order,
                                 backend="ducc")
    assert ssht_rot == approx(ducc0_rot)
def sYlm(s, l, m, L, rotation=None):
    flm = np.zeros(L*L, dtype=complex)
    ind = ssht.elm2ind(l, m)
    flm[ind] = 1.0
    if rotation:
        flm = ssht.rotate_flms(flm, rotation[0], rotation[1], rotation[2], L)
    f = ssht.inverse(flm, L, Spin=s)
    return f
Beispiel #3
0
def test_rot(L, nthreads=1):
    gamma = np.pi / 5
    beta = np.pi / 7
    alpha = -np.pi / 3

    flm = np.random.randn(L * L) + 1j * np.random.randn(L * L)

    t0 = time()
    flm_rot = ssht.rotate_flms(flm,
                               alpha,
                               beta,
                               gamma,
                               L,
                               backend="ducc",
                               nthreads=nthreads)
    tducc = time() - t0
    t0 = time()
    flm_rot2 = ssht.rotate_flms(flm, alpha, beta, gamma, L)
    tssht = time() - t0
    return (_l2error(flm_rot, flm_rot2), tssht / tducc)
Beispiel #4
0
m = 2
gamma = np.pi/2
beta = np.pi/4
alpha = -np.pi/2

# Generate spherical harmonics.
flm = np.zeros((L*L),dtype=complex);
ind = ssht.elm2ind(el, m);
flm[ind] = 1.0 + 1j*0.0;

# Compute function on the sphere.
f = ssht.inverse(flm, L)


# Rotate spherical harmonic
flm_rot = ssht.rotate_flms(flm, alpha, beta, gamma, L)


# Compute rotated function on the sphere.
f_rot = ssht.inverse(flm_rot, L)


# Plot
f_plot, mask_array, f_plot_imag, mask_array_imag = ssht.mollweide_projection(f, L, resolution=200, rot=[0.0,np.pi,np.pi])
plt.figure()
plt.subplot(1,2,1)
imgplot = plt.imshow(f_plot,interpolation='nearest')
plt.colorbar(imgplot,fraction=0.025, pad=0.04)
plt.imshow(mask_array, interpolation='nearest', cmap=cm.gray, vmin=-1., vmax=1.)
plt.gca().set_aspect("equal")
plt.title("f")
Beispiel #5
0
L=256
thetas, phis = ssht.sample_positions(L, Grid=True)

f = np.zeros((L,2*L-1), dtype=np.float_) + np.random.randn(L,2*L-1)
#ssht.plot_sphere(phis, L,Parametric=False, Output_File='test.pdf',Show=False, Color_Bar=True, Units='Radians')

(x, y, z) = ssht.s2_to_cart(thetas, phis)
(x, y, z) = ssht.spherical_to_cart( np.ones(thetas.shape), thetas, phis)


#test rotations
flm = ssht.forward(phis, L, Reality=True)
f = ssht.inverse(flm,L, Reality=True)


flm_prime = ssht.rotate_flms(flm, np.pi/4, np.pi/4, np.pi/4, L)
f_prime = ssht.inverse(flm_prime, L, Reality=True)

#ssht.plot_sphere(f, L,Parametric=False, Output_File='test_phi_sphere.pdf',Show=False, Color_Bar=True, Units='Radians')
#ssht.plot_sphere(f_prime, L,Parametric=False, Output_File='test_phi_rot_sphere.pdf',Show=False, Color_Bar=True, Units='Radians')


#plot = ssht.plot_mollweide(f, L, Close=True)
#plt.show()
#plot2 = ssht.plot_mollweide(f_prime, L, Close=True)
#plt.show()

# transform tests


L = 128