示例#1
0
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")
plt.axis('off')

f_plot, mask_array, f_plot_imag, mask_array_imag = ssht.mollweide_projection(f_rot, L, resolution=200, rot=[0.0,np.pi,np.pi])
plt.subplot(1,2,2)
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")
示例#2
0
#% Load harmonic coefficients of Earth.
mat_contents = sio.loadmat('src/matlab/data/EGM2008_Topography_flms_L0128')

flm = np.ascontiguousarray(mat_contents['flm'][:, 0])

#% Smooth harmonic coefficients.
flm_smooth = ssht.guassian_smoothing(flm, L, sigma)

# Compute real space version of Earth.
f = ssht.inverse(flm, L, Reality=True)
f_smooth = ssht.inverse(flm_smooth, L, Reality=True)

# Plot
f_plot, mask_array = 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")
plt.axis('off')

f_plot, mask_array = ssht.mollweide_projection(f_smooth,
# Define parameters.
L = 64

# Generate random flms (of complex signal).
flm = np.random.randn(L*L) + 1j*np.random.randn(L*L)

# Compute inverse then forward transform.
f = ssht.inverse(flm, L);
flm_syn = ssht.forward(f, L);

# Compute max error in harmonic space.
maxerr = np.abs(flm_syn - flm).max()
print "Max error: ", maxerr

# Plot function on sphere using mollweide projection

f_plot, mask_array = ssht.mollweide_projection(np.abs(f), L, resolution=200)
plt.figure()
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|")
plt.axis('off')
plt.show()

plt.figure()


if  Add_noise:
	print "adding noise"
	shear = shear + 0.005*(np.random.randn(L,2*L-1) + 1j*np.random.randn(L,2*L-1))

print "Reconstruct on the sphere MW"
k_rec_mw, count = mm.reduced_shear_to_kappa_mw(shear, L, Iterate=Reduce_shear, Method=Method, tol_error=1E-10, return_count=True, sigma=-1)

if Reduce_shear:
	print "Number of iterations: ", count
print "rms error: ", np.sqrt(np.mean((k_rec_mw.real-k_mw)**2))




print "Plot original convergence"
f_plot, masked_array = ssht.mollweide_projection(k_mw, L, resolution=mol_resolution, Method=Method)
plt.figure()
imgplot = plt.imshow(f_plot,interpolation='nearest', cmap="cubehelix", vmin=-0.016, vmax=0.016)
plt.colorbar(imgplot,fraction=0.025, pad=0.04)
plt.imshow(masked_array, interpolation='nearest', cmap=cm.gray, vmin=-1., vmax=1.)
plt.gca().set_aspect("equal")
plt.title("Sphere kappa")
plt.axis('off')

print "Plot recovered convergence"
f_real_plot, mask_real, f_imag_plot, mask_imag = ssht.mollweide_projection(k_rec_mw, L, resolution=mol_resolution, Method=Method)
plt.figure()
imgplot = plt.imshow(f_real_plot,interpolation='nearest', cmap="cubehelix", vmin=-0.016, vmax=0.016)
plt.colorbar(imgplot,fraction=0.025, pad=0.04)
plt.imshow(mask_real, interpolation='nearest', cmap=cm.gray, vmin=-1., vmax=1.)
plt.gca().set_aspect("equal")