How to use the healpy.anafast function in healpy

To help you get started, we’ve selected a few healpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LSSTDESC / NaMaster / test / test_nmt_utils.py View on Github external
def anafast(self,mps) :
        return hp.anafast(mps)
github damonge / CoLoRe / test / study_pk.py View on Github external
lt,cls_dd=np.loadtxt('test/outlj_cl_dd.txt',unpack=True);
lt,clt_dl=np.loadtxt('test/outlj_cl_d1l2.txt',unpack=True);
lt,clt_ll=np.loadtxt('test/outlj_cl_ll.txt',unpack=True);
lt,clt_kd=np.loadtxt('test/outlj_cl_dc.txt',unpack=True);
lt,clt_kk=np.loadtxt('test/outlj_cl_cc.txt',unpack=True);
lt,clt_id=np.loadtxt('test/outlj_cl_di.txt',unpack=True);
lt,clt_ii=np.loadtxt('test/outlj_cl_ii.txt',unpack=True);
cln_dd=np.ones_like(lt)/ndens
clt_dd=cls_dd+cln_dd
cld_dd,cld_ee,cld_bb,cld_de,cld_eb,cld_db=hp.anafast(np.array([mp_d,mp_e1,mp_e2]),pol=True);
ld=np.arange(len(cld_dd));

#Analyze kappa
mp_k=hp.read_map("test/out_kappa_z000.fits")
cld_kk=hp.anafast(mp_k); ld=np.arange(len(cld_kk))
cld_kd=hp.anafast(mp_k,map2=mp_d)

#Analyze ISW
mp_i=hp.read_map("test/out_isw_z000.fits")
cld_ii=hp.anafast(mp_i); ld=np.arange(len(cld_ii))
cld_id=hp.anafast(mp_i,map2=mp_d)

#Plots
hp.mollview(mp_d);
hp.mollview(mp_E);
hp.mollview(mp_B);
hp.mollview(mp_e1);
hp.mollview(mp_e2);
hp.mollview(mp_k)
hp.mollview(mp_i)
plt.figure()
github damonge / CoLoRe / test / study_pk.py View on Github external
lt,clt_id=np.loadtxt('test/outlj_cl_di.txt',unpack=True);
lt,clt_ii=np.loadtxt('test/outlj_cl_ii.txt',unpack=True);
cln_dd=np.ones_like(lt)/ndens
clt_dd=cls_dd+cln_dd
cld_dd,cld_ee,cld_bb,cld_de,cld_eb,cld_db=hp.anafast(np.array([mp_d,mp_e1,mp_e2]),pol=True);
ld=np.arange(len(cld_dd));

#Analyze kappa
mp_k=hp.read_map("test/out_kappa_z000.fits")
cld_kk=hp.anafast(mp_k); ld=np.arange(len(cld_kk))
cld_kd=hp.anafast(mp_k,map2=mp_d)

#Analyze ISW
mp_i=hp.read_map("test/out_isw_z000.fits")
cld_ii=hp.anafast(mp_i); ld=np.arange(len(cld_ii))
cld_id=hp.anafast(mp_i,map2=mp_d)

#Plots
hp.mollview(mp_d);
hp.mollview(mp_E);
hp.mollview(mp_B);
hp.mollview(mp_e1);
hp.mollview(mp_e2);
hp.mollview(mp_k)
hp.mollview(mp_i)
plt.figure()
plt.hist(mp_e1,bins=100,histtype='step');
plt.hist(mp_e2,bins=100,histtype='step');
plt.figure()
plt.plot(ld,cld_dd,'r-',label='$\\delta_g\\times\\delta_g$',lw=2)
plt.plot(ld,cld_ee,'y-',label='$\\gamma^E_g\\times\\gamma^E_g$',lw=2)
plt.plot(ld,cld_de,'c-',label='$\\gamma^E_g\\times\\delta_g$',lw=2)
github damonge / CoLoRe / test / study_pk.py View on Github external
lt,cls_dd=np.loadtxt('test/outlj_cl_dd.txt',unpack=True);
lt,clt_dl=np.loadtxt('test/outlj_cl_d1l2.txt',unpack=True);
lt,clt_ll=np.loadtxt('test/outlj_cl_ll.txt',unpack=True);
lt,clt_kd=np.loadtxt('test/outlj_cl_dc.txt',unpack=True);
lt,clt_kk=np.loadtxt('test/outlj_cl_cc.txt',unpack=True);
lt,clt_id=np.loadtxt('test/outlj_cl_di.txt',unpack=True);
lt,clt_ii=np.loadtxt('test/outlj_cl_ii.txt',unpack=True);
cln_dd=np.ones_like(lt)/ndens
clt_dd=cls_dd+cln_dd
cld_dd,cld_ee,cld_bb,cld_de,cld_eb,cld_db=hp.anafast(np.array([mp_d,mp_e1,mp_e2]),pol=True);
ld=np.arange(len(cld_dd));

#Analyze kappa
mp_k=hp.read_map("test/out_kappa_z000.fits")
cld_kk=hp.anafast(mp_k); ld=np.arange(len(cld_kk))
cld_kd=hp.anafast(mp_k,map2=mp_d)

#Analyze ISW
mp_i=hp.read_map("test/out_isw_z000.fits")
cld_ii=hp.anafast(mp_i); ld=np.arange(len(cld_ii))
cld_id=hp.anafast(mp_i,map2=mp_d)

