forked from gkulkarni/QLF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbins_withg.py
97 lines (79 loc) · 4.08 KB
/
bins_withg.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import sys
import numpy as np
import individual
reload(individual)
from individual import lf
import mosaic
qlumfiles = ['Data_new/dr7z2p2_sample.dat',
'Data_new/croom09sgp_sample.dat',
'Data_new/croom09ngp_sample.dat',
'Data_new/bossdr9color.dat',
'Data_new/dr7z3p7_sample.dat',
'Data_new/glikman11debug.dat',
'Data_new/yang16_sample.dat',
'Data_new/mcgreer13_dr7sample.dat',
'Data_new/mcgreer13_s82sample.dat',
'Data_new/mcgreer13_dr7extend.dat',
'Data_new/mcgreer13_s82extend.dat',
'Data_new/jiang16main_sample.dat',
'Data_new/jiang16overlap_sample.dat',
'Data_new/jiang16s82_sample.dat',
'Data_new/willott10_cfhqsdeepsample.dat',
'Data_new/willott10_cfhqsvwsample.dat',
'Data_new/kashikawa15_sample.dat',
'Data_new/giallongo15_sample.dat']
selnfiles = [('Data_new/dr7z2p2_selfunc.dat', 0.1, 0.05, 6248.0, 13, r'Schneider et al.\ 2010'),
('Data_new/croom09sgp_selfunc.dat', 0.3, 0.05, 64.2, 15, r'Croom et al.\ 2009'),
('Data_new/croom09ngp_selfunc.dat', 0.3, 0.05, 127.7, 15, r'Croom et al.\ 2009'),
('Data_new/ross13_selfunc2.dat', 0.1, 0.05, 2236.0, 1, r'Ross et al.\ 2013'),
('Data_new/dr7z3p7_selfunc.dat', 0.1, 0.05, 6248.0, 13, r'Schneider et al.\ 2010'),
('Data_new/glikman11_selfunc_ndwfs.dat', 0.05, 0.02, 1.71, 6, r'Glikman et al.\ 2011'),
('Data_new/glikman11_selfunc_dls.dat', 0.05, 0.02, 2.05, 6, r'Glikman et al.\ 2011'),
('Data_new/yang16_sel.dat', 0.1, 0.05, 14555.0, 17, r'Yang et al.\ 2016'),
('Data_new/mcgreer13_dr7selfunc.dat', 0.1, 0.05, 6248.0, 8, r'McGreer et al.\ 2013'),
('Data_new/mcgreer13_s82selfunc.dat', 0.1, 0.05, 235.0, 8, r'McGreer et al.\ 2013'),
('Data_new/jiang16main_selfunc.dat', 0.1, 0.05, 11240.0, 18, r'Jiang et al.\ 2016'),
('Data_new/jiang16overlap_selfunc.dat', 0.1, 0.05, 4223.0, 18, r'Jiang et al.\ 2016'),
('Data_new/jiang16s82_selfunc.dat', 0.1, 0.05, 277.0, 18, r'Jiang et al.\ 2016'),
('Data_new/willott10_cfhqsdeepsel.dat', 0.1, 0.025, 4.47, 10, r'Willott et al.\ 2010'),
('Data_new/willott10_cfhqsvwsel.dat', 0.1, 0.025, 494.0, 10, r'Willott et al.\ 2010'),
('Data_new/kashikawa15_sel.dat', 0.05, 0.05, 6.5, 11, r'Kashikawa et al.\ 2015'),
('Data_new/giallongo15_sel.dat', 0.0, 0.0, 0.047, 7, 'Giallongo et al.\ 2015')]
method = 'Nelder-Mead'
zls = [(4.1, 4.7), (4.7, 5.5), (5.5, 6.5)]
lfs = []
for i, zl in enumerate(zls):
lfi = lf(quasar_files=qlumfiles, selection_maps=selnfiles, zlims=zl)
print 'z =', zl
print '{:d} quasars in this bin.'.format(lfi.z.size)
print 'sids (samples): '+' '.join(['{:2d}'.format(int(x)) for x in np.unique(lfi.sid)])
print 'sids (maps): '+' '.join(['{:2d}'.format(x.sid) for x in lfi.maps])
print ' '
g = (np.log10(1.e-6), -25.0, -3.0, -1.5)
b = lfi.bestfit(g, method=method)
zmin, zmax = zl
if zmin < 0.3:
lfi.prior_min_values = np.array([-14.0, -32.0, -7.0, -10.0])
else:
lfi.prior_min_values = np.array([-14.0, -32.0, -7.0, -4.0])
if zmin > 5.4:
# Special priors for z = 6 data.
lfi.prior_max_values = np.array([-4.0, -20.0, -4.0, 0.0])
# Change result of optimize.minimize so that emcee works.
lfi.bf.x[2] = -5.0
elif zmin < 0.3:
lfi.prior_max_values = np.array([-1.0, -15.0, 0.0, 15.0])
else:
lfi.prior_max_values = np.array([-4.0, -20.0, 0.0, 0.0])
assert(np.all(lfi.prior_min_values < lfi.prior_max_values))
lfi.run_mcmc()
lfi.get_percentiles()
WRITE_PARAMS = True
if WRITE_PARAMS:
with open('bins.dat', 'a') as f:
output = ([lfi.z.mean()] + list(zl) + lfi.phi_star
+ lfi.M_star + lfi.alpha + lfi.beta)
f.write(('{:.3f} '*len(output)).format(*output))
f.write('\n')
lfs.append(lfi)
# mosaic.draw(lfs)