-
Notifications
You must be signed in to change notification settings - Fork 0
/
qso_correlation_plotting.py
294 lines (266 loc) · 10.4 KB
/
qso_correlation_plotting.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
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 15 15:55:24 2014
@author: suberlak
Plotting histograms of correlated values from
qso_javelin_chelsea_stats_correlation.py for CRTS
"""
import numpy as np
import matplotlib.pyplot as plt
results = 'qso_jav_chelsea_correlation_tabulated_ALL.txt'
output = np.loadtxt(results, dtype='str')
ra_jav = output[:,0].astype(np.float)
ra_ch = output[:,1].astype(np.float)
dec_jav= output[:,2].astype(np.float)
dec_ch= output[:,3].astype(np.float)
tau_jav= output[:,4].astype(np.float)
tau_ch= output[:,5].astype(np.float)
log_tau_ratio= output[:,6].astype(np.float)
sigma_jav= output[:,7].astype(np.float)
sigma_ch= output[:,8].astype(np.float)
sig_rat= output[:,9].astype(np.float)
log_sigma_ratio= output[:,10].astype(np.float)
timespan_obs= output[:,11].astype(np.float)
nobs_object= output[:,12].astype(np.float)
lc_length= output[:,13].astype(np.float)
avg_N_day= output[:,14].astype(np.float)
avg_mag_ttl= output[:,15].astype(np.float)
avg_err_ttl= output[:,16].astype(np.float)
avg_mjd_diff= output[:,17].astype(np.float)
mean_time_bet_obs= output[:,18].astype(np.float)
divide = np.max(np.where(log_tau_ratio < -2.5))
# MORE AUTOMATIC WAY
names=['timespan_obs','nobs_object','lc_length', 'avg_N_day', 'avg_mag_ttl',\
'avg_err_ttl', 'avg_mjd_diff','mean_time_bet_obs']
stats=[timespan_obs,nobs_object,lc_length, avg_N_day, avg_mag_ttl,\
avg_err_ttl, avg_mjd_diff,mean_time_bet_obs]
#
#print '\n Plotting coloured hist for log_tau_ratio vs log_sigma_ratio'
#plt.clf()
#fig1 = plt.figure()
#x=log_tau_ratio
#y=log_sigma_ratio
#plt.plot(x,y,'.r')
#nbins =3000
#H, xedges,yedges = np.histogram2d(x,y,bins=nbins)
#H = np.rot90(H)
#H = np.flipud(H)
#Hmasked = np.ma.masked_where(H==0,H)
#fig2 = plt.figure()
#plt.pcolormesh(xedges, yedges, Hmasked)
#plt.xlim((-10,5))
#plt.ylim((-2,2))
#plt.title('Full sample : 7075 Quasars ')
#plt.xlabel('log_tau_ratio')
#plt.ylabel('log_sigma_ratio')
#cbar = plt.colorbar()
#cbar.ax.set_ylabel('Counts')
#fname3='corr_h2d-log_sigma_ratio_vs_log_tau_ratio.png'
#plt.savefig(fname3)
#
## SINGLE HISTOGRAMS
for i in range(5,6):
print '\n Plotting histograms for',names[i]
pct1sig = len(stats[i][0:divide]) * np.array([0.25,0.50,0.75])
medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
vsort = np.sort(stats[i][0:divide]) # sorts the array along either sigma or tau dimension
hpdb = vsort[medlowhig] # picks out values at the positions for the
print names[i], ': 25, 50, 75 percentiles for bad tau ', hpdb
hist_minb = hpdb[1] - 2*(hpdb[2]-hpdb[0])
hist_maxb = hpdb[1] +2*(hpdb[2]-hpdb[0])
print 'hist_min, hist_max', hist_minb, hist_maxb
pct1sig = len(stats[i][divide:]) * np.array([0.25,0.50,0.75])
medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
vsort = np.sort(stats[i][divide:]) # sorts the array along either sigma or tau dimension
hpdg = vsort[medlowhig] # picks out values at the positions for the
print names[i], ': 25, 50, 75 percentiles for good tau', hpdg
hist_ming = hpdg[1] - 2*(hpdg[2]-hpdg[0])
hist_maxg = hpdg[1] +2*(hpdg[2]-hpdg[0])
print 'hist_min, hist_max', hist_ming, hist_maxg
plt.clf()
plt.hist(stats[i][0:divide],bins=50)
plt.xlim((hist_minb,hist_maxb))
plot_title = names[i] + 'distribution, bad tau ratio (<-2.5)'
plt.title(plot_title)
plt.xlabel(names[i])
plt.ylabel('Frequency')
fname1 = 'corr_h1d-'+names[i]+'-bad_tau.png'
plt.savefig(fname1)
plt.clf()
plt.hist(stats[i][divide:],bins=50)
plt.xlim((hist_ming,hist_maxg))
plot_title = names[i] + 'distribution, good tau ratio (>-2.5)'
plt.title(plot_title)
plt.xlabel(names[i])
plt.ylabel('Frequency')
fname2 = 'corr_h1d-'+names[i]+'-good_tau.png'
plt.savefig(fname2)
# COLOURED HISTOGRAMS
#for i in range(len(stats)):
#
# pct1sig = len(stats[i][0:divide]) * np.array([0.25,0.50,0.75])
# medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
# vsort = np.sort(stats[i][0:divide]) # sorts the array along either sigma or tau dimension
# hpdb = vsort[medlowhig] # picks out values at the positions for the
# print '\n', names[i], ': 25, 50, 75 percentiles for bad tau ', hpdb
#
# hist_minb = hpdb[1] - 2*(hpdb[2]-hpdb[0])
# hist_maxb = hpdb[1] +2*(hpdb[2]-hpdb[0])
# print 'hist_min, hist_max', hist_minb, hist_maxb
#
#
# pct1sig = len(stats[i][divide:]) * np.array([0.25,0.50,0.75])
# medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
# vsort = np.sort(stats[i][divide:]) # sorts the array along either sigma or tau dimension
# hpdg = vsort[medlowhig] # picks out values at the positions for the
# print '\n',names[i], ': 25, 50, 75 percentiles for good tau', hpdg
#
# hist_ming = hpdg[1] - 2*(hpdg[2]-hpdg[0])
# hist_maxg = hpdg[1] +2*(hpdg[2]-hpdg[0])
# print 'hist_min, hist_max', hist_ming, hist_maxg
#
# for j in range(len(stats)):
# if (i != j) :
# print '\n Plotting coloured hist for',names[i], ' vs ', names[j], 'for bad tau'
# plt.clf()
# fig1 = plt.figure()
# x=stats[i][0:divide]
# y=stats[j][0:divide]
# plt.plot(x,y,'.r')
# plt.xlim((hist_minb,hist_maxb))
# #plt.xlabel(names[i])
# #plt.ylabel(names[j])
# nbins =100
# H, xedges,yedges = np.histogram2d(x,y,bins=nbins)
# H = np.rot90(H)
# H = np.flipud(H)
# Hmasked = np.ma.masked_where(H==0,H)
# fig2 = plt.figure()
# plt.pcolormesh(xedges, yedges, Hmasked)
# plt.xlim((hist_minb,hist_maxb))
# plt.title('Sample with log (tau ratio) <-2')
# plt.xlabel(names[i])
# plt.ylabel(names[j])
# cbar = plt.colorbar()
# cbar.ax.set_ylabel('Counts')
# fname3='corr_h2d-'+names[i]+'_vs_'+names[j]+'-bad_tau.png'
# plt.savefig(fname3)
#
# print '\n Plotting coloured hist for',names[i], ' vs ', names[j], 'for good tau'
# plt.clf()
# fig1 = plt.figure()
# x=stats[i][divide:]
# y=stats[j][divide:]
# plt.plot(x,y,'.r')
# plt.xlim((hist_ming,hist_maxg))
# #plt.xlabel(names[i])
# #plt.ylabel(names[j])
# nbins =100
# H, xedges,yedges = np.histogram2d(x,y,bins=nbins)
# H = np.rot90(H)
# H = np.flipud(H)
# Hmasked = np.ma.masked_where(H==0,H)
# fig2 = plt.figure()
# plt.pcolormesh(xedges, yedges, Hmasked)
# plt.xlim((hist_ming,hist_maxg))
# plt.title('Sample with log (tau ratio) >-2')
# plt.xlabel(names[i])
# plt.ylabel(names[j])
# cbar = plt.colorbar()
# cbar.ax.set_ylabel('Counts')
# fname3='corr_h2d-'+names[i]+'_vs_'+names[j]+'-good_tau.png'
# plt.savefig(fname3)
# AVG ERR TTL
# figuring out what are the percentiles of the avg_err_ttl distribution
#print '\n Plotting histograms for avg err ttl '
#
#pct1sig = len(avg_err_ttl[0:divide]) * np.array([0.25,0.50,0.75])
#medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
#vsort = np.sort(avg_err_ttl[0:divide]) # sorts the array along either sigma or tau dimension
#hpdb = vsort[medlowhig] # picks out values at the positions for the
#print 'avg_err_ttl for bad tau 25, 50, 75 percentiles ', hpdb
#
#hist_minb = hpdb[1] - 2*(hpdb[2]-hpdb[0])
#hist_maxb = hpdb[1] +2*(hpdb[2]-hpdb[0])
#print hist_maxb, hist_minb
#
#pct1sig = len(avg_err_ttl[divide:]) * np.array([0.25,0.50,0.75])
#medlowhig =pct1sig.astype(np.int32) # expresses the pointers above as integers
#vsort = np.sort(avg_err_ttl[divide:]) # sorts the array along either sigma or tau dimension
#hpdg = vsort[medlowhig] # picks out values at the positions for the
#print 'avg_err_ttl for good tau 25, 50, 75 percentiles ', hpdg
#
#hist_ming = hpdg[1] - 2*(hpdg[2]-hpdg[0])
#hist_maxg = hpdg[1] +2*(hpdg[2]-hpdg[0])
#print hist_maxg, hist_ming
#
#
#
#plt.clf()
#plt.hist(avg_err_ttl[0:divide],bins=40)
#plt.xlim((hist_minb,hist_maxb))
#plt.title('Average error distribution, bad tau ratio (<-2)')
#plt.xlabel('Average total error ')
#plt.ylabel('Frequency')
#fname1 = 'qso_corr-avg_ttl_err-bad_tau-hist.png'
#plt.savefig(fname1)
#
#
#plt.clf()
#plt.hist(avg_err_ttl[divide:],bins=40)
#plt.xlim((hist_ming,hist_maxg))
#plt.title('Average error distribution, good tau ratio (>-2)')
#plt.xlabel('Average total error ')
#plt.ylabel('Frequency')
#fname2 = 'qso_corr-avg_ttl_err-good_tau-hist.png'
#plt.savefig(fname2)
#print '\n plotting avg_err_ttl for bad tau vs log_sigma_ration as a colour-coded histogram'
#
#plt.clf()
#fig1 = plt.figure()
#x=avg_err_ttl[0:divide]
#y=log_sigma_ratio[0:divide]
#plt.plot(x,y,'.r')
#plt.xlim((hist_minb,hist_maxb))
#plt.xlabel('Average of quasar error on magnitude')
#plt.ylabel('Log (sigma_jav / sigma_chelsea) ')
#nbins =100
#H, xedges,yedges = np.histogram2d(x,y,bins=nbins)
#H = np.rot90(H)
#H = np.flipud(H)
#Hmasked = np.ma.masked_where(H==0,H)
#fig2 = plt.figure()
#plt.pcolormesh(xedges, yedges, Hmasked)
#plt.xlim((hist_minb,hist_maxb))
#plt.title('Sample with log (tau ratio) <-2')
#plt.xlabel('Average of quasar error on magnitude')
#plt.ylabel('Log (sigma_jav / sigma_chelsea) ')
#cbar = plt.colorbar()
#cbar.ax.set_ylabel('Counts')
#fname3='qso_corr-avg_ttl_err-log_sig_ratio-bad_tau-hist.png'
#plt.savefig(fname3)
#print '\n plotting avg_err_ttl for good tau vs log_sigma_ration as a colour-coded histogram'
#
#plt.clf()
#fig1 = plt.figure()
#x=avg_err_ttl[divide:]
#y=log_sigma_ratio[divide:]
#plt.plot(x,y,'.r')
#plt.xlim((hist_ming,hist_maxg))
#plt.xlabel('Average of quasar error on magnitude')
#plt.ylabel('Log (sigma_jav / sigma_chelsea) ')
#nbins =100
#H, xedges,yedges = np.histogram2d(x,y,bins=nbins)
#H = np.rot90(H)
#H = np.flipud(H)
#Hmasked = np.ma.masked_where(H==0,H)
#fig2 = plt.figure()
#plt.pcolormesh(xedges, yedges, Hmasked)
#plt.xlim((hist_ming,hist_maxg))
#plt.title('Sample with log (tau ratio) >-2')
#plt.xlabel('Average of quasar error on magnitude')
#plt.ylabel('Log (sigma_jav / sigma_chelsea) ')
#cbar = plt.colorbar()
#cbar.ax.set_ylabel('Counts')
#fname3='qso_corr-avg_ttl_err-log_sig_ratio-good_tau-hist.png'
#plt.savefig(fname3)