示例#1
0
def main(args):
    SetPlotStyle()

    # Params 'n' stuff
    fits_planck_mask = '../Data/mask_convergence_planck_2015_512.fits'
    fits_planck_map = '../Data/convergence_planck_2015_512.fits'
    twoMPZ_mask = 'fits/2MPZ_mask_tot_256.fits'  # N_side = 256
    twoMPZ_cat = 'fits/results16_23_12_14_73.fits'

    nside = args.nside
    do_plots = False
    delta_ell = args.delta_ell
    lmin = args.lmin
    lmax = args.lmax
    K_S_min = args.K_S_min
    K_S_max = args.K_S_max

    # Load Cat and Mask
    print("...loading 2MPZ catalogue...")
    twompz = Load2MPZ(twoMPZ_cat, K_S_min=K_S_min, K_S_max=K_S_max)
    print("...done...")

    # Load Planck CMB lensing map 'n' mask
    print("...loading Planck map/mask...")
    planck_map, planck_mask = LoadPlanck(fits_planck_map,
                                         fits_planck_mask,
                                         nside,
                                         do_plots=0,
                                         filt_plank_lmin=0)
    print("...done...")

    print("...reading 2MPZ mask...")
    mask = hp.read_map(twoMPZ_mask, verbose=False)
    nside_mask = hp.npix2nside(mask.size)
    if nside_mask != nside:
        mask = hp.ud_grade(mask, nside)
    print("...done...")

    # Common Planck & WISExSCOS mask
    mask *= planck_mask

    # Counts 'n' delta map
    cat_tmp = twompz[(twompz.ZSPEC >= args.zmin) & (twompz.ZSPEC < args.zmax)]
    counts = hpy.GetCountsMap(cat_tmp.RA,
                              cat_tmp.DEC,
                              nside,
                              coord='G',
                              rad=True)
    delta = hpy.Counts2Delta(counts, mask=mask)

    est = cs.Master(mask,
                    lmin=lmin,
                    lmax=lmax,
                    delta_ell=delta_ell,
                    MASTER=1,
                    pixwin=True)

    print('...extracting kg spectra...')
    kg, err_kg = est.get_spectra(planck_map, map2=delta, analytic_errors=True)
    print("\t=> Detection at rougly %3.2f sigma ") % (np.sum(
        (kg[0:] / err_kg[0:])**2)**.5)

    # Initializing Cosmo class
    cosmo = Cosmo()
    cosmo_nl = Cosmo(nonlinear=True)

    nz, z, _ = hist(twompz.ZSPEC[twompz.ZSPEC > 0.],
                    'knuth',
                    normed=1,
                    histtype='step')
    z = 0.5 * (z[1:] + z[:-1])
    plt.close()

    fig = plt.figure()  #figsize=(10, 8))

    ax = fig.add_subplot(1, 1, 1)
    plt.title(r'$%.2f < z < %.2f$' % (args.zmin, args.zmax))

    clkg = GetCrossSpectrum(cosmo,
                            z,
                            nz, [args.zmin, args.zmax],
                            b=1,
                            alpha=1.,
                            lmax=500,
                            sigma_zph=0.)
    clkg_nl = GetCrossSpectrum(cosmo_nl,
                               z,
                               nz, [args.zmin, args.zmax],
                               b=1,
                               alpha=1.,
                               lmax=500,
                               sigma_zph=0.)

    # z, n_z = GetdNdzNorm(nz=1000)
    # clkg = GetCrossSpectrum(cosmo, z, n_z, [bins_edges[zbin][0],0.3], b=1.24, alpha=1., lmax=1000)
    # # clkg = GetCrossSpectrum(cosmo, z, n_z, [bins_edges[zbin][0],bins_edges[zbin][1]], b=1, alpha=1.24, lmax=1000)
    # clkg_nl = GetCrossSpectrum(cosmo_nl, z, n_z, [bins_edges[zbin][0],0.5], b=1.24, alpha=1., lmax=1000)
    # # clkg_nl = GetCrossSpectrum(cosmo_nl, z, n_z, [bins_edges[zbin][0],bins_edges[zbin][1]], b=1.24, alpha=1., lmax=1000)
    # # clgg_pherrz = GetAutoSpectrum(cosmo, z, dndz, [bins_edges[zbin][0],bins_edges[zbin][1]], b=1.24, alpha=1., lmax=1000, sigma_zph=0.03)

    lab = r'2MPZ  $%.1f < K_S < %.1f$' % (K_S_min, K_S_max)
    ax.plot(clkg, color='grey', label=r'$b=1$')
    ax.plot(clkg_nl, color='darkgrey', ls='--', label=r'NL $b=1$')
    ax.errorbar(est.lb, kg, yerr=err_kg, fmt='o', capsize=0, ms=5, label=lab)
    ax.set_ylabel(r'$C_{\ell}^{\kappa g}$')
    ax.set_xlabel(r'Multipole $\ell$')
    ax.legend(loc='best')
    ax.axhline(ls='--', color='grey')
    ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
    ax.set_xlim([2., 200])
    ax.set_yscale('log')
    ax.set_ylim([1e-8, 1e-5])

    plt.tight_layout()
    plt.savefig('plots/2MPZ_Planck_clkg_dl' + str(args.delta_ell) + '_lmin_' +
                str(args.lmin) + '_lmax' + str(args.lmax) + '_KS_min_' +
                str(args.K_S_min) + '_KS_max_' + str(args.K_S_max) + '_nside' +
                str(args.nside) + '_zmin_' + str(args.zmin) + '_zmax' +
                str(args.zmax) + '_split_spec.pdf',
                bbox_inches='tight')
    # plt.show()
    # plt.close()

    # embed()

    np.savetxt(
        'spectra/2MPZ_Planck2015_clkg_dl' + str(args.delta_ell) + '_lmin_' +
        str(args.lmin) + '_lmax' + str(args.lmax) + '_KS_min_' +
        str(args.K_S_min) + '_KS_max_' + str(args.K_S_max) + '_nside' +
        str(args.nside) + '_zmin_' + str(args.zmin) + '_zmax' +
        str(args.zmax) + '_split_spec.dat', np.c_[est.lb, kg, err_kg])
