コード例 #1
0
def writexipbias(samples,rhosfilenames,xim=False, plots=False,nameterms='terms_dxi.png',namedxip='dxi.png',namecovmat='covmat_pars.png',filename='dxip.fits'):
    from readjson import read_rhos
    from maxlikelihood import bestparameters
    from plot_stats import pretty_rho
    from readfits import read_corr
    from astropy.io import fits
    import numpy as np

    #plot covariance matrix of parameters alpha, beta and eta.
    if plots:
        par_matcov = np.cov(samples)
        corr=corrmatrix(par_matcov)
        print(par_matcov)
        print(corr)
        cov_vmin=np.min(corr)
        plt.imshow(corr,cmap='viridis'+'_r', interpolation='nearest',
                   aspect='auto', origin='lower', vmin=cov_vmin, vmax=1.)
        plt.colorbar()
        plt.title(r'$\alpha \mid \beta \mid \eta $')
        plt.savefig(namecovmat, dpi=500)
        print(namecovmat, 'Printed!')

    a = b = n = 0; vara =  varb =  varn = 0; covab = covan = covbn = 0
    bestpar = bestparameters(samples)
    par_matcov = np.cov(samples) 
    if (par_matcov.size==1 ): variances = par_matcov
    else: variances = np.diagonal(par_matcov)
    covariances = sum( (par_matcov[i,i+1: ].tolist() for i in range(len(samples) - 1)) , [] )
    if(len(samples)==3):
        a, b, n = bestpar
        vara, varb, varn =  variances
        covab, covan, covbn =  covariances
    elif(len(samples)==2):
        a, b = bestpar
        vara, varb =  variances
        covab =  covariances[0]
    elif(len(samples)==1):
        a =  bestpar[0]
        vara =  variances
    else:
        print("Warning, test type not defined")
    
    
    rhonames = args.rhos
    meanr, rho0, cov_rho0 = read_corr(rhonames[0])
    meanr, rho1, cov_rho1 = read_corr(rhonames[1])
    meanr, rho2, cov_rho2 = read_corr(rhonames[2])
    meanr, rho3, cov_rho3 = read_corr(rhonames[3])
    meanr, rho4, cov_rho4 = read_corr(rhonames[4])
    meanr, rho5, cov_rho5 = read_corr(rhonames[5])
    sig_rho0 =  np.sqrt(np.diag(cov_rho0))
    sig_rho1 =  np.sqrt(np.diag(cov_rho1))
    sig_rho2 =  np.sqrt(np.diag(cov_rho2))
    sig_rho3 =  np.sqrt(np.diag(cov_rho3))
    sig_rho4 =  np.sqrt(np.diag(cov_rho4))
    sig_rho5 =  np.sqrt(np.diag(cov_rho5))

    #Ploting each term of the bias
    if(plots):
        xlim = [2., 300.]
        #supposing that a,b and n are idependent of rhos(scale independent)
        var0 = ((2*a*rho0p)**2)*vara +  (a**2)*(sig_rho0**2)
        var1 = ((2*b*rho1p)**2)*varb +  (b**2)*(sig_rho1**2)
        var2 = ((2*n*rho3p)**2)*varn +  (n**2)*(sig_rho3**2)
        varab =  vara*(b**2) + varb*(a**2) + 2*covab*(a*b)
        #varab = ((a*b)**2)*( (vara/((a)**2)) + (varb/((b)**2)) + 2*covab/(a*b) )
        var3 = 4*( (rho2p**2)*varab + (sig_rho2**2)*((a*b)**2)  )
        #var3 = 4*((a*b*rho2p)**2)*( varab/((a*b)**2) + (sig_rho2/rho2p)**2 )
        varbn =  varn*(b**2) + varb*(n**2) + 2*covbn*(b*n)
        #varbn = ((n*b)**2)*( (varn/((n)**2)) + (varb/((b)**2)) + 2*covbn/(b*n) ) 
        var4 = 4*( (rho4p**2)*varbn + (sig_rho4**2)*((n*b)**2)  )
        #var4 = 4*((n*b*rho4p)**2)*(varbn/((b*n)**2) + (sig_rho4/rho4p)**2)
        varan = varn*(a**2) + vara*(n**2) + 2*covan*(a*n)
        #varan = ((n*a)**2)*( (varn/((n)**2)) + (vara/((a)**2)) + 2*covan/(a*n) ) 
        var5 = 4*( (rho5p**2)*varan + (sig_rho5**2)*((n*a)**2)  )
        #var5 = 4*((n*a*rho5p)**2)*(varan/((a*n)**2) + (sig_rho5/rho5p)**2) 
        plt.clf()
        lfontsize = 7
        if (len(samples)==3):
            pretty_rho(meanr, (a**2)*rho0p, np.sqrt(np.diag(cov_rho0)), legend=r'$\alpha^{2} \rho_{0}$',lfontsize=lfontsize,  color='red', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (b**2)*rho1p, np.sqrt(var1), legend=r'$\beta^{2}\rho_{1}$',lfontsize=lfontsize,  color='green', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (n**2)*rho3p, np.sqrt(var2), legend=r'$\eta^{2}\rho_{3}$', lfontsize=lfontsize, color='black', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (2*a*b)*rho2p, np.sqrt(var3), legend=r'$2\alpha\beta \rho_{2}$',lfontsize=lfontsize,  color='yellow', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (2*b*n)*rho4p, np.sqrt(var4), legend=r'$2\beta\eta\rho_{4}$',lfontsize=lfontsize,  color='blue', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (2*n*a)*rho5p, np.sqrt(var5), legend=r'$2\eta\alpha\rho_{5}$', lfontsize=lfontsize, color='gray', ylabel='Correlations', xlim=xlim)
            print('Printing',  nameterms)
            plt.savefig(nameterms, dpi=200)
        if (len(samples)==2):
            pretty_rho(meanr, (a**2)*rho0p, np.sqrt(var0), legend=r'$\alpha^{2} \rho_{0}$',lfontsize=lfontsize,  color='red', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (b**2)*rho1p, np.sqrt(var1), legend=r'$\beta^{2}\rho_{1}$',lfontsize=lfontsize,  color='green', ylabel='Correlations', xlim=xlim)
            pretty_rho(meanr, (2*a*b)*rho2p, np.sqrt(var3), legend=r'$2\alpha\beta \rho_{2}$',lfontsize=lfontsize,  color='yellow', ylabel='Correlations', xlim=xlim)
            print('Printing',  nameterms)
            plt.savefig(nameterms, dpi=200)
        if (len(samples)==1):
            pretty_rho(meanr, (a**2)*rho0p, np.sqrt(var0), legend=r'$\alpha^{2} \rho_{0}$',lfontsize=lfontsize,  color='red', ylabel='Correlations', xlim=xlim)
            print('Printing',  nameterms)
            plt.savefig(nameterms, dpi=200)
    
    #supposing that a,b and n are idependent of rhos(scale independent)
    dxip = (a**2)*rho0p + (b**2)*rho1p + (n**2)*rho3p + (2*a*b)*rho2p + (2*b*n)*rho4p + (2*n*a)*rho5p
    f1 = 2*(a*rho0p + b*rho2p + n*rho5p)     
    f2 = 2*(b*rho1p + a*rho2p + n*rho4p)
    f3 = 2*(n*rho3p + b*rho4p + a*rho5p)
    f4 = a**2 ; f5 = b**2; f6 = 2*a*b
    f7 = n**2 ; f8 = 2*b*n; f9 = 2*n*a 
    covmat_dxip = np.diag( (f1**2)*vara + (f2**2)*varb + (f3**2)*varn + + 2*(f1*f2*covab + f1*f3*covan + f2*f3*covbn) ) \
    + (f4**2)*(cov_rho0) + (f5**2)*(cov_rho1) + (f6**2)*(cov_rho2) + (f7**2)*(cov_rho3) +(f8**2)*(cov_rho4) + (f9**2)*(cov_rho5) 

    if(plots):
        plt.clf()
        pretty_rho(meanr, dxip, np.sqrt(np.diag(covmat_dxip)) , legend=r"$\delta \xi_{+}$",  ylabel=r"$\delta \xi_{+}$",  xlim=xlim)
        print('Printing',  dxipname)
        plt.savefig(dxipname, dpi=150)

    nrows = len(dxip)
    hdu = fits.PrimaryHDU()
    hdul = fits.HDUList([hdu])
    covmathdu = fits.ImageHDU(covmat_dxip, name='COVMAT')
    hdul.insert(1, covmathdu)
    angarray = meanr
    valuearray =  np.array(dxip)
    bin1array = np.array([ -999]*nrows)
    bin2array = np.array([ -999]*nrows)
    angbinarray = np.arange(nrows)
    array_list = [bin1array, bin2array, angbinarray, valuearray,  angarray ]
    for array, name in zip(array_list, names): outdata[name] = array 
    corrhdu = fits.BinTableHDU(outdata, name=nam)
    hdul.insert(2, corrhdu)
    if xim:
        hdul.writeto(filename + 'm.fits', clobber=True)
    else:
        hdul.writeto(filename + 'p.fits', clobber=True)
