Skip to content

Commit

Permalink
backup null test
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Thibaut committed Nov 6, 2024
1 parent 423648c commit f5ce821
Show file tree
Hide file tree
Showing 61 changed files with 14,627 additions and 1,281 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""
This script plots summary PTE distribution
"""

import numpy as np
import pylab as plt
import pickle
from pspy import pspy_utils
from matplotlib import rcParams


rcParams["font.family"] = "serif"
rcParams["font.size"] = "40"
rcParams["xtick.labelsize"] = 16
rcParams["ytick.labelsize"] = 16
rcParams["axes.labelsize"] = 16
rcParams["axes.titlesize"] = 16

def pte_histo(pte_list, n_bins, name, color):
n_samples = len(pte_list)
bins = np.linspace(0, 1, n_bins + 1)
min, max = np.min(pte_list), np.max(pte_list)

id_high = np.where(pte_list > 0.99)
id_low = np.where(pte_list < 0.01)
nPTE_high = len(id_high[0])
nPTE_low = len(id_low[0])

plt.figure(figsize=(8,6))
plt.title("Elevation test: 40 degree vs 45 degree vs 47 degree", fontsize=16)
plt.xlabel(r"Probability to exceed (PTE)", fontsize=16)

plt.hist(pte_list, bins=bins, label=f"n tests: {n_samples}, min: {min:.3f}, max: {max:.3f}", histtype='bar', facecolor=color, edgecolor='black', linewidth=3)
plt.axhline(n_samples/n_bins, color="k", ls="--", alpha=0.5)
plt.xlim(0,1)
plt.tight_layout()
plt.legend(fontsize=16)

plt.savefig(f"{summary_dir}/pte_elevation_{name}.png", dpi=300, bbox_inches='tight')
plt.clf()
plt.close()



test = "elevation"
summary_dir = f"summary_{test}"
pspy_utils.create_directory(f"{summary_dir}")


label = "spectra+mc_cov"
list = []
arrays = ["pa4_f220", "pa5_f090", "pa5_f150", "pa6_f090", "pa6_f150"]

all_spec_list = [["TT", "TE", "ET", "EE"], ["EE", "EB", "BE", "BB"], ["TT", "TE", "ET", "TB", "BT", "EE", "EB", "BE", "BB"]]
file_name_list = ["T_and_E", "E_and_B", "all"]
colors = ["lightblue", "green", "orange"]

for color, name, spec_list in zip(colors, file_name_list, all_spec_list):
list = []

for ar in arrays:
file = open(f"{ar}/plots/array_nulls/pte_dict.pkl", "rb")
pte = pickle.load(file)
for spec in spec_list:
if (ar == "pa4_f220") & (spec != "TT"):
continue
print(ar, spec)
list = np.append(list, pte[label, spec])

# pte_histo(pte[label, "all"], n_bins)

n_bins = 14
print(len(list))
print(np.min(list), np.max(list))
pte_histo(list, n_bins, name, color)

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# Define the multipole range


multipole_range = {}
for el in ["el1", "el2", "el3"]:
multipole_range[f"{el}_pa4_f150"] = {"T": [1250, 8500], "E": [1250, 8500], "B": [1250, 8500] }
multipole_range[f"{el}_pa4_f220"] = {"T": [1000, 8500], "E": [1000, 8500], "B": [1000, 8500] }
multipole_range[f"{el}_pa5_f090"] = {"T": [1000, 8500], "E": [1000, 8500], "B": [1000, 8500] }
multipole_range[f"{el}_pa5_f150"] = {"T": [800, 8500], "E": [800, 8500], "B": [800, 8500] }
multipole_range[f"{el}_pa6_f090"] = {"T": [1000, 8500], "E": [1000, 8500], "B": [1000, 8500] }
multipole_range[f"{el}_pa6_f150"] = {"T": [600, 8500], "E": [600, 8500], "B": [600, 8500] }


# Options
l_pows = {
"TT": 1,
"TE": 0,
"TB": 0,
"ET": 0,
"BT": 0,
"EE": -1,
"EB": -1,
"BE": -1,
"BB": -1
}
y_lims = {
"TT": (-100000, 75000),
"TE": (-30, 30),
"TB": (-30, 30),
"ET": (-30, 30),
"BT": (-30, 30),
"EE": (-0.01, 0.01),
"EB": (-0.01, 0.01),
"BE": (-0.01, 0.01),
"BB": (-0.01, 0.01)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
This script performs null tests
and plot residual power spectra and a summary PTE distribution
"""

import numpy as np
import pylab as plt
import pickle
from pspy import pspy_utils
from matplotlib import rcParams


rcParams["font.family"] = "serif"
rcParams["font.size"] = "40"
rcParams["xtick.labelsize"] = 16
rcParams["ytick.labelsize"] = 16
rcParams["axes.labelsize"] = 16
rcParams["axes.titlesize"] = 16


def pte_histo(pte_list, n_bins, name, color):
n_samples = len(pte_list)
bins = np.linspace(0, 1, n_bins + 1)
min, max = np.min(pte_list), np.max(pte_list)

id_high = np.where(pte_list > 0.99)
id_low = np.where(pte_list < 0.01)
nPTE_high = len(id_high[0])
nPTE_low = len(id_low[0])

plt.figure(figsize=(8,6))
plt.title("Detectors test: In vs Out", fontsize=16)
plt.xlabel(r"Probability to exceed (PTE)", fontsize=16)
plt.hist(pte_list, bins=bins, label=f"n tests: {n_samples}, min: {min:.3f}, max: {max:.3f}", histtype='bar', facecolor=color, edgecolor='black', linewidth=3)
plt.axhline(n_samples/n_bins, color="k", ls="--", alpha=0.5)
plt.xlim(0,1)
plt.tight_layout()
plt.legend(fontsize=16)
plt.savefig(f"{summary_dir}/pte_inout_{name}.png", dpi=300, bbox_inches='tight')
plt.clf()
plt.close()

test = "inout"
summary_dir = f"summary_{test}"
pspy_utils.create_directory(f"{summary_dir}")


label = "spectra_corrected+mc_cov+beam_cov+leakage_cov"
list = []
arrays = ["pa4_f220", "pa5_f090", "pa5_f150", "pa6_f090", "pa6_f150"]

all_spec_list = [["TT", "TE", "ET", "EE"], ["EE", "EB", "BE", "BB"], ["TT", "TE", "ET", "TB", "BT", "EE", "EB", "BE", "BB"]]
file_name_list = ["T_and_E", "E_and_B", "all"]
colors = ["lightblue", "green", "orange"]



for color, name, spec_list in zip(colors, file_name_list, all_spec_list):
list = []

for ar in arrays:
file = open(f"{ar}/plots/array_nulls/pte_dict.pkl", "rb")
pte = pickle.load(file)
for spec in spec_list:
if (ar == "pa4_f220") & (spec != "TT"):
continue
print(ar, spec)
list = np.append(list, pte[label, spec])
# pte_histo(pte[label, "all"], n_bins)

n_bins = 13
print(len(list))
print(np.min(list), np.max(list))
pte_histo(list, n_bins, name, color)
Loading

0 comments on commit f5ce821

Please sign in to comment.