示例#2
0
def main(args):
    SetPlotStyle()

    # Params 'n' stuff
    fits_planck_mask = '../Data/mask_convergence_planck_2015_512.fits'
    fits_planck_map = '../Data/convergence_planck_2015_512.fits'
    twoMPZ_mask = 'fits/2MPZ_mask_tot_256.fits'  # N_side = 256
    twoMPZ_cat = 'fits/results16_23_12_14_73.fits'
    twoMPZ_cat2 = 'fits/results2_14_20_37_1053.fits.gz'
    fits_ebv = 'fits/lambda_sfd_ebv.fits'
    nsidelow = 64
    nside = args.nside
    do_plots = False
    delta_ell = args.delta_ell
    lmin = args.lmin
    lmax = args.lmax
    K_S_min = args.K_S_min
    K_S_max = args.K_S_max
    # lbmin    = 2
    # lbmax    = 10

    # Load Cat and Mask
    print("...loading 2MPZ catalogue...")
    twompz = Load2MPZ(twoMPZ_cat, K_S_min=K_S_min, K_S_max=K_S_max)
    twompz2 = Load2MPZ(twoMPZ_cat2, K_S_min=K_S_min, K_S_max=K_S_max)
    print("...done...")

    # E(B-V) reddening map by Schlegel+ in gal coord at nside=512
    ebv = hp.read_map(fits_ebv, verbose=False)
    ebv = hp.ud_grade(ebv, nsidelow, pess=True)
    A_K = ebv * 0.367  # K-band correction for Galactic extinction
    print("...Reddening map loaded...")

    # Get nstar map
    nstar = GetNstarMap(twompz['RA'],
                        twompz['DEC'],
                        twompz['STARDENSITY'],
                        nsidelow,
                        rad=True)

    # Get 2MPZ mask (A_K + nstar + counts)
    # !!! "torque rod gashes" still need to be removed !!!
    mask2mpz = Get2MPZMask(A_K,
                           nstar,
                           nside=nside,
                           maskcnt=hpy.GuessMask(twompz['RA'],
                                                 twompz['DEC'],
                                                 nsidelow,
                                                 rad=True))
    print("Mask f_sky is %3.2f" % np.mean(mask2mpz))

    # Load Planck CMB lensing map 'n' mask
    print("...loading Planck map/mask...")
    planck_map, planck_mask = LoadPlanck(fits_planck_map,
                                         fits_planck_mask,
                                         nside,
                                         do_plots=0,
                                         filt_plank_lmin=0)
    print("...done...")

    print("...reading 2MPZ mask...")
    mask = hp.read_map(twoMPZ_mask, verbose=False)
    nside_mask = hp.npix2nside(mask.size)
    if nside_mask != nside:
        mask = hp.ud_grade(mask, nside)
    print("...done...")

    # Common Planck & WISExSCOS mask
    mask *= planck_mask

    # embed()

    # Counts n overdesnity map
    cat_tmp = twompz[(twompz.ZPHOTO >= args.zmin)
                     & (twompz.ZPHOTO < args.zmax)]
    a, b = train_test_split(cat_tmp, test_size=0.5)

    counts_a = hpy.GetCountsMap(a.RA, a.DEC, nside, coord='G', rad=True)
    counts_b = hpy.GetCountsMap(b.RA, b.DEC, nside, coord='G', rad=True)
    # hp.write_map('fits/counts_'+zbin+'_sum.fits', counts_sum[zbin])
    # hp.write_map('fits/counts_'+zbin+'_diff.fits', counts_diff[zbin])
    print("\tNumber of sources in bin [%.2f,%.2f) is %d" %
          (args.zmin, args.zmax, np.sum((counts_a + counts_b) * mask)))

    print("...converting to overdensity maps...")

    delta_a = hpy.Counts2Delta(counts_a, mask=mask)
    delta_b = hpy.Counts2Delta(counts_b, mask=mask)

    delta_sum = 0.5 * (delta_a + delta_b)
    delta_diff = 0.5 * (delta_a - delta_b)
    # hp.write_map('fits/delta_'+zbin+'_sum.fits', delta_sum[zbin])
    # hp.write_map('fits/delta_'+zbin+'_diff.fits', delta_diff[zbin])

    cat_tmp2 = twompz2[(twompz2.ZPHOTO >= args.zmin)
                       & (twompz2.ZPHOTO < args.zmax)]
    a, b = train_test_split(cat_tmp2, test_size=0.5)

    counts_a2 = hpy.GetCountsMap(a.RA, a.DEC, nside, coord='G', rad=True)
    counts_b2 = hpy.GetCountsMap(b.RA, b.DEC, nside, coord='G', rad=True)

    delta_a2 = hpy.Counts2Delta(counts_a2, mask=mask)
    delta_b2 = hpy.Counts2Delta(counts_b2, mask=mask)

    delta_sum2 = 0.5 * (delta_a2 + delta_b2)
    delta_diff2 = 0.5 * (delta_a2 - delta_b2)

    print("...done...")

    # embed()

    # exit()

    # XC estimator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    est_mask = cs.Master(mask,
                         lmin=lmin,
                         lmax=lmax,
                         delta_ell=delta_ell,
                         MASTER=0,
                         pixwin=True)
    # est_mask2mpz = cs.Master(mask2mpz, lmin=lmin, lmax=lmax, delta_ell=delta_ell, MASTER=0, pixwin=True)
    print('...extracting gg spectra...')

    clGS, err_gg = est_mask.get_spectra(delta_sum, analytic_errors=True)
    clGD = est_mask.get_spectra(delta_diff)
    gg = clGS - clGD

    clGS_2mpz, err_gg_2mpz = est_mask.get_spectra(delta_sum2,
                                                  analytic_errors=True)
    clGD_2mpz = est_mask.get_spectra(delta_diff2)
    gg_2mpz = clGS_2mpz - clGD_2mpz

    # clGS_2mpz, err_gg_2mpz = est_mask2mpz.get_spectra(delta_sum, analytic_errors=True)
    # clGD_2mpz = est_mask2mpz.get_spectra(delta_diff)
    # gg_2mpz = clGS_2mpz - clGD_2mpz

    print('...done...')

    # Initializing Cosmo class
    cosmo = Cosmo()
    cosmo_nl = Cosmo(nonlinear=True)

    nz, z, _ = hist(twompz.ZPHOTO, 'knuth', normed=1)
    z = 0.5 * (z[1:] + z[:-1])
    plt.close()

    fig = plt.figure()  #figsize=(10, 8))

    ax = fig.add_subplot(1, 1, 1)
    plt.title(r'$%.2f < z < %.2f$' % (args.zmin, args.zmax))

    # z, n_z  = GetdNdzNorm(nz=1000)
    # clgg    = GetAutoSpectrumMagLim( cosmo,    2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000)
    # clgg_ph = GetAutoSpectrumMagLim( cosmo_nl, 2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000, sigma_zph=0.03)
    # clgg_nl = GetAutoSpectrumMagLim( cosmo_nl, 2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000)
    clgg = GetAutoSpectrum(cosmo,
                           z,
                           nz, [args.zmin, args.zmax],
                           b=1.,
                           alpha=1.,
                           lmax=500,
                           sigma_zph=0.015,
                           i=0)
    clgg_nl = GetAutoSpectrum(cosmo_nl,
                              z,
                              nz, [args.zmin, args.zmax],
                              b=1.,
                              alpha=1.,
                              lmax=500,
                              sigma_zph=0.015,
                              i=0)
    # clgg    = GetAutoSpectrum(cosmo,   z,  dndz, [0., 0.08, 0.5], b=1.24, alpha=1., lmax=500, sigma_zph=0.015, i=i)
    # clgg_nl = GetAutoSpectrum(cosmo_nl, z, dndz, [0., 0.08, 0.5], b=1.24, alpha=1., lmax=500, sigma_zph=0.015, i=i)
    # ax = fig.add_subplot(1,1,i+1)
    lab = r'2MPZ  $%.1f < K_S < %.1f$' % (K_S_min, K_S_max)
    ax.plot(clgg, color='grey', label=r'$b=1$ $\sigma_z=0.015$')
    ax.plot(clgg_nl,
            color='darkgrey',
            ls='--',
            label=r'NL $b=1$ $\sigma_z=0.015$')
    ax.errorbar(est_mask.lb,
                gg,
                yerr=err_gg,
                fmt='o',
                capsize=0,
                ms=5,
                label=lab)
    ax.errorbar(est_mask.lb + 1,
                gg_2mpz,
                yerr=err_gg_2mpz,
                fmt='x',
                capsize=0,
                ms=5)  #, label=lab)
    ax.set_ylabel(r'$C_{\ell}^{gg}$')
    ax.set_xlabel(r'Multipole $\ell$')
    ax.legend(loc='best')
    ax.axhline(ls='--', color='grey')
    ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
    ax.set_xlim([2., 200])
    ax.set_yscale('log')
    ax.set_ylim([1e-5, 1e-3])

    plt.tight_layout()
    # plt.savefig('plots/2MPZ_clgg_dl'+str(args.delta_ell)+'_lmin_'+str(args.lmin)+'_lmax'+str(args.lmax)+'_KS_min_'+str(args.K_S_min)+'_KS_max_'+str(args.K_S_max)+'_nside'+str(args.nside)+'_zmin_'+str(args.zmin)+'_zmax'+str(args.zmax)+'_split.pdf', bbox_inches='tight')
    plt.show()
    # plt.close()

    embed()