コード例 #2
0
ファイル: test4.py プロジェクト: des-science/alpha-beta-gamma
def main():
    import sys
    sys.path.insert(0, '/home/dfa/sobreira/alsina/alpha-beta-gamma/code/src')
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    plt.style.use('SVA1StyleSheet.mplstyle')
    from readjson import read_rhos, read_taus
    from plot_stats import pretty_rho
    import numpy as np

    outpath = os.path.expanduser(
        '/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/plots')
    try:
        if not os.path.exists(outpath):
            os.makedirs(outpath)
    except OSError:
        if not os.path.exists(outpath): raise

    #Comparing mod and unmod tau correlations
    modtaus = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_irz.json"
    unmodtaus = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_unmod_irz.json"
    meanr, tau0p, tau2p, tau5p, sig_tau0, sig_tau2, sig_tau5 = read_taus(
        modtaus)
    meanr_m, tau0p_m, tau2p_m, tau5p_m, sig_tau0_m, sig_tau2_m, sig_tau5_m = read_taus(
        unmodtaus)
    sqrtn = 1
    plt.clf()
    pretty_rho(meanr,
               tau0p,
               sig_tau0,
               sqrtn,
               legend=r'$\tau_{0}$',
               color='blue',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr_m,
               tau0p_m,
               sig_tau0_m,
               sqrtn,
               legend=r'$\tau_0*$',
               color='blue',
               marker='P',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               tau2p,
               sig_tau2,
               sqrtn,
               legend=r'$\tau_{2}$',
               color='green',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr_m,
               tau2p_m,
               sig_tau2_m,
               sqrtn,
               legend=r'$\tau_2*$',
               color='green',
               marker='P',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               tau5p,
               sig_tau5,
               sqrtn,
               legend=r'$\tau_{5}$',
               color='red',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr_m,
               tau5p_m,
               sig_tau5_m,
               sqrtn,
               legend=r'$\tau_5*$',
               color='red',
               marker='P',
               ylim=False,
               lfontsize=10,
               ylabel=r'$\tau(\theta)$')
    plt.xlim([0, 1000])
    print("Printing :", outpath + '/taustatsmeanvsnomean1.pdf')
    plt.savefig(outpath + '/taustatsmeanvsnomean1.pdf')

    #Comparing mod and unmod rhos correlations
    modrhoseobs = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/rho_all_reserved_mod_eobs_magcut_irz.json"
    modrhosepiff = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/rho_all_reserved_unmod_eobs_magcut_irz.json"
    meanr_obs, rho0p_obs, rho1p_obs, rho2p_obs, rho3p_obs, rho4p_obs, rho5p_obs, sig_rho0_obs, sig_rho1_obs, sig_rho2_obs, sig_rho3_obs, sig_rho4_obs, sig_rho5_obs = read_rhos(
        modrhoseobs)
    meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p, sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 = read_rhos(
        modrhosepiff)
    sqrtn = 1
    plt.clf()
    pretty_rho(meanr,
               rho1p_obs,
               sig_rho1_obs,
               sqrtn,
               legend=r'$\rho_{1}$',
               color='blue',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho1p,
               sig_rho1,
               sqrtn,
               legend=r'$\rho_1*$',
               color='blue',
               marker='P',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho3p_obs,
               sig_rho3_obs,
               sqrtn,
               legend=r'$\rho_{3}$',
               color='green',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho3p,
               sig_rho3,
               sqrtn,
               legend=r'$\rho_3*$',
               color='green',
               marker='P',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho4p_obs,
               sig_rho4_obs,
               sqrtn,
               legend=r'$\rho_{4}$',
               color='red',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho4p,
               sig_rho4,
               sqrtn,
               legend=r'$\rho_4*$',
               color='red',
               marker='P',
               ylim=False,
               lfontsize=10)
    plt.xlim([0, 400])
    print("Printing :", outpath + '/statsmeanvsnomean1.pdf')
    plt.savefig(outpath + '/statsmeanvsnomean1.pdf')
    plt.clf()
    pretty_rho(meanr,
               rho2p_obs,
               sig_rho2_obs,
               sqrtn,
               legend=r'$\rho_{2}$',
               color='blue',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho2p,
               sig_rho2,
               sqrtn,
               legend=r'$\rho_2*$',
               color='blue',
               marker='P',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho5p_obs,
               sig_rho5_obs,
               sqrtn,
               legend=r'$\rho_{5}$',
               color='green',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho5p,
               sig_rho5,
               sqrtn,
               legend=r'$\rho_5*$',
               color='green',
               marker='P',
               ylim=False,
               lfontsize=10)
    plt.xlim([0, 400])
    print("Printing :", outpath + '/statsmeanvsnomean2.pdf')
    plt.savefig(outpath + '/statsmeanvsnomean2.pdf')
    plt.clf()
    pretty_rho(meanr,
               rho0p_obs,
               sig_rho0_obs,
               sqrtn,
               legend=r'$\rho_{0}$',
               color='blue',
               ylim=False,
               lfontsize=10)
    pretty_rho(meanr,
               rho0p,
               sig_rho0,
               sqrtn,
               legend=r'$\rho_0*$',
               color='blue',
               marker='P',
               ylim=False,
               lfontsize=10)
    plt.xlim([0, 400])
    print("Printing :", outpath + '/statsmeanvsnomean0.pdf')
    plt.savefig(outpath + '/statsmeanvsnomean0.pdf')

    #Reading a ploting reserved stars correlations
    modrhoseobs = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/rho_all_reserved_mod_eobs_magcut_irz.json"
    modrhosepiff = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/rho_all_reserved_mod_epiff_magcut_irz.json"
    meanr_obs, rho0p_obs, rho1p_obs, rho2p_obs, rho3p_obs, rho4p_obs, rho5p_obs, sig_rho0_obs, sig_rho1_obs, sig_rho2_obs, sig_rho3_obs, sig_rho4_obs, sig_rho5_obs = read_rhos(
        modrhoseobs)
    meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p, sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 = read_rhos(
        modrhosepiff)
    sqrtn = 1
    plt.clf()
    pretty_rho(meanr,
               rho1p_obs,
               sig_rho1_obs,
               sqrtn,
               legend=r'$\rho_{1}(e_{obs})$',
               color='blue')
    pretty_rho(meanr,
               rho1p,
               sig_rho1,
               sqrtn,
               legend=r'$\rho_1(e_{piff})$',
               color='green',
               marker='P')
    print("Printing :", outpath + '/deltarho1_modeobs.pdf')
    plt.savefig(outpath + '/deltarho1_modeobs.pdf')

    plt.clf()
    pretty_rho(meanr,
               rho2p + rho1p,
               np.sqrt(sig_rho1**2 + sig_rho2**2),
               sqrtn,
               legend=r'$\rho_2(e_{piff})+\rho_1(e_{piff})$',
               color='blue')
    pretty_rho(meanr,
               rho2p_obs,
               sig_rho2_obs,
               sqrtn,
               legend=r'$\rho_2(e_{obs})$',
               color='green',
               marker='P')
    print("Printing :", outpath + '/r2+r1modepiff.pdf')
    plt.savefig(outpath + '/r2+r1modepiff.pdf')
