forked from gkulkarni/QLF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata2.py
198 lines (149 loc) · 5.32 KB
/
data2.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
mpl.rcParams['text.usetex'] = True
mpl.rcParams['font.family'] = 'serif'
mpl.rcParams['font.serif'] = 'cm'
mpl.rcParams['font.size'] = '22'
import matplotlib.pyplot as plt
from random import shuffle
"""
Histogram of all quasar data used in this study.
"""
def getqlums(lumfile):
"""Read quasar luminosities."""
with open(lumfile,'r') as f:
z, mag, p = np.loadtxt(lumfile, usecols=(1,2,3), unpack=True)
return z, mag, p
class sample:
def __init__(self, sample_data_files, color='None', label=None):
for f in sample_data_files:
z, m, p = getqlums(f)
try:
self.z = np.append(self.z, z)
except(AttributeError):
self.z = z
self.color = color
self.label = label
return
def plot_data(data):
fig = plt.figure(figsize=(14, 7), dpi=100)
ax = fig.add_subplot(1, 1, 1)
ax.tick_params('both', which='major', length=7, width=1)
ax.tick_params('both', which='minor', length=3, width=1)
ax.set_yscale('log')
bin_width = 0.1
for d in data:
nbins = int(np.ptp(d.z)/bin_width)+1
if d.z.size == 1:
zlim = (d.z-bin_width/2.0, d.z+bin_width/2.0)
plt.hist(d.z, bins=nbins, range=zlim, color=d.color,
histtype='stepfilled', ec='k', label=d.label, linewidth=0.2)
else:
plt.hist(d.z, bins=nbins, color=d.color,
histtype='stepfilled', ec='k', label=d.label, linewidth=0.2)
z = 7.085
zlim = (z-bin_width/2.0, z+bin_width/2.0)
nbins = 1
n, bins, patches = plt.hist(z, bins=nbins, range=zlim, color=u'#f77189',
histtype='stepfilled', ec='none', label='UKIDSS Mortlock et al.\ (2011)')
ax.set_xlabel(r'redshift')
ax.set_ylabel(r'Number of quasars')
plt.ylim(7e-1, 5.0e4)
plt.xlim(0., 8.)
plt.legend(loc='upper right', fontsize=10, handlelength=3,
frameon=False, framealpha=0.0, labelspacing=.1,
handletextpad=0.4, borderpad=0.2,markerscale=.5)
plt.savefig('qsos.pdf', bbox_inches='tight')
return
# seaborn.color_palette('husl', 16).as_hex()
cs = [u'#f77189', u'#f7754f', u'#dc8932', u'#c39532', u'#ae9d31', u'#97a431',
u'#77ab31', u'#31b33e', u'#33b07a', u'#35ae93', u'#36ada4', u'#37abb4',
u'#38a9c5', u'#3aa5df', u'#6e9bf4', u'#a48cf4', u'#cc7af4', u'#f45cf2',
u'#f565cc', u'#f66bad']
shuffle(cs)
data = []
f = ['Data_new/dr7z2p2_sample.dat']
l = r'SDSS DR7 with Richards et al.\ (2006) selection function'
s = sample(f, color=cs[0], label=l)
data.append(s)
f = ['Data_new/croom09sgp_sample.dat',
'Data_new/croom09ngp_sample.dat']
l = r'2SLAQ NGP+SGP Croom et al.\ (2009a, 2009b)'
s = sample(f, color=cs[1], label=l)
data.append(s)
f = ['Data_new/dr7z3p7_sample.dat']
l = r'SDSS DR7 with Richards et al.\ (2006) selection function'
s = sample(f, color=cs[0])
# Use only up to z = 4.7 to avoid overlap with McGreer and Yang
s.z = s.z[s.z<4.7]
data.append(s)
f = ['Data_new/bossdr9color.dat']
l = r'BOSS DR9 colour-selected Ross et al.\ (2013)'
s = sample(f, color=cs[2], label=l)
data.append(s)
f = ['Data_new/yang16_sample.dat']
l = r'SDSS+Wise Yang et al.\ (2016)'
s = sample(f, color=cs[3], label=l)
data.append(s)
f = ['Data_new/mcgreer13_dr7sample.dat']
l = r'SDSS DR7 McGreer et al.\ (2013)'
s = sample(f, color=cs[4], label=l)
data.append(s)
f = ['Data_new/mcgreer13_s82sample.dat']
l = r'SDSS Stripe 82 McGreer et al.\ (2013)'
s = sample(f, color=cs[5], label=l)
data.append(s)
f = ['Data_new/mcgreer13_dr7extend.dat']
l = r'SDSS DR7 extended McGreer et al.\ (2013)'
s = sample(f, color=cs[6], label=l)
data.append(s)
f = ['Data_new/mcgreer13_s82extend.dat']
l = r'SDSS Stripe 82 extended McGreer et al.\ (2013)'
s = sample(f, color=cs[7], label=l)
data.append(s)
f = ['Data/glikman11qso.dat']
l = r'NDWFS+DLS Glikman et al.\ (2011)'
s = sample(f, color=cs[8], label=l)
data.append(s)
f = ['Data_new/giallongo15_sample.dat']
l = r'CANDELS GOODS-S Giallongo et al.\ (2015)'
s = sample(f, color=cs[9], label=l)
data.append(s)
f = ['Data_new/jiang08_sample.dat']
l = r'SDSS Deep Jiang et al.\ (2008, 2009)'
s = sample(f, color=cs[10], label=l)
data.append(s)
f = ['Data_new/jiang09_sample.dat']
l = r'SDSS Deep Jiang et al.\ (2009)'
s = sample(f, color=cs[10])
data.append(s)
f = ['Data_new/jiang16main_sample.dat']
l = r'SDSS Main Jiang et al.\ (2016)'
s = sample(f, color=cs[11], label=l)
data.append(s)
f = ['Data_new/fan06_sample.dat']
l = r'SDSS Fan et al.\ (2006)'
s = sample(f, color=cs[12], label=l)
data.append(s)
f = ['Data_new/jiang16overlap_sample.dat']
l = r'SDSS Overlap Jiang et al.\ (2016)'
s = sample(f, color=cs[13], label=l)
data.append(s)
f = ['Data_new/jiang16s82_sample.dat']
l = r'SDSS Stripe 82 Jiang et al.\ (2016)'
s = sample(f, color=cs[14], label=l)
data.append(s)
f = ['Data_new/willott10_cfhqsdeepsample.dat']
l = r'CFHQS Deep Willott et al.\ (2010)'
s = sample(f, color=cs[15], label=l)
data.append(s)
f = ['Data_new/willott10_cfhqsvwsample.dat']
l = r'CFHQS Very Wide Willott et al.\ (2010)'
s = sample(f, color=cs[16], label=l)
data.append(s)
f = ['Data_new/kashikawa15_sample.dat']
l = r'Subaru High-$z$ Quasar Survey Kashikawa et al.\ (2010)'
s = sample(f, color=cs[17], label=l)
data.append(s)
plot_data(data)