示例#3
0
def main(args):
    SetPlotStyle()

    # Params 'n' stuff
    fits_planck_mask = '../Data/mask_convergence_planck_2015_512.fits'
    fits_planck_map = '../Data/convergence_planck_2015_512.fits'
    twoMPZ_mask = 'fits/2MPZ_mask_tot_256.fits'  # N_side = 256
    twoMPZ_cat = 'fits/results16_23_12_14_73.fits'
    nside = args.nside
    do_plots = False
    delta_ell = args.delta_ell
    lmin = args.lmin
    lmax = args.lmax
    K_S_min = args.K_S_min
    K_S_max = args.K_S_max
    # lbmin    = 2
    # lbmax    = 10

    # Load Cat and Mask
    print("...loading 2MPZ catalogue...")
    twompz = Load2MPZ(twoMPZ_cat, K_S_min=K_S_min, K_S_max=K_S_max)
    print("...done...")

    # Load Planck CMB lensing map 'n' mask
    print("...loading Planck map/mask...")
    planck_map, planck_mask = LoadPlanck(fits_planck_map,
                                         fits_planck_mask,
                                         nside,
                                         do_plots=0,
                                         filt_plank_lmin=0)
    print("...done...")

    print("...reading 2MPZ mask...")
    mask = hp.read_map(twoMPZ_mask, verbose=False)
    nside_mask = hp.npix2nside(mask.size)
    if nside_mask != nside:
        mask = hp.ud_grade(mask, nside)
    print("...done...")

    # Common Planck & WISExSCOS mask
    mask *= planck_mask

    # embed()

    # Counts n overdesnity map
    cat_tmp = twompz[(twompz.ZPHOTO >= args.zmin)
                     & (twompz.ZPHOTO < args.zmax)]
    a, b = train_test_split(cat_tmp, test_size=0.5)

    counts_a = hpy.GetCountsMap(a.RA, a.DEC, nside, coord='G', rad=True)
    counts_b = hpy.GetCountsMap(b.RA, b.DEC, nside, coord='G', rad=True)
    # hp.write_map('fits/counts_'+zbin+'_sum.fits', counts_sum[zbin])
    # hp.write_map('fits/counts_'+zbin+'_diff.fits', counts_diff[zbin])
    print("\tNumber of sources in bin [%.2f,%.2f) is %d" %
          (args.zmin, args.zmax, np.sum((counts_a + counts_b) * mask)))

    print("...converting to overdensity maps...")

    delta_a = hpy.Counts2Delta(counts_a, mask=mask)
    delta_b = hpy.Counts2Delta(counts_b, mask=mask)

    delta_sum = 0.5 * (delta_a + delta_b)
    delta_diff = 0.5 * (delta_a - delta_b)
    # hp.write_map('fits/delta_'+zbin+'_sum.fits', delta_sum[zbin])
    # hp.write_map('fits/delta_'+zbin+'_diff.fits', delta_diff[zbin])

    print("...done...")

    # embed()

    # exit()

    # XC estimator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    est = cs.Master(mask,
                    lmin=lmin,
                    lmax=lmax,
                    delta_ell=delta_ell,
                    MASTER=1,
                    pixwin=True)
    print('...extracting gg spectra...')

    clGS, err_gg = est.get_spectra(delta_sum, analytic_errors=True)
    clGD = est.get_spectra(delta_diff)
    gg = clGS - clGD
    counts_ = counts_a + counts_b
    delta_ = hpy.Counts2Delta(counts_, mask=mask)
    gg_, err_gg_ = est.get_spectra(delta_,
                                   nl=GetNlgg(counts_, mask=mask),
                                   pseudo=0,
                                   analytic_errors=True)
    print("\t=> Detection at rougly %.2f sigma ") % (np.sum(
        (gg[0:] / err_gg[0:])**2)**.5)
    print("\t=> Detection at rougly %.2f sigma ") % (np.sum(
        (gg_[0:] / err_gg_[0:])**2)**.5)

    print('...done...')

    # Initializing Cosmo class
    cosmo = Cosmo()
    cosmo_nl = Cosmo(nonlinear=True)

    nz, z, _ = hist(twompz.ZPHOTO, 'knuth', normed=1)
    z = 0.5 * (z[1:] + z[:-1])
    plt.close()

    fig = plt.figure()  #figsize=(10, 8))

    ax = fig.add_subplot(1, 1, 1)
    plt.title(r'$%.2f < z < %.2f$' % (args.zmin, args.zmax))

    # z, n_z  = GetdNdzNorm(nz=1000)
    # clgg    = GetAutoSpectrumMagLim( cosmo,    2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000)
    # clgg_ph = GetAutoSpectrumMagLim( cosmo_nl, 2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000, sigma_zph=0.03)
    # clgg_nl = GetAutoSpectrumMagLim( cosmo_nl, 2.21, 0.053, 1.43, bias=1.24, alpha=1., lmax=1000)
    clgg = GetAutoSpectrum(cosmo,
                           z,
                           nz, [args.zmin, args.zmax],
                           b=1.,
                           alpha=1.,
                           lmax=500,
                           sigma_zph=0.015,
                           i=0)
    clgg_nl = GetAutoSpectrum(cosmo_nl,
                              z,
                              nz, [args.zmin, args.zmax],
                              b=1.,
                              alpha=1.,
                              lmax=500,
                              sigma_zph=0.015,
                              i=0)
    # clgg    = GetAutoSpectrum(cosmo,   z,  dndz, [0., 0.08, 0.5], b=1.24, alpha=1., lmax=500, sigma_zph=0.015, i=i)
    # clgg_nl = GetAutoSpectrum(cosmo_nl, z, dndz, [0., 0.08, 0.5], b=1.24, alpha=1., lmax=500, sigma_zph=0.015, i=i)
    # ax = fig.add_subplot(1,1,i+1)
    lab = r'2MPZ  $%.1f < K_S < %.1f$' % (K_S_min, K_S_max)
    ax.plot(clgg, color='grey', label=r'$b=1$ $\sigma_z=0.015$')
    ax.plot(clgg_nl,
            color='darkgrey',
            ls='--',
            label=r'NL $b=1$ $\sigma_z=0.015$')
    ax.errorbar(est.lb, gg, yerr=err_gg, fmt='o', capsize=0, ms=5, label=lab)
    # ax.errorbar(est.lb+1, gg_[zbin], yerr=err_gg_[zbin], fmt='x', capsize=0, ms=5)#, label=lab)
    ax.set_ylabel(r'$C_{\ell}^{gg}$')
    ax.set_xlabel(r'Multipole $\ell$')
    ax.legend(loc='best')
    ax.axhline(ls='--', color='grey')
    ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
    ax.set_xlim([2., 200])
    ax.set_yscale('log')
    ax.set_ylim([1e-5, 1e-3])

    plt.tight_layout()
    plt.savefig('plots/2MPZ_clgg_dl' + str(args.delta_ell) + '_lmin_' +
                str(args.lmin) + '_lmax' + str(args.lmax) + '_KS_min_' +
                str(args.K_S_min) + '_KS_max_' + str(args.K_S_max) + '_nside' +
                str(args.nside) + '_zmin_' + str(args.zmin) + '_zmax' +
                str(args.zmax) + '_split.pdf',
                bbox_inches='tight')
    # plt.show()
    # plt.close()

    # embed()

    np.savetxt(
        'spectra/2MPZ_clgg_dl' + str(args.delta_ell) + '_lmin_' +
        str(args.lmin) + '_lmax' + str(args.lmax) + '_KS_min_' +
        str(args.K_S_min) + '_KS_max_' + str(args.K_S_max) + '_nside' +
        str(args.nside) + '_zmin_' + str(args.zmin) + '_zmax' +
        str(args.zmax) + '_split.dat', np.c_[est.lb, gg, err_gg])