コード例 #3
0
def main():
    import sys
    args = parse_args()
    sys.path.insert(0, args.srcpath)
    import numpy as np
    from readjson import read_xi,  read_dxip
    from plot_stats import pretty_rho

    #Make directory where the ouput data will be
    outpath = os.path.expanduser(args.outpath)
    try:
        if not os.path.exists(outpath):
            os.makedirs(outpath)
    except OSError:
        if not os.path.exists(outpath): raise

    
    meanr_xip, xip_obs,  sig_xip = read_xi(args.xipobs)
    meanr_dxip, dxip,  sig_dxip = read_dxip(args.dxip)
    plt.clf()
    pretty_rho(meanr_xip, xip_obs, sig_xip, legend=r"$\xi_{+}^{obs}$",lfontsize=10,  color='blue', ylabel='Correlations', ylim=False)
    pretty_rho(meanr_dxip, dxip, sig_dxip,  legend=r"$\delta \xi_{+}$",lfontsize=10,  color='red', ylabel='Correlations', ylim=False)
    fname = 'plots/xiobs_vs_xibias_abe2.png' 
    print('Printing:',  outpath +fname)
    plt.savefig(outpath +fname)

    meanr_dxip, dxip,  sig_dxip = read_dxip('/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/dxip-alpha-beta.json')
    plt.clf()
    pretty_rho(meanr_xip, xip_obs, sig_xip, legend=r"$\xi_{+}^{obs}$",lfontsize=10,  color='blue', ylabel='Correlations', ylim=False)
    pretty_rho(meanr_dxip, dxip, sig_dxip,  legend=r"$\delta \xi_{+}$",lfontsize=10,  color='red', ylabel='Correlations', ylim=False)
    fname = 'plots/xiobs_vs_xibias_ab2.png' 
    print('Printing:',  outpath +fname)
    plt.savefig(outpath +fname)

    meanr_dxip, dxip,  sig_dxip = read_dxip('/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/dxip-alpha.json')
    plt.clf()
    pretty_rho(meanr_xip, xip_obs, sig_xip, legend=r"$\xi_{+}^{obs}$",lfontsize=10,  color='blue', ylabel='Correlations', ylim=False)
    pretty_rho(meanr_dxip, dxip, sig_dxip,  legend=r"$\delta \xi_{+}$",lfontsize=10,  color='red', ylabel='Correlations', ylim=False)
    fname = 'plots/xiobs_vs_xibias_a2.png' 
    print('Printing:',  outpath +fname)
    plt.savefig(outpath +fname)
