def getxipbias(samples, rhosfilename, plotname=None, plots=False): from readjson import read_rhos from maxlikelihood import bestparameters from plot_stats import pretty_rho import numpy as np 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 not defined") meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p,\ sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4,\ sig_rho5 = read_rhos(rhosfilename) #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 var_dxip = (f1**2)*vara + (f2**2)*varb + (f3**2)*varn + \ (f4**2)*(sig_rho0**2) + (f5**2)*(sig_rho1**2) + \ (f6**2)*(sig_rho2**2) + (f7**2)*(sig_rho3**2) + \ (f8**2)*(sig_rho4**2) + (f9**2)*(sig_rho5**2) + 2*(f1*f2*covab + f1*f3*covan + f2*f3*covbn) return meanr, dxip, var_dxip
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 plotallrhos(filename, outpath, title=None, xlim=None, ylims=None): from readjson import read_rhos ylim0, ylim1, ylim2 = [None, None, None] if ylims is not None: ylim0, ylim1, ylim2 = ylims meanr, rho0p, rho1p, rho2p, rho3p, rho4p, rho5p, sig_rho0, sig_rho1, sig_rho2, sig_rho3, sig_rho4, sig_rho5 = read_rhos( filename) plt.clf() pretty_rho1(meanr, rho1p, sig_rho1, rho3p, sig_rho3, rho4p, sig_rho4, title=title, xlim=xlim, ylim=ylim1) print("Printing file: ", outpath + 'rho1_all_rsrs.png') plt.savefig(outpath + 'rho1_all_rsrs.png') plt.clf() pretty_rho2(meanr, rho0p, sig_rho0, rho2p, sig_rho2, rho5p, sig_rho5, title=title, xlim=xlim, ylim=ylim2) print("Printing file: ", outpath + 'rho2_all_rsrs.png') plt.savefig(outpath + 'rho2_all_rsrs.png')
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 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')