fits_planck_mask = '../Data/mask_convergence_planck_2015_512.fits'
fits_planck_map = '../Data/convergence_planck_2015_512.fits'
twoMPZ_mask = 'fits/2MPZ_mask_tot_256.fits'  # N_side = 256
twoMPZ_cat = 'fits/results16_23_12_14_73.fits'

# Load Cat
print("...loading 2MPZ catalogue...")
twompz = Load2MPZ(twoMPZ_cat, K_S_min=K_S_min, K_S_max=K_S_max)
print("...done...")

# Read masks

# Load Planck CMB lensing map 'n' mask
planck_map, mask_planck_2015 = LoadPlanck(fits_planck_map,
                                          fits_planck_mask,
                                          nside,
                                          do_plots=0,
                                          filt_plank_lmin=0)
# mask_planck_2015 = LoadPlanckMask(fits_planck_mask, nside, do_plots=False)
mask_2MPZ = hp.read_map(twoMPZ_mask, verbose=False)
mask = mask_planck_2015 * mask_2MPZ

# Get the gal number density
cat_tmp = twompz[(twompz.ZPHOTO >= zmin) & (twompz.ZPHOTO < zmax)]
counts = hpy.GetCountsMap(cat_tmp.RA, cat_tmp.DEC, nside, coord='G', rad=True)
counts = hp.ma(counts)
counts.mask = np.logical_not(mask)
ngal = counts.mean()
ngal_sr = ngal / hp.nside2pixarea(nside)