コード例 #4
0
def main():
    import sys
    sys.path.insert(0, '/home/dfa/sobreira/alsina/alpha-beta-gamma/code/src')
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    plt.style.use('SVA1StyleSheet.mplstyle')
    from readjson import read_rhos, read_taus
    from plot_stats import pretty_rho
    import numpy as np

    outpath = os.path.expanduser(
        '/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/plots')
    try:
        if not os.path.exists(outpath):
            os.makedirs(outpath)
    except OSError:
        if not os.path.exists(outpath): raise

    tausp1 = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_mod_patch1_irz.json"
    tausp2 = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_mod_patch2_irz.json"
    tausp3 = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_mod_patch3_irz.json"
    tausp4 = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_mod_patch4_irz.json"
    meanr1, tau0p1, tau2p1, tau5p1, sig_tau01, sig_tau21, sig_tau51 = read_taus(
        tausp1)
    meanr2, tau0p2, tau2p2, tau5p2, sig_tau02, sig_tau22, sig_tau52 = read_taus(
        tausp2)
    meanr3, tau0p3, tau2p3, tau5p3, sig_tau03, sig_tau23, sig_tau53 = read_taus(
        tausp3)
    meanr4, tau0p4, tau2p4, tau5p4, sig_tau04, sig_tau24, sig_tau54 = read_taus(
        tausp4)
    sqrtn = 1
    plt.clf()
    pretty_rho(meanr1,
               tau0p1,
               sig_tau01,
               sqrtn,
               legend='P++',
               lfontsize=10,
               color='blue',
               ylabel=r'$\tau_{0}$',
               ylim=False)
    pretty_rho(meanr2,
               tau0p2,
               sig_tau02,
               sqrtn,
               legend='P-+',
               lfontsize=10,
               color='red',
               ylabel=r'$\tau_{0}$',
               ylim=False)
    pretty_rho(meanr3,
               tau0p3,
               sig_tau03,
               sqrtn,
               legend='P--',
               lfontsize=10,
               color='green',
               ylabel=r'$\tau_{0}$',
               ylim=False)
    pretty_rho(meanr4,
               tau0p4,
               sig_tau04,
               sqrtn,
               legend='P+-',
               lfontsize=10,
               color='black',
               ylabel=r'$\tau_{0}$',
               ylim=False)
    print("Printing :", outpath + '/taus0_quadrants.png')
    plt.savefig(outpath + '/taus0_quadrants.png')

    plt.clf()
    pretty_rho(meanr1,
               tau2p1,
               sig_tau21,
               sqrtn,
               legend='P++',
               lfontsize=10,
               color='blue',
               ylabel=r'$\tau_{2}$',
               ylim=False)
    pretty_rho(meanr2,
               tau2p2,
               sig_tau22,
               sqrtn,
               legend='P-+',
               lfontsize=10,
               color='red',
               ylabel=r'$\tau_{2}$',
               ylim=False)
    pretty_rho(meanr3,
               tau2p3,
               sig_tau23,
               sqrtn,
               legend='P--',
               lfontsize=10,
               color='green',
               ylabel=r'$\tau_{2}$',
               ylim=False)
    pretty_rho(meanr4,
               tau2p4,
               sig_tau24,
               sqrtn,
               legend='P+-',
               lfontsize=10,
               color='black',
               ylabel=r'$\tau_{2}$',
               ylim=False)
    print("Printing :", outpath + '/taus2_quadrants.png')
    plt.savefig(outpath + '/taus2_quadrants.png')

    plt.clf()
    pretty_rho(meanr1,
               tau5p1,
               sig_tau51,
               sqrtn,
               legend='P++',
               lfontsize=10,
               color='blue',
               ylabel=r'$\tau_{5}$',
               ylim=False)
    pretty_rho(meanr2,
               tau5p2,
               sig_tau52,
               sqrtn,
               legend='P-+',
               lfontsize=10,
               color='red',
               ylabel=r'$\tau_{5}$',
               ylim=False)
    pretty_rho(meanr3,
               tau5p3,
               sig_tau53,
               sqrtn,
               legend='P--',
               lfontsize=10,
               color='green',
               ylabel=r'$\tau_{5}$',
               ylim=False)
    pretty_rho(meanr4,
               tau5p4,
               sig_tau54,
               sqrtn,
               legend='P+-',
               lfontsize=10,
               color='black',
               ylabel=r'$\tau_{5}$',
               ylim=False)
    print("Printing :", outpath + '/taus5_quadrants.png')
    plt.savefig(outpath + '/taus5_quadrants.png')
