Skip to content

Commit

Permalink
uniform styles across plots (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
zatkins2 authored Feb 20, 2025
1 parent aeeab43 commit 53b7143
Showing 1 changed file with 46 additions and 23 deletions.
69 changes: 46 additions & 23 deletions project/ACT_DR6/python/paper_plots/results_noise_spectrum_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
from pspy import so_dict, pspy_utils, so_spectra, so_cov
from pspipe_utils import covariance, pspipe_list, log, best_fits, external_data
import numpy as np
import pylab as plt
import matplotlib.pyplot as plt
import sys, os
import scipy.stats as ss
from matplotlib import rcParams


rcParams["xtick.labelsize"] = 16
rcParams["ytick.labelsize"] = 16
rcParams["axes.labelsize"] = 20
rcParams["axes.titlesize"] = 20
labelsize = 14
fontsize = 20

d = so_dict.so_dict()
d.read_from_file(sys.argv[1])
Expand All @@ -40,7 +36,7 @@

yrange["EE"] = (1, 500)

plt.figure(figsize=(14, 8))
plt.figure(figsize=(12, 6), dpi=100)


my_colors = {}
Expand All @@ -58,8 +54,12 @@
ax = plt.subplot(1,2, count)

plt.semilogy()
plt.plot(l_th, ps_th[spec], color="gray", label=r"$D^{\rm th}_{\ell}$")

if count == 1:
plt.plot(l_th, ps_th[spec], color="gray", label=r"$D^{\rm th}_{\ell}$")
else:
plt.plot(l_th, ps_th[spec], color="gray")

# first construct inv_Nb_mean so it can be plotted 2nd rather than last
inv_Nb_list = []
for spec_name in spec_name_list:
na, nb = spec_name.split("x")
Expand All @@ -72,35 +72,58 @@

if na == nb:
inv_Nb_list += [ 1 / Nb[spec]]

# plot inv_Nb_mean
inv_Nb_mean = np.sum(inv_Nb_list, axis=0)
if spec in ["TT", "EE", "BB"]:
if na == nb:
linestyle="-"
else:
linestyle="--"


id = np.where(lb > 300)
plt.plot(lb[id], Nb[spec][id], linestyle=linestyle, label= f"{pa_a} {ftag_a} x {pa_b} {ftag_b}", color=my_colors[spec_name])
plt.xlabel(r"$\ell$", fontsize=22)

if count == 1:
plt.ylabel(r"$\frac{\ell (\ell + 1)}{2\pi}N_\ell \ [\mu K^{2}]$", fontsize=22)
plt.plot(lb[id], 1 / inv_Nb_mean[id], linestyle=linestyle, label= f"DR6 effective noise", color="black")
else:
plt.plot(lb[id], 1 / inv_Nb_mean[id], linestyle=linestyle, color="black")

inv_Nb_mean = np.sum(inv_Nb_list, axis=0)
if spec in ["TT", "EE", "BB"]:
plt.plot(lb[id], 1 / inv_Nb_mean[id], linestyle=linestyle, label= f"DR6 effective noise", color="black")
# finally plot individual spectra
for spec_name in spec_name_list:
na, nb = spec_name.split("x")
if ("pa4" in spec_name) & (spec != "TT") & remove_pa4_pol: continue
sv_a, pa_a, ftag_a = na.split("_")
sv_b, pa_b, ftag_b = nb.split("_")
if pa_a != pa_b: continue

lb, Nb = so_spectra.read_ps(f"spectra/Dl_{spec_name}_noise.dat", spectra=spectra)

if na == nb:
linestyle="-"
else:
linestyle="--"

id = np.where(lb > 300)
if count == 1:
plt.plot(lb[id], Nb[spec][id], linestyle=linestyle, label= f"{pa_a.upper()} ({ftag_a} x {ftag_b})", color=my_colors[spec_name])
else:
plt.plot(lb[id], Nb[spec][id], linestyle=linestyle, color=my_colors[spec_name])
plt.xlabel(r"$\ell$", fontsize=fontsize)

if count == 1:
plt.ylabel(r"$\frac{\ell (\ell + 1)}{2\pi}N_\ell \ [\mu \rm K^{2}]$", fontsize=fontsize)

plt.ylim(yrange[spec])
plt.tick_params(labelsize=labelsize)
plt.xlim(0, 4000)

if spec == "TT":
plt.title("Temperature noise")
plt.title("TT Noise", fontsize=fontsize)
else:
plt.title("E-modes noise")
plt.title("EE Noise", fontsize=fontsize)

if count>1:
ax.legend(fontsize=16, loc='center left', bbox_to_anchor=(1, 0.5))

count += 1

plt.gcf().legend(fontsize=labelsize, loc='upper center', bbox_to_anchor=(0.5, 0), ncol=3)

plt.tight_layout()
plt.savefig(f"{paper_plot_dir}/DR6_noise.pdf")
Expand Down

0 comments on commit 53b7143

Please sign in to comment.