def make_lensing_field(conv_map, nside, fov_deg): print 'making lensing field from convergence map' jay=0.+1.j lx,ly=make_lxy_arrays(nside,fov_deg) #lx/=2. #ly/=2. l_arr=make_l_array(nside,fov_deg) #l_arr/=2. l_sq=l_arr*l_arr one_over_l_sq=1./l_sq one_over_l_sq[0,0]=1 lj=one_over_l_sq*jay fov_rad=(pi/180.)*fov_deg delta_theta=fov_rad/nside fft_conv_map=np.fft.fft2(conv_map) #fft_lensing_potential=lj*fft_conv_map fft_lensing_potential=one_over_l_sq*fft_conv_map*(2) #Heather added *2, changed lj to one_over_l_sq, add negative?? - if I put in a negative then reconstructed convergence is negative #check ps of phi - looking good :) l_vec,cl_tt, cl_ee, cl_te, cl_tt_lens, cl_ee_lens, cl_bb_lens, cl_te_lens, cl_kk=scal_power_spectra.spectra() cl_dd=cl_kk*4 / (l_vec*(l_vec+1)) cl_pp=cl_dd/(l_vec * (l_vec + 1.0)) """ l, phi_spec=scal_power_spectra.just_compute_power_spectrum(np.real(np.fft.ifft2(fft_lensing_potential)),fov_deg) plt.plot(l, np.sqrt(l*(l+1)/(2*pi)*phi_spec), label='from map') plt.plot(l_vec, np.sqrt(l_vec*(l_vec+1)/(2*pi)*cl_pp)) plt.xlim(1, 10000) plt.xscale('log') plt.yscale('log') plt.title('potential power spec') plt.show() """ fft_x_deflection=lx*jay*fft_lensing_potential #H added jay here and on next line fft_y_deflection=ly*jay*fft_lensing_potential x_deflection=np.real(np.fft.ifft2(fft_x_deflection)) #real y_deflection=np.real(np.fft.ifft2(fft_y_deflection)) print 'ave x deflection', np.mean(np.abs(x_deflection)) print 'ave y deflection', np.mean(np.abs(y_deflection)) """ plt.imshow(x_deflection*180/pi*60) plt.colorbar() plt.title ('x deflection') plt.show() plt.imshow(y_deflection*180/pi*60) plt.colorbar() plt.title ('y deflection') plt.show() plt.imshow(np.sqrt(x_deflection**2+y_deflection**2)*180/pi*60) plt.colorbar() plt.title ('deflection angle magnitude') plt.show() def_mag=np.sqrt(x_deflection**2+y_deflection**2) l, def_spec=scal_power_spectra.just_compute_power_spectrum(def_mag,fov_deg) l_alpha, c_alpha=scal_power_spectra.compute_deflection_spectrum(x_deflection,y_deflection,fov_deg) #relate to ps of dx and dy plt.plot(l_alpha, np.sqrt(l*(l+1)/(2*pi)*c_alpha), label='x and y combined from map') #plt.plot(l, np.sqrt(l*(l+1)/(2*pi)*(def_spec_x)), label='y from map') #plt.plot(l, np.sqrt(l*(l+1)/(2*pi)*(def_spec_y)), label='x from map') plt.plot(l, np.sqrt(l*(l+1)/(2*pi)*def_spec), label='from map') plt.plot(l_vec, np.sqrt(l_vec*(l_vec+1)/(2*pi)*cl_dd), label='from camb') plt.legend(loc='lower center') plt.xlim(1,10000) plt.xscale('log') plt.yscale('log') plt.xlabel('L') plt.ylabel(r'$[l(l+1)C^{\alpha\alpha}_L/2\pi]^{1/2}$') plt.title('deflection angle power spec') plt.show() """ x_displacement=np.real(np.fft.ifft2(fft_x_deflection))/delta_theta y_displacement=np.real(np.fft.ifft2(fft_y_deflection))/delta_theta result=(x_displacement,y_displacement) #result=(x_deflection, y_deflection) return(result)
cmap='Greys_r') plt.colorbar() plt.title(r'$|\tilde{T}-T|$') plt.show() plt.figure() plt.imshow(def_mod_map, origin='lower', extent=[0, fov_deg, 0, fov_deg], cmap='Greys_r') plt.colorbar() plt.title(r'$|\vec{\alpha}|$') plt.show() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - l_vec, cl_tt, cl_ee, cl_te, cl_tt_lens, cl_ee_lens, cl_bb_lens, cl_te_lens, cl_kk = scal_power_spectra.spectra( ) l_fac = l_vec * (l_vec + 1) / (2 * np.pi) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - plt.figure() plt.plot(l_vec, l_fac * cl_tt, label='unlensed', color='black') plt.plot(l_vec, l_fac * cl_tt_lens, label='lensed', color='black', linestyle='--') plt.xscale('log') plt.yscale('log') plt.xlim(1, 1e4) plt.ylim(1e-3, 1e4) plt.ylabel(r'$l$')