def alm2map(m, a_l, Nside): theta = get_ring_thetas(Nside) g = al2gmtheta(m, a_l, theta) Npix = 12 * Nside**2 map = np.zeros(Npix) g_m_theta = np.zeros((4 * Nside - 1, lmax + 1), dtype=np.complex) print g_m_theta.shape, g.shape # plt.clf() # plt.plot(g.real) g_m_theta[:, m] = g from wavemoth.fastsht import ShtPlan fake_input = np.zeros(1, dtype=np.cdouble) plan = ShtPlan(Nside, lmax, lmax, fake_input, map, 'mmajor') plan.perform_backward_ffts(0, 4 * Nside - 1) return map
from cmb.maps import pixel_sphere_map pixel_sphere_map(m[0, :]).plot(title=title) Nside = 256 lmax = 2 * Nside nmaps = 1 ring_counts = get_ring_pixel_counts(Nside) ring_offsets = np.cumsum(np.r_[0, ring_counts])[2 * Nside - 1:] input = np.zeros(((lmax + 1) * (lmax + 2) // 2, nmaps), dtype=np.complex128) sht_output = np.zeros((12 * Nside**2, nmaps)) psht_output = np.zeros((12 * Nside**2, nmaps), order='F') sht_plan = ShtPlan(Nside, lmax, lmax, input, sht_output, 'mmajor') psht_plan = PshtMmajorHealpix(lmax=lmax, Nside=Nside, nmaps=nmaps) def hash_array(x): h = hashlib.sha1() h.update(x) return h.hexdigest() def do_comparison(): psht_plan.alm2map(input, psht_output) sht_plan.execute() d = norm(sht_output - psht_output) f = norm(psht_output) # print d
lmax = 2 * Nside mstride = 100 bins = (lmax + 1) // mstride mstart = (lmax + 1) - mstride * bins print 'mstart', mstart nmaps = 1 J = 200 K_with = 200 K_without = 5 input = np.zeros(((lmax + 1) * (lmax + 2) // 2, nmaps), dtype=np.complex128) output = np.zeros((nmaps, 12 * Nside**2)) plan = ShtPlan(Nside, lmax, lmax, input, output, 'mmajor') t_with = np.zeros(J) t_without = np.zeros(J) # Try with strides print 'With strides...' for j in range(J): if j % 10 == 0: print j t0 = clock() plan.perform_legendre_transform(mstart, lmax + 1, mstride, repeat=K_with) t_with[j] = (clock() - t0) / K_with # Try without strides print 'Without strides...'
from wavemoth.fastsht import ShtPlan from wavemoth.psht import PshtMmajorHealpix from wavemoth import * from cPickle import dumps, loads assert os.environ['OMP_NUM_THREADS'] == '1' Nside = 128 lmax = 2 * Nside J = 200 input = np.zeros((lmax + 1)**2, dtype=np.complex128) output = np.zeros(12*Nside**2) plan = ShtPlan(Nside, lmax, lmax, input, output, 'mmajor') from cmb.maps import harmonic_sphere_map plan.execute(repeat=1) with benchmark('MC', J, profile=True): plan.execute(repeat=J) T = PshtMmajorHealpix(lmax=lmax, Nside=Nside) T.alm2map(input, output, repeat=1) with benchmark('healpix', J): T.alm2map(input, output, repeat=J) # with benchmark('M', J): # for j in range(J * mstride):
lmax = 2 * Nside mstride = 100 bins = (lmax + 1) // mstride mstart = (lmax + 1) - mstride * bins print 'mstart', mstart nmaps = 1 J = 200 K_with = 200 K_without = 5 input = np.zeros(((lmax + 1) * (lmax + 2) // 2, nmaps), dtype=np.complex128) output = np.zeros((nmaps, 12 * Nside**2)) plan = ShtPlan(Nside, lmax, lmax, input, output, 'mmajor') t_with = np.zeros(J) t_without = np.zeros(J) # Try with strides print 'With strides...' for j in range(J): if j % 10 == 0: print j t0 = clock() plan.perform_legendre_transform(mstart, lmax + 1, mstride, repeat=K_with) t_with[j] = (clock() - t0) / K_with # Try without strides print 'Without strides...' for j in range(J):