コード例 #5
0
def plot_correlations(outpath):

    from plot_stats import pretty_rho
    import numpy as np
    
    ylims =  [[ - 0.1, 0.1],[ - 30, 30],[ -600, 600] ] 
    outputnames = ['rho0.png', 'rho1.png', 'rho2.png', 'rho3.png', 'rho4.png', 'rho5.png']
    colors = ['black', 'green', 'blue', 'red', 'gray', 'pink']
    min_sep_list = [0.05, 0.1, 0.2, 0.3, 0.4]
    #min_sep_list = [0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
    for min_sep in enumeratemin_sep_list:
        meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p, sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 =read_rhos(os.path.join(outpath, "rho_%f.json"%(min_sep)))

        plt.clf()
        plt.figure(0)
        pretty_rho(meanr, rho0p, sig_rho0, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{0}(\theta)$',title=r'$\rho_{0}(\theta)$',
                   xlim=None, ylim=None)

        plt.clf()
        plt.figure(1)
        pretty_rho(meanr, rho1p, sig_rho1, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{1}(\theta)$',title=r'$\rho_{1}(\theta)$',
                   xlim=None, ylim=None)

        plt.clf()
        plt.figure(2)
        pretty_rho(meanr, rho2p, sig_rho2, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{2}(\theta)$',title=r'$\rho_{2}(\theta)$',
                   xlim=None, ylim=None)

        plt.clf()
        plt.figure(3)
        pretty_rho(meanr, rho3p, sig_rho3, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{3}(\theta)$',title=r'$\rho_{3}(\theta)$',
                   xlim=None, ylim=None)

        plt.clf()
        plt.figure(4)
        pretty_rho(meanr, rho4p, sig_rho4, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{4}(\theta)$',title=r'$\rho_{4}(\theta)$',
                   xlim=None, ylim=None)

        plt.clf()
        plt.figure(5)
        pretty_rho(meanr, rho5p, sig_rho5, legend=str(min_sep), lfontsize=24,
                   color='black', marker='o',
                   ylabel=r'$\rho_{5}(\theta)$',title=r'$\rho_{5}(\theta)$',
                   xlim=None, ylim=None)
        

    for i in range(6):
        plt.figure(i)
        plt.tight_layout()
        print("Printing :", outpath + outputnames[t])
        plt.savefig(outpath +outputnames[i],  dpi=200)
