def plotalltaus(filename, outpath, xlim=None, ylims=None): from readjson import read_taus ylim0, ylim1, ylim2 = [None, None, None] if ylims is not None: ylim0, ylim1, ylim2 = ylims meanr2, tau0p, tau2p, tau5p, sig_tau0, sig_tau2, sig_tau5 = read_taus( filename) plt.clf() pretty_tau(meanr2, tau0p, sig_tau0, r'$\tau_{0}(\theta)$', xlim=xlim, ylim=ylim0) print("Printing file: ", outpath + 'tau0_all_rsgal.png') plt.savefig(outpath + 'tau0_all_rsgal.png') plt.clf() pretty_tau(meanr2, tau2p, sig_tau2, r'$\tau_{2}(\theta)$', xlim=xlim, ylim=ylim1) print("Printing file: ", outpath + 'tau2_all_rsgal.png') plt.savefig(outpath + 'tau2_all_rsgal.png') plt.clf() pretty_tau(meanr2, tau5p, sig_tau5, r'$\tau_{5}(\theta)$', xlim=xlim, ylim=ylim2) print("Printing file: ", outpath + 'tau5_all_rsgal.png') plt.savefig(outpath + 'tau5_all_rsgal.png')
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 tausepiff = "/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/used/tau_all_galaxy-reserved_max_sep100_irz.json" meanr, tau0p, tau2p, tau5p, sig_tau0, sig_tau2, sig_tau5 = read_taus(tausepiff) sqrtn = 1 marker = 'o' plt.clf() plt.plot(meanr, tau0p, color='blue', label=r"$\tau_{0}$") plt.plot(meanr, -tau0p, color='blue', ls=':') plt.errorbar(meanr[tau0p>0], tau0p[tau0p>0], yerr=sig_tau0[tau0p>0]/sqrtn, color='blue', ls='', marker=marker) plt.errorbar(meanr[tau0p<0], -tau0p[tau0p<0], yerr=sig_tau0[tau0p<0]/sqrtn, color='blue', ls='', marker=marker) tau0p0_line = plt.errorbar(-meanr, tau0p, yerr=sig_tau0, color='blue', marker='o') plt.plot(meanr, tau2p, color='green', label=r"$\tau_{2}$") plt.plot(meanr, -tau2p, color='green', ls=':') plt.errorbar(meanr[tau2p>0], tau2p[tau2p>0], yerr=sig_tau2[tau2p>0]/sqrtn, color='green', ls='', marker=marker) plt.errorbar(meanr[tau2p<0], -tau2p[tau2p<0], yerr=sig_tau2[tau2p<0]/sqrtn, color='green', ls='', marker=marker) tau0p0_line = plt.errorbar(-meanr, tau0p, yerr=sig_tau0, color='green', marker='o') plt.plot(meanr, tau5p, color='red', label=r"$\tau_{5}$") plt.plot(meanr, -tau5p, color='red', ls=':') plt.errorbar(meanr[tau5p>0], tau5p[tau5p>0], yerr=sig_tau5[tau5p>0]/sqrtn, color='red', ls='', marker=marker) plt.errorbar(meanr[tau5p<0], -tau5p[tau5p<0], yerr=sig_tau5[tau5p<0]/sqrtn, color='red', ls='', marker=marker) tau0p0_line = plt.errorbar(-meanr, tau0p, yerr=sig_tau0, color='red', marker='o') plt.legend(loc='best', fontsize=24) plt.ylim( [1.e-11, 1.e-5] ) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim( [0.5,150.] ) plt.xlabel(r'$\theta$ (degrees)', fontsize=24) plt.ylabel(r'$\tau$', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing :", outpath +'/taus_100degrees.pdf') plt.savefig(outpath +'/taus_100degrees.pdf')
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')
def run_parspatch(outpath, rhosfolder, tausfolder): from readjson import read_rhos, read_taus from chi2 import minimizeCHI2 from maxlikelihood import MCMC, percentiles import numpy as np nwalkers, nsteps = 100, 1000 eq = 'All' moderr = False gflag, bflag = True, True nsig = 1 i_guess0 = [-0.01, 1, -1] #fiducial values data = {} for i in range(1, 5): rhosp = rhosfolder + findpatchfile(rhosfolder, i) tausp = tausfolder + findpatchfile(tausfolder, i) a_c = [] a_l = [] a_r = [] b_c = [] b_l = [] b_r = [] d_c = [] d_l = [] d_r = [] for ibin in range(1, 21): meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p,\ sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4,\ sig_rho5 = read_rhos(rhosp, maxbin=ibin) meanr, tau0p, tau2p, tau5p, sig_tau0, sig_tau2,sig_tau5 =\ read_taus(tausp, maxbin=ibin) rhos = [rho0p, rho1p, rho2p, rho3p, rho4p, rho5p] sigrhos = [ sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 ] taus = [tau0p, tau2p, tau5p] sigtaus = [sig_tau0, sig_tau2, sig_tau5] data['rhos'] = rhos data['sigrhos'] = sigrhos data['taus'] = taus data['sigtaus'] = sigtaus fit_pars, chisq = minimizeCHI2(data, i_guess0, eq=eq, gflag=gflag, bflag=bflag, moderr=moderr) samples = MCMC(fit_pars, data, nwalkers, nsteps, eq=eq, gflag=gflag, bflag=bflag, moderr=moderr, plot=False) mcmcpars = percentiles(samples, nsig=nsig) a_c.append(mcmcpars[0][0]) a_l.append(mcmcpars[0][1]) a_r.append(mcmcpars[0][2]) b_c.append(mcmcpars[1][0]) b_l.append(mcmcpars[1][1]) b_r.append(mcmcpars[1][2]) d_c.append(mcmcpars[2][0]) d_l.append(mcmcpars[2][1]) d_r.append(mcmcpars[2][2]) write_pars(outpath + 'parspatch' + str(i) + '.json', meanr, a_c, a_l, a_r, b_c, b_l, b_r, d_c, d_l, d_r)
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')
def main(): import sys args = parse_args() sys.path.insert(0, args.srcpath) import numpy as np import itertools from readjson import read_rhos, read_taus import fitsio from fitsio import FITS, FITSHDR from astropy.io import fits #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 nwalkers, nsteps = 100, 1000 moderr = False nsig = 1 eq = 'All' i_guess0 = [-0.01, 1, -1] #fiducial values meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p,\ sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4,\ sig_rho5 =read_rhos(args.rhos, args.maxscale) rhos = [rho0p, rho1p, rho2p, rho3p, rho4p, rho5p] sigrhos = [sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5] data = {} data['rhos'] = rhos data['sigrhos'] = sigrhos names = ['BIN1', 'BIN2', 'ANGBIN', 'ANG', 'VALUE'] forms = ['i4', 'i4', 'i4', 'f8', 'f8'] dtype = dict(names=names, formats=forms) nrows = 20 outdata = np.recarray((nrows, ), dtype=dtype) nbins = 4 a = [i for i in range(1, nbins + 1)] bin_pairs = [] for p in itertools.combinations_with_replacement(a, 2): bin_pairs.append(p) covmat = np.zeros(shape=(nbins * nrows, nbins * nrows)) covmatbin = None listofmat = [] for i, j in bin_pairs: taufilename = findbinfile(args.tausfolder, i, j) if taufilename is None: continue print(i, j, taufilename) meanr2, tau0p, tau2p, tau5p, sig_tau0, sig_tau2, sig_tau5 \ = read_taus(args.tausfolder + taufilename, args.maxscale) taus = [tau0p, tau2p, tau5p] sigtaus = [sig_tau0, sig_tau2, sig_tau5] data['taus'] = taus data['sigtaus'] = sigtaus if not (args.abe or args.ab or args.a): args.abe = True ## ALPHA-BETA-ETA if (args.abe): print("### Runing alpha, beta and eta test ### ") gflag, bflag = True, True i_guess = i_guess0 meanr, dxip, vardxip = RUNtest(args, data, nwalkers, nsteps, i_guess, gflag, bflag, eq, moderr, nsig) covmat[nrows * (i - 1):nrows * i, nrows * (j - 1):nrows * j] = np.diag(vardxip) angarray = meanr valuearray = dxip bin1array = np.array([i] * len(meanr)) bin2array = np.array([j] * len(meanr)) angbinarray = np.array([i for i in range(len(meanr))]) array_list = [ bin1array, bin2array, angbinarray, angarray, valuearray ] for array, name in zip(array_list, names): outdata[name] = array write_fit(outdata, names, outpath + args.filename) ## ALPHA-BETA if (args.ab): print("### Runing alpha and beta test ### ") gflag, bflag = False, True i_guess = i_guess0[:2] #fiducial values meanr, dxip, vardxip = RUNtest(args, data, nwalkers, nsteps, i_guess, gflag, bflag, eq, moderr, nsig) covmat[nrows * (i - 1):nrows * i, nrows * (j - 1):nrows * j] = np.diag(vardxip) angarray = meanr valuearray = dxip bin1array = np.array([i] * len(meanr)) bin2array = np.array([j] * len(meanr)) angbinarray = np.array([i for i in range(len(meanr))]) array_list = [ bin1array, bin2array, angbinarray, angarray, valuearray ] for array, name in zip(array_list, names): outdata[name] = array write_fit(outdata, names, outpath + args.filename) ## ALPHA if (args.a): print("### Runing alpha test ### ") gflag, bflag = False, False i_guess = i_guess0[:1] #fiducial values meanr, dxip, vardxip = RUNtest(args, data, nwalkers, nsteps, i_guess, gflag, bflag, eq, moderr, nsig) covmat[nrows * (i - 1):nrows * i, nrows * (j - 1):nrows * j] = np.diag(vardxip) angarray = meanr valuearray = dxip bin1array = np.array([i] * len(meanr)) bin2array = np.array([j] * len(meanr)) angbinarray = np.array([i for i in range(len(meanr))]) array_list = [ bin1array, bin2array, angbinarray, angarray, valuearray ] for array, name in zip(array_list, names): outdata[name] = array write_fit(outdata, names, outpath + args.filename) hdulist = fits.open(outpath + args.filename) hdulist[1].name = 'xip' covmathdu = fits.ImageHDU(covmat, name='COVMAT') hdulist.insert(1, covmathdu) hdulist.writeto(outpath + args.filename, clobber=True) print(covmat)
def main(): import os 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 chi2 import minimizeCHI2 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 meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p, sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 = read_rhos( '/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/rho_all_reserved_mod_epiff_magcut_irz.json' ) meanr2, tau0p, tau2p, tau5p, sig_tau0, sig_tau2, sig_tau5 = read_taus( '/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_irz.json' ) meanr3, tau0p_sn, tau2p_sn, tau5p_sn, sig_tau0_sn, sig_tau2_sn, sig_tau5_sn = read_taus( '/home2/dfa/sobreira/alsina/catalogs/output/alpha-beta-gamma/tau_all_galaxy-reserved_shapenoise_irz.json' ) plt.clf() plt.plot(meanr, sig_tau0**2, color='blue', label=r'$var(\tau_{0})$', marker='o') plt.plot(meanr, sig_tau2**2, color='red', label=r'$var(\tau_{2})$', marker='o') plt.plot(meanr, sig_tau5**2, color='green', label=r'$var(\tau_{5})$', marker='o') plt.plot(meanr, sig_tau0_sn**2, color='blue', label=r'$var(\tau_{0sn})$', marker='P') plt.plot(meanr, sig_tau2_sn**2, color='red', label=r'$var(\tau_{2sn})$', marker='P') plt.plot(meanr, sig_tau5_sn**2, color='green', label=r'$var(\tau_{5sn})$', marker='P') plt.legend(loc='upper right', shadow=True, fontsize=7) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) plt.ylim([10**-25, 10**-9]) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel('Variances', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing :" + outpath + '/treecorr_vs_notes_variances.pdf') plt.savefig(outpath + '/treecorr_vs_notes_variances.pdf') plt.clf() plt.plot(meanr, (sig_tau0_sn**2) / (sig_tau0**2), color='blue', label=r'$var(\tau_{0})/var(\tau_{0sn})$', marker='o') plt.plot(meanr, (sig_tau2_sn**2) / (sig_tau2**2), color='green', label=r'$var(\tau_{2})/var(\tau_{2sn})$', marker='o') plt.plot(meanr, (sig_tau5_sn**2) / (sig_tau5**2), color='red', label=r'$var(\tau_{5})/var(\tau_{5sn})$', marker='o') plt.legend(loc='best', shadow=True, fontsize=7) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) plt.ylim([0, 3]) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel('Variances', fontsize=24) plt.xscale('log') #plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing :" + outpath + '/ratio_treecorr_vs_notes_variances.pdf') plt.savefig(outpath + '/ratio_treecorr_vs_notes_variances.pdf') plt.clf() plt.plot(meanr, sig_tau0_sn**2, color='blue', label=r'$var(\tau_{0sn})$', marker='o') plt.plot(meanr, sig_tau2_sn**2, color='red', label=r'$var(\tau_{2sn})$', marker='o') plt.plot(meanr, sig_tau5_sn**2, color='green', label=r'$var(\tau_{5sn})$', marker='o') plt.plot(meanr, sig_rho0**2, color='black', label=r'$var(\rho_{0})$', marker='o') plt.plot(meanr, sig_rho1**2, color='yellow', label=r'$var(\rho_{1})$', marker='o') plt.plot(meanr, sig_rho2**2, color='gray', label=r'$var(\rho_{2})$', marker='o') plt.plot(meanr, sig_rho3**2, color='magenta', label=r'$var(\rho_{3})$', marker='o') plt.plot(meanr, sig_rho4**2, color='pink', label=r'$var(\rho_{4})$', marker='o') plt.plot(meanr, sig_rho5**2, color='orange', label=r'$var(\rho_{5})$', marker='o') plt.legend(loc='upper right', shadow=True, fontsize=7) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) plt.ylim([10**-25, 10**-9]) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel('Variances', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing :" + outpath + '/all_variances_bybin.pdf') plt.savefig(outpath + '/all_variances_bybin.pdf') #Finding best alpha beta gamma rhos = [rho0p, rho1p, rho2p, rho3p, rho4p, rho5p] sigrhos = [sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5] taus = [tau0p, tau2p, tau5p] sigtaus = [sig_tau0, sig_tau2, sig_tau5] data = {} data['rhos'] = rhos data['sigrhos'] = sigrhos data['taus'] = taus data['sigtaus'] = sigtaus gflag, bflag = False, False i_guess = [0] #fiducial values alpha0, chisq0 = minimizeCHI2(data, i_guess, eq=0, gflag=gflag, bflag=bflag) alpha1, chisq1 = minimizeCHI2(data, i_guess, eq=1, gflag=gflag, bflag=bflag) alpha2, chisq2 = minimizeCHI2(data, i_guess, eq=2, gflag=gflag, bflag=bflag) print(alpha0, alpha1, alpha2) res0 = (tau0p - alpha0 * rho0p)**2 res1 = (tau2p - alpha1 * rho2p)**2 res2 = (tau5p - alpha2 * rho5p)**2 plt.clf() plt.plot(meanr, sig_tau0**2, color='blue', label=r'$var(\tau_{0})$', marker='o') plt.plot(meanr, sig_tau2**2, color='red', label=r'$var(\tau_{2})$', marker='o') plt.plot(meanr, sig_tau5**2, color='green', label=r'$var(\tau_{5})$', marker='o') plt.legend(loc='lower left', shadow=True, fontsize=15) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) #plt.ylim( [10**-22,10 **-10] ) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel('Variances', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing variances_bybin.pdf") plt.savefig(outpath + '/variances_bybin.pdf') plt.clf() plt.plot(meanr, res0, color='blue', label=r'$(\tau_{0}-\alpha_{0}\rho_{0})^2$', marker='o') plt.plot(meanr, res1, color='red', label=r'$(\tau_{2}-\alpha_{1}\rho_{2})^2$', marker='o') plt.plot(meanr, res2, color='green', label=r'$(\tau_{5}-\alpha_{2}\rho_{5})^2$', marker='o') plt.legend(loc='lower left', shadow=True, fontsize=15) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) plt.ylim([10**-22, 10**-10]) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel('Residuals', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing Residual_chi2_bybin.pdf") plt.savefig(outpath + '/Residuals_chi2_bybin.pdf') plt.clf() plt.plot(meanr, res0 / sig_tau0**2, color='blue', label=r'$\chi_{0}^2$', marker='o') plt.plot(meanr, res1 / sig_tau2**2, color='red', label=r'$\chi_{1}^2$', marker='o') plt.plot(meanr, res2 / sig_tau5**2, color='green', label=r'$\chi_{2}^2$', marker='o') plt.legend(loc='upper left', shadow=True, fontsize=15) plt.tick_params(axis='both', which='major', labelsize=24) plt.xlim([0.5, 300.]) plt.ylim([0.01, 50000.]) plt.xlabel(r'$\theta$ (arcmin)', fontsize=24) plt.ylabel(r'$\chi^{2}$', fontsize=24) plt.xscale('log') plt.yscale('log', nonposy='clip') plt.tight_layout() print("Printing chi2_bybin.pdf") plt.savefig(outpath + '/chi2_bybin.pdf')
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)