-
Notifications
You must be signed in to change notification settings - Fork 0
/
width.py
executable file
·40 lines (35 loc) · 1.08 KB
/
width.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Calculate the width mean and std for every z-bin.
Results
-------
2mpz : w = 1.0012677579134883 +/- 0.00095770892183479800
wisc1 : w = 1.0004753794174424 +/- 0.00035192981400517946
wisc2 : w = 1.0003905203637462 +/- 0.00029281910671999460
wisc3 : w = 1.0015899531635275 +/- 0.00145711261063026880
wisc4 : w = 1.0006421122602290 +/- 0.00048906841732273440
wisc5 : w = 1.0001195698677399 +/- 0.00106238073747336920
"""
import numpy as np
from funcs import Likelihood
# names of z-bins
zbins = ["2mpz"] + ["wisc%d" % b for b in range(1, 6)]
for zbin in zbins:
# if zbin != "wisc5": continue
# load N(z)
f = np.load("out/DIR_%s.npz" % zbin)
z_mid, Nz = f["z_arr"], f["nz_arr"]
# load JKs
diff_sq = 0
Njk = 0
while True:
try:
f = np.load("out/DIR_%s_jk%s.npz" % (zbin, Njk))
diff_sq += (f["nz_arr"]-Nz)**2
Njk += 1
except FileNotFoundError:
break
# run likelihood
dNz = np.sqrt(Njk/(Njk-1) * diff_sq)
l = Likelihood(z_mid, Nz, dNz)
w, dw = l.prob()
print(f"{zbin} : w = {w} +/- {dw}")