-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRead_Syste.py
143 lines (114 loc) · 6.33 KB
/
Read_Syste.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
from astropy.table import vstack,Table
from astropy.io import ascii
import matplotlib.pyplot as plt
import numpy as np
def Plot_Filters(sela,what_x='',what_y=[],ratio_x=False,ratio_y=False,legx='',legy='',prefixa='LSST::',title=''):
fige, axe = plt.subplots(ncols=2, nrows=3, figsize=(14,10))
fige.suptitle(title)
for j,band in enumerate(['u','g','r','i','z','y']):
selac=sela[np.where(np.logical_and(sela['filter']==prefixa+band,sela['e_per_sec']/sela['e_per_sec_err']>=5.))]
if j<2:
k=0
if j>= 2 and j < 4:
k=1
if j>=4:
k=2
if not ratio_x:
if not ratio_y:
drawx=selac[what_x]
drawy_1=selac[what_y[0]]-selac[what_y[1]]
drawy_2=selac[what_y[0]]-selac[what_y[2]]
else:
drawx=selac[what_x]
if what_y[1] != 'filtSkyBrightness':
drawy_1=selac[what_y[1]]/selac[what_y[0]]
drawy_2=selac[what_y[2]]/selac[what_y[0]]
else:
drawy_1=0.5*(selac[what_y[1]]-21.)/selac[what_y[0]]
drawy_2=0.5*(selac[what_y[2]]-21.)/selac[what_y[0]]
else:
if not ratio_y:
axe[k][j%2].plot(selac[what_x],selac[what_y[0]]-selac[what_y[1]],'k.')
axe[k][j%2].plot(selac[what_x],selac[what_y[0]]-selac[what_y[2]],'r.')
else:
drawx=selac[what_x]/selac[what_y[0]]
drawy_1=selac[what_x]/selac[what_y[0]]-selac[what_x]/selac[what_y[1]]
drawy_2=selac[what_x]/selac[what_y[0]]-selac[what_x]/selac[what_y[2]]
axe[k][j%2].plot(drawx,drawy_1,'k.')
axe[k][j%2].plot(drawx,drawy_2,'r.')
axe[k][j%2].set_xlabel(r''+legx,{'fontsize': 12.})
axe[k][j%2].set_ylabel(r''+legy,{'fontsize': 12.})
axe[k][j%2].set_title(band,loc='left')
def Plot_Multiple(sela,what_x='',what_y=[],ratio_x=False,ratio_y=False,legx='',legy='',prefixa='LSST::',title=''):
fige, axe = plt.subplots(ncols=2, nrows=3, figsize=(14,10))
colors=['b','g','r','m','c']
fige.suptitle(title)
for j,band in enumerate(['u','g','r','i','z','y']):
selac=sela[np.where(np.logical_and(sela['filter']==prefixa+band,sela['e_per_sec']/sela['e_per_sec_err']>=5.))]
if j<2:
k=0
if j>= 2 and j < 4:
k=1
if j>=4:
k=2
for i in range(1,6,1):
drawx=selac[what_x]
drawy_1=selac[what_y[0]]-selac[what_y[1]+'_'+str(i)]
drawy_2=selac[what_y[0]]-selac[what_y[2]+'_'+str(i)]
axe[k][j%2].plot(drawx,drawy_1,colors[i-1]+'*',label='$m_{sky}-'+str(0.1*i)+'$')
axe[k][j%2].plot(drawx,drawy_2,colors[i-1]+'o',label='$m_{sky}+'+str(0.1*i)+'$')
axe[k][j%2].set_xlabel(r''+legx,{'fontsize': 12.})
axe[k][j%2].set_ylabel(r''+legy,{'fontsize': 12.})
axe[k][j%2].set_title(band,loc='left')
axe[k][j%2].legend(loc='upper left',fontsize=5)
def Plot_Multiple_SNR(sela,what_x='',what_y=[],ratio_x=False,ratio_y=False,legx='',legy='',prefixa='LSST::',title=''):
fige, axe = plt.subplots(ncols=2, nrows=3, figsize=(14,10))
colors=['b','g','r','m','c']
fige.suptitle(title)
for j,band in enumerate(['u','g','r','i','z','y']):
selac=sela[np.where(np.logical_and(sela['filter']==prefixa+band,sela['e_per_sec']/sela['e_per_sec_err']>=5.))]
if j<2:
k=0
if j>= 2 and j < 4:
k=1
if j>=4:
k=2
for i in range(1,6,1):
drawx=selac[what_x]
drawy_1=selac[what_x]/selac[what_y[1]+'_'+str(i)]
drawy_2=selac[what_x]/selac[what_y[2]+'_'+str(i)]
axe[k][j%2].plot(drawx,drawy_1,colors[i-1]+'*',label='$m_{sky}-'+str(0.1*i)+'$')
axe[k][j%2].plot(drawx,drawy_2,colors[i-1]+'o',label='$m_{sky}+'+str(0.1*i)+'$')
axe[k][j%2].plot([18, 26], [5.,5.], color='r', linestyle='-', linewidth=1)
#axe[k][j%2].set_yscale('log')
axe[k][j%2].set_ylim([0.,50.])
axe[k][j%2].set_xlabel(r''+legx,{'fontsize': 12.})
axe[k][j%2].set_ylabel(r''+legy,{'fontsize': 12.})
axe[k][j%2].set_title(band,loc='left')
axe[k][j%2].legend(loc='upper left',fontsize=5)
dir_snsim='lc4pg'
table_params=ascii.read(dir_snsim+'/sample.ntuple',fast_reader=False)
for i,name in enumerate(['z','dL','DayMax','X1','Color','ra','dec']):
table_params.rename_column('col'+str(i+1),name)
for num in range(len(table_params)):
file_name='LC_systes/lc_'+str(num).zfill(4)+'.txt'
if num == 0:
table_syste = ascii.read(file_name,fast_reader=False)
else:
table_n = ascii.read(file_name,fast_reader=False)
table_syste=vstack([table_syste,table_n])
#print num,len(table_match),len(table_n)
#if num >=100:
#break
print table_syste
Plot_Filters(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus_5','err_mag_plus_5'])
Plot_Filters(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus_5','err_mag_plus_5'],ratio_y=True)
Plot_Filters(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus_5','err_mag_plus_5'],ratio_x=True,ratio_y=True)
Plot_Filters(table_syste,what_x='fiveSigmaDepth',what_y=['fiveSigmaDepth','fiveSigmaThrough','fiveSigmaThrough'],legx='$m_5^{OpSim}$',legy='$m_5^{OpSim}-m_5^{throughput}$')
#Plot_Filters(table_syste,what_x='fiveSigmaThrough',what_y=['fiveSigmaThrough','fiveSigmaThrough_plus','fiveSigmaThrough_minus'],legx='$m_5^{throughput}$',legy='$\Delta m_5$')
Plot_Filters(table_syste,what_x='fiveSigmaDepth',what_y=['fiveSigmaDepth','filtSkyBrightness','filtSkyBrightness'],ratio_y=True)
Plot_Multiple(table_syste,what_x='fiveSigmaThrough',what_y=['fiveSigmaThrough','fiveSigmaThrough_plus','fiveSigmaThrough_minus'],legx='$m_5^{throughput}$',legy='$\Delta m_5$')
Plot_Multiple(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus','err_mag_plus'],legx='SN mag',legy='$\Delta \sigma=\sigma_{nom}-\sigma_{sky var.}$ [mag]')
Plot_Multiple(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus','err_mag_plus'],legx='SN mag',legy='$\Delta \sigma=\sigma_{nom}-\sigma_{sky var.}$ [mag]')
Plot_Multiple_SNR(table_syste,what_x='mag',what_y=['err_mag','err_mag_minus','err_mag_plus'],legx='SN mag',legy='SNR')
plt.show()