#Plots
hp.mollview(mp_d);
hp.mollview(mp_E);
hp.mollview(mp_B);
hp.mollview(mp_e1);
hp.mollview(mp_e2);
hp.mollview(mp_k)
hp.mollview(mp_i)
plt.figure()
plt.hist(mp_e1,bins=100,histtype='step');
github astroML / astroML / examples / datasets / plot_wmap_power_spectra.py View on Github external
hp.mollview(wmap_unmasked, min=-1, max=1, title='Unmasked map',
            fig=1, unit=r'$\Delta$T (mK)')

#------------------------------------------------------------
# plot the masked map
#  filled() fills the masked regions with a null value.
fig = plt.figure(2)
hp.mollview(wmap_masked.filled(), title='Masked map',
            fig=2, unit=r'$\Delta$T (mK)')

#------------------------------------------------------------
# compute and plot the power spectrum
cl = hp.anafast(wmap_masked.filled(), lmax=1024)
ell = np.arange(len(cl))

cl_white = hp.anafast(white_noise, lmax=1024)

fig = plt.figure(3)
ax = fig.add_subplot(111)
ax.scatter(ell, ell * (ell + 1) * cl,
           s=4, c='black', lw=0,
           label='data')
ax.scatter(ell, ell * (ell + 1) * cl_white,
           s=4, c='gray', lw=0,
           label='white noise')

ax.set_xlabel(r'$\ell$')
ax.set_ylabel(r'$\ell(\ell+1)C_\ell$')
ax.set_title('Angular Power (not mask corrected)')
ax.legend(loc='upper right')
ax.grid()
ax.set_xlim(0, 1100)
github healpy / healpy / doc / create_images.py View on Github external
unit="mK",
    norm="hist",
    min=-1,
    max=1,
    xsize=SIZE,
)
hp.graticule()

plt.savefig("static/wmap_histeq_ecl.png", dpi=DPI)
mask = hp.read_map(
    "../healpy/test/data/wmap_temperature_analysis_mask_r9_7yr_v4.fits"
).astype(np.bool)
wmap_map_I_masked = hp.ma(wmap_map_I)
wmap_map_I_masked.mask = np.logical_not(mask)
LMAX = 1024
cl = hp.anafast(wmap_map_I_masked.filled(), lmax=LMAX)
ell = np.arange(len(cl))
plt.figure()
plt.plot(ell, ell * (ell + 1) * cl)
plt.xlabel("ell")
plt.ylabel("ell(ell+1)cl")
plt.grid()

plt.savefig("static/wmap_powspec.png", dpi=DPI)
github LSSTDESC / NaMaster / sandbox_validation / data / get_lss_contaminants.py View on Github external
if o.plot_stuff :    
    mpzero=np.zeros_like(msk)
    cwp_q,cwp_u=hp.read_map("cont_wl_psf_ns%d.fits"%o.nside_out,field=[0,1],verbose=False)
    cws_q,cws_u=hp.read_map("cont_wl_ss_ns%d.fits"%o.nside_out,field=[0,1],verbose=False)                            
    cld=hp.read_map("cont_lss_dust_ns%d.fits"%o.nside_out,field=0,verbose=False)
    cls=hp.read_map("cont_lss_star_ns%d.fits"%o.nside_out,field=0,verbose=False)
    dl,dw_q,dw_u=hp.synfast([cltt[:3*o.nside_out],clee[:3*o.nside_out],clbb[:3*o.nside_out],clte[:3*o.nside_out]],o.nside_out,new=True,verbose=False,pol=True)
    tl=dl+cls+cld
    tw_q=dw_q+cwp_q+cws_q; tw_u=dw_u+cwp_u+cws_u;
    c_l_cdcd=hp.anafast(cld*msk)/fsky
    c_l_cscs=hp.anafast(cls*msk)/fsky
    c_l_dd=hp.anafast(dl*msk)/fsky
    c_l_tt=hp.anafast(tl*msk)/fsky
    c_l_dd_tt,c_w_dd_ee,c_w_dd_bb,c_l_dd_te,dum1,dum2=hp.anafast([dl,dw_q,dw_u],pol=True)
    c_l_tt_tt,c_w_tt_ee,c_w_tt_bb,c_l_tt_te,dum1,dum2=hp.anafast([tl,tw_q,tw_u],pol=True)
    dum1,c_w_cscs_ee,c_w_cscs_bb,dum2,dum3,dum4=hp.anafast([mpzero,cws_q,cws_u],pol=True)
    dum1,c_w_cpcp_ee,c_w_cpcp_bb,dum2,dum3,dum4=hp.anafast([mpzero,cwp_q,cwp_u],pol=True)
    
    plt.figure();
    plt.plot(larr,c_l_dd,label='True $\\delta_g$')
    plt.plot(larr,c_l_cdcd,label='Dust contaminant')
    plt.plot(larr,c_l_cscs,label='Star contaminant')
    plt.plot(larr,c_l_tt,label='Contaminated $\\delta_g$')
    plt.xlabel('$\\ell$',fontsize=18);
    plt.ylabel('$C_\\ell$',fontsize=18);
    plt.legend(); plt.loglog(); plt.xlim([2,3*o.nside_out])
    
    plt.figure()
    plt.plot(larr,c_w_dd_ee,label='True $\\gamma_g$ EE')
    plt.plot(larr,c_w_cpcp_ee,label='PSF contaminant EE')
    plt.plot(larr,c_w_cscs_ee,label='Small-scale contaminant EE')
    plt.plot(larr,c_w_tt_ee,label='Contaminated $\\gamma_g$ EE')