-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_1d_histo.py
executable file
·329 lines (285 loc) · 10.4 KB
/
plot_1d_histo.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/usr/bin/env python
"""
Plot 1D histogram for a parameter.
"""
import numpy as np
import pylab as plt
import wztanh as model
from load_data_files import load_chain
from matplotlib import ticker
import sys, os
import corner
# Get arguments
if len(sys.argv) != 2:
print("Requires one argument: idx")
sys.exit(1)
idx = int(sys.argv[1])
SAMPLE_SEED = 88 #44
BURNIN = 200000 #1200000
NSAMP = 150000 #50000
PARAM = 'h'
legend = True
if idx == 0:
tmpl = "chains/final_wztanh_seed30_cmb_lss%s"
expts = ["", "_desi", "_desi_hetdex", "_hirax_pbw", "_hetdex_hirax_pbw", "_cvlowz",]
colours = [ '#E1E1E1', '#555555', '#863AB7', '#E6773D', '#F5BC00', 'g']
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
' + DESI',
' + HETDEX + DESI',
r' + HIRAX ($3\times$PB wedge)',
r' + HETDEX + HIRAX ($3\times$ PB wedge)',
' + CV-limited low-z' ]
if idx == 1:
tmpl = "chains/final_wztanh_cmb_lss%s"
expts = ["", "_hirax_hw", "_hirax_pbw", "_hirax_nw", "_cvlowz"]
colours = [ '#E1E1E1', '#555555', '#863AB7', '#E6773D', '#F5BC00', 'g' ]
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
r' + HIRAX (horizon wedge)',
r' + HIRAX ($3\times$PB wedge)',
r' + HIRAX (no wedge)',
' + CV-limited low-z' ]
if idx == 2:
tmpl = "chains/final_wztanh_cmb_lss%s.dat"
fnames = [ #"chains/final_wztanh_cmb_lss.dat",
#"chains/final_wztanh_cmb_lss_cvlowz.dat",
#"chains/final_wztanh_seed16_cmb_lss_cvlowz.dat",
#"chains/final_wztanh_seed17_cmb_lss_cvlowz.dat",
#"chains/final_wztanh_seed18_cmb_lss_cvlowz.dat",
#"chains/final_wztanh_seed19_cmb_lss_cvlowz.dat",
"chains/final_wztanh_seed20_cmb_lss_cvlowz.dat",
"chains/final_wztanh_seed21_cmb_lss_cvlowz.dat",
]
colours = [ '#E1E1E1', '#555555', '#863AB7', '#E6773D', '#F5BC00', 'g', 'm']
labels = [ #'CMB + LSS',
#' + CV-limited low-z (15)',
#' + CV-limited low-z (16)',
#' + CV-limited low-z (17)',
#' + CV-limited low-z (18)',
#' + CV-limited low-z (19)',
' + CV-limited low-z (20)',
' + CV-limited low-z (21)',
]
if idx == 3:
tmpl = "chains/final_wztanh_seed21_cmb_lss%s"
expts = ["", "_desi", "_desi_hetdex",
#"_hirax_pbw",
"_hetdex_hirax_pbw",
"_cvlowz",]
colours = [ '#E1E1E1', '#555555', '#863AB7', '#E6773D', '#F5BC00', 'g']
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
' + DESI',
' + HETDEX + DESI',
#r' + HIRAX ($3\times$PB wedge)',
r' + HETDEX + HIRAX ($3\times$ PB wedge)',
' + CV-limited low-z' ]
if idx == 4:
tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [ "",
#"_desi",
"_hirax_nw", "_hirax_pbw", "_hirax_hw",]
colours = [ '#E1E1E1', '#863AB7', '#E6773D', '#F5BC00',] # '#555555'
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
#' + DESI',
r' + HIRAX (no wedge)',
r' + HIRAX ($3\times$PB wedge)',
r' + HIRAX (horiz. wedge)',
]
if idx == 5:
figname = "pub_histo_tanh_hirax_%s.pdf" % MODE
legend = True
if MODE == 'lowz': legend = False
tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [ "",
"_hirax_hw", "_hirax_pbw", "_hirax_nw",]
colours = [ '#E1E1E1', '#D92E1C', '#E6773D', '#F5BC00']
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
r' + HIRAX (horiz. wedge)',
r' + HIRAX ($3\times$PB wedge)',
r' + HIRAX (no wedge)',
]
if idx == 6:
#figname = "pub_histo_tanh_hirax_%s.pdf" % MODE
if MODE == 'lowz': legend = False
tmpl = "chains/final_wztanh_seed21_cmb_lss%s"
expts = [ "",
'_cosvis_nw', '_cosvis_pbw', '_cosvis_hw',
'_hizrax_nw', '_hizrax_pbw', '_hizrax_hw',]
colours = [ '#E1E1E1', '#D92E1C', '#E6773D', '#F5BC00', 'm', 'c', 'y']
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
r' + CosVis (no wedge)',
r' + CosVis ($3\times$PB wedge)',
r' + CosVis (horiz. wedge)',
r' + HIRAX high-z (no wedge)',
r' + HIRAX high-z ($3\times$PB wedge)',
r' + HIRAX high-z (horiz. wedge)',
]
if idx == 7:
figname = "pub_histo_tanh_compare_desi_%s.pdf" % MODE
if MODE == 'lowz': legend = False
dash = [False for j in range(10)]
dash[1] = True
tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [ '',
'_desi_hetdex',
'_hirax_pbw',
#'_hizrax_pbw',
'_cosvis_pbw',
#'_cvlowz',
#'_cvlowz_hetdex',
#'_cvlowz_hizrax_pbw',
]
colours = [ '#E1E1E1', '#555753', '#E6773D', '#3465a4']
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
r' + DESI + HETDEX',
r' + HIRAX ($3\times$PB wedge)',
r' + Stage 2 ($3\times$PB wedge)',
#r' + CV lim. (low-z)',
#r' + CV lim. (low-z) + HETDEX',
#r' + CV lim. (low-z) + HIRAX (high-z)',
]
if idx == 8:
figname = "pub_histo_tanh_compare_galsurv_%s.pdf" % MODE
#if MODE == 'lowz': legend = False
dash = [False for j in range(10)]
dash[1] = True
LW = 2.1
tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [ '',
#'_desi',
'_cvlowz',
'_cvlowz_hetdex',
'_cvlowz_hizrax_pbw',
'_cvlowz_cosvis_pbw',
]
colours = [ '#E1E1E1', '#000000', '#555753', '#fcaf3e', '#ad7fa8', '#3465a4',]
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
#r' + DESI',
r' + CV-lim. (low-z)',
r' + CV-lim. (low-z) + HETDEX',
r' + CV-lim. (low-z) + HIRAX high-z ($3\times$PB)',
r' + CV-lim. (low-z) + Stage 2 ($3\times$PB)',
]
if idx == 9:
figname = "pub_histo_tanh_compare_lowzhighz_%s.pdf" % MODE
#if MODE == 'lowz': legend = False
YLIM = (0.4, 1.1)
dash = [False for j in range(10)]
dash[1] = True
tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [ '',
'_cvlowz',
'_cosvis_pbw',
'_cvlowz_cosvis_pbw',
]
colours = [ '#E1E1E1', '#000000', '#3465a4', '#ad7fa8',]
fnames = [tmpl % e for e in expts]
labels = [ 'CMB + LSS',
r' + CV-lim. (low-z)',
r' + Stage 2 ($3\times$PB wedge)',
r' + CV-lim. (low-z) + Stage 2 ($3\times$PB wedge)',
]
if idx == -1:
plt.title("Seed 100 Sel 22") # 21, 30
#figname = "pub_histo_tanh_hirax_%s.pdf" % MODE
if MODE == 'lowz': legend = False
tmpl = "chains/seed100_selseed22/final_wztanh_seed100_cmb_lss%s"
#tmpl = "chains/final_wztanh_seed100_cmb_lss%s"
expts = [
'_cosvis_hw',
'_cosvis_nw',
'_cosvis_pbw',
'_cvlowz_cosvis_pbw',
'_cvlowz',
'_cvlowz_hetdex',
'_cvlowz_hizrax_pbw',
'',
'_desi',
'_desi_hetdex',
'_desi_hirax_pbw',
'_desi_hizrax_hw',
'_desi_hizrax_nw',
'_desi_hizrax_pbw',
'_hetdex_hirax_pbw',
'_hirax_hw',
'_hirax_nw',
'_hirax_pbw',
'_hizrax_hw',
'_hizrax_nw',
'_hizrax_pbw',
]
colours = [ '#E1E1E1', '#D92E1C', '#E6773D', '#F5BC00', 'm', 'c', 'y',]
colours += colours + colours + colours
fnames = [tmpl % e for e in expts]
labels = expts
# Create figure
ax = plt.subplot(111)
# Load data and select random samples
for j, fn in enumerate(fnames[:3]):
# Load samples
print("%s: Loading samples" % fn)
dat = load_chain(fn)
# Choose random subset of samples
np.random.seed(SAMPLE_SEED)
sample_idxs = np.random.randint(low=BURNIN, high=dat['h'].size, size=NSAMP)
print("Selecting %d samples out of %d available (burnin %d discarded)" \
% (sample_idxs.size, dat['h'].size - BURNIN, BURNIN))
ax.hist(dat[PARAM][sample_idxs], bins=160, range=(0.62, 0.73),
density=True, histtype='step', color=colours[j],
label=labels[j])
"""
if MODE == 'lowz':
plt.xlim((0., 2.2))
plt.ylim((-1.5, -0.2))
plt.gca().xaxis.set_major_locator(ticker.MultipleLocator(0.5))
plt.gca().xaxis.set_minor_locator(ticker.MultipleLocator(0.1))
else:
plt.xlim((0., 1170.))
try:
plt.ylim(YLIM)
except:
plt.ylim((-1.5, -0.2))
plt.gca().yaxis.set_major_locator(ticker.MultipleLocator(0.5))
plt.gca().yaxis.set_minor_locator(ticker.MultipleLocator(0.1))
#plt.gca().xaxis.set_major_locator(ticker.MultipleLocator(2.0))
#plt.gca().xaxis.set_minor_locator(ticker.MultipleLocator(0.5))
"""
plt.xlabel("$%s$" % PARAM, fontsize=15)
#plt.ylabel(r"$w(z)$", fontsize=15, labelpad=10)
plt.gca().tick_params(axis='both', which='major', labelsize=18, size=8.,
width=1.5, pad=8.)
plt.gca().tick_params(axis='both', which='minor', labelsize=18, size=5.,
width=1.5, pad=8.)
plt.gca().tick_params(axis='y', which='major', labelsize=18, size=5.,
width=1.5, pad=8., label1On=False)
# Re-order legend
#handles, labels = plt.gca().get_legend_handles_labels()
#handles = [handles[-1], handles[0], handles[1], handles[2], handles[3]]
#labels = [labels[-1], labels[0], labels[1], labels[2], labels[3]]
#leg = plt.legend(handles, labels, loc='upper left', frameon=False)
plt.legend(loc='upper left', frameon=False)
"""
if legend:
# Re-order legend so CMB+LSS is always first
_handles, _labels = plt.gca().get_legend_handles_labels()
handles = [_handles[-1],]
labels = [_labels[-1],]
for i in range(0, len(_handles)-1):
handles += [_handles[i],]
labels += [_labels[i],]
leg = plt.legend(handles, labels, loc='upper left', frameon=False)
"""
plt.tight_layout()
try:
plt.savefig(figname)
print("Figure saved as", figname)
except:
pass
plt.show()