print ngal, ngal_sr
示例#5
0
plt.legend(loc='best')
plt.tight_layout()
plt.subplots_adjust(left=0.2)
plt.savefig('plots/dNdz_2MPZ_KS_min_'+str(K_S_min)+'_KS_max_'+str(K_S_max)+'.pdf', bboxes_inches='tight')
plt.show()

embed()

exit()

# Load Planck CMB lensing map 'n' mask
fits_planck_mask = '../Data/mask_convergence_planck_2015_512.fits'
fits_planck_map  = '../Data/convergence_planck_2015_512.fits'
twoMPZ_mask = 'fits/2MPZ_mask_tot_256.fits' # N_side = 256
print("...loading Planck map/mask...")
planck_map, planck_mask = LoadPlanck(fits_planck_map, fits_planck_mask, nside, do_plots=0, filt_plank_lmin=0, pess=0)
print("...done...")

print("...reading 2MPZ mask...")
mask  = hp.read_map(twoMPZ_mask, verbose=False)
nside_mask = hp.npix2nside(mask.size)
if nside_mask != nside:
   mask = hp.ud_grade(mask, nside)
print("...done...")

# Common Planck & WISExSCOS mask  
mask *= planck_mask

# Counts 'n' delta map
counts = hpy.GetCountsMap(twompz.RA, twompz.DEC, nside, coord='G', rad=True)
delta  = hpy.Counts2Delta(counts, mask=mask)