コード例 #6
0
def main():
    import sys
    args = parse_args()
    sys.path.insert(0, args.srcpath)
    import numpy as np
    from readjson import read_taus
    from plot_stats import pretty_rho, plot_tomograpically_bin

    #Make directory where the ouput data will be
    outpath = os.path.expanduser(args.outpath)
    try:
        if not os.path.exists(outpath):
            os.makedirs(outpath)
    except OSError:
        if not os.path.exists(outpath): raise

    section_name = 'galaxy_cl_nbb'
    xlabel = r'$\theta$ [arcmin]'
    ylabel = r'$\tau$'
    nbins = 4
    fig, ax = plt.subplots(nbins,
                           nbins,
                           figsize=(1.6 * nbins, 1.6 * nbins),
                           sharey=True,
                           sharex=True)
    bins = [[1, 1], [2, 2], [3, 3], [4, 4]]
    lines = []
    cols = ['red', 'blue', 'green', 'gray']
    for i, j in bins:
        fileaux = findbinfile(args.tausbins, i, j)
        meanr, tau0p, tau2p, tau5p, sig_tau0p, sig_tau2p, sig_tau5p = read_taus(
            args.tausbins + fileaux)
        plot_tomograpically_bin(ax,
                                i,
                                j,
                                meanr,
                                tau0p,
                                yerr=sig_tau0p,
                                xlabel=xlabel,
                                ylabel=ylabel,
                                nbins=4,
                                color='blue')  #, label=r'$\tau_{0}$')
        plot_tomograpically_bin(ax,
                                i,
                                j,
                                meanr,
                                tau2p,
                                yerr=sig_tau2p,
                                xlabel=xlabel,
                                ylabel=ylabel,
                                nbins=4,
                                color='red')  #, label=r'$\tau_{2}$')
        plot_tomograpically_bin(ax,
                                i,
                                j,
                                meanr,
                                tau5p,
                                yerr=sig_tau5p,
                                xlabel=xlabel,
                                ylabel=ylabel,
                                nbins=4,
                                color='green')  #, label=r'$\tau_{05}$')
        lines.append(ax[1][1].lines)

    fig.legend(lines,
               labels=[r'$\tau_{0}$', r'$\tau_{2}$', r'$\tau_{5}$'],
               bbox_to_anchor=(1.1, 1.08))
    plt.tight_layout()
    fname = 'all_taus_tomo.png'
    print('Printing:', outpath + fname)
    plt.savefig(outpath + fname, dpi=300)
    plt.close(fig)

    #tau0
    plt.clf()
    for i, j in bins:
        fileaux = findbinfile(args.tausbins, i, j)
        meanr, tau0p, tau2p, tau5p, sig_tau0p, sig_tau2p, sig_tau5p = read_taus(
            args.tausbins + fileaux)
        pretty_rho(meanr,
                   tau0p,
                   sig_tau0p,
                   legend="{},{}".format(i, j),
                   lfontsize=15,
                   color=cols[i - 1],
                   ylabel=r'$\tau_{0}(\theta)$',
                   ylim=False)
    fname = 'taus0_tomo.png'
    print('Printing:', outpath + fname)
    plt.savefig(outpath + fname, dpi=300)
    #tau2
    plt.clf()
    for i, j in bins:
        fileaux = findbinfile(args.tausbins, i, j)
        meanr, tau0p, tau2p, tau5p, sig_tau0p, sig_tau2p, sig_tau5p = read_taus(
            args.tausbins + fileaux)
        pretty_rho(meanr,
                   tau2p,
                   sig_tau2p,
                   legend="{},{}".format(i, j),
                   lfontsize=15,
                   color=cols[i - 1],
                   ylabel=r'$\tau_{2}(\theta)$',
                   ylim=False)
    fname = 'taus2_tomo.png'
    print('Printing:', outpath + fname)
    plt.savefig(outpath + fname, dpi=300)
    #tau5
    plt.clf()
    for i, j in bins:
        fileaux = findbinfile(args.tausbins, i, j)
        meanr, tau0p, tau2p, tau5p, sig_tau0p, sig_tau2p, sig_tau5p = read_taus(
            args.tausbins + fileaux)
        pretty_rho(meanr,
                   tau5p,
                   sig_tau5p,
                   legend="{},{}".format(i, j),
                   lfontsize=15,
                   color=cols[i - 1],
                   ylabel=r'$\tau_{5}(\theta)$',
                   ylim=False)
    fname = 'taus5_tomo.png'
    print('Printing:', outpath + fname)
    plt.savefig(outpath + fname, dpi=300)