/
cos_pg1617ly.pro
197 lines (186 loc) · 7.76 KB
/
cos_pg1617ly.pro
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
pro cos_pg1617ly
directoryname = '/Users/drupke/Box Sync/cosquest/fits/'
gal = 'pg1617'
zsys=0.114d
readcol,directoryname+gal+'/'+gal+'.txt', wavelength, flux, error, $
FORMAT='D,D,D',/silent
; Lyalpha
fittedline = 'Lyalpha'
contplotreg=[1280,1440]
contplotind=[VALUE_LOCATE(wavelength,contplotreg[0]),$
VALUE_LOCATE(wavelength,contplotreg[1])]
goodind = [[1141,1142],[1147.5,1151.5],[1153,1189],[1191,1192.5],[1194,1198],$
[1201.5,1205],[1207.5,1224.5],[1225.5,1231.5],[1232.5,1236.5],$
[1237.7,1238.2],[1239.2,1239.3],[1240.5,1242],[1243.5,1250],$
[1251.5,1253.5],[1254.5,1257.5],[1261,1276.5],[1278.5,1301],$
[1305,1320],[1321,1325],$
[1326,1327],[1330,1333.5],[1336.5,1339],$
[1344,1346.5],[1347.5,1349],[1350.5,1360],[1369,1369.8],[1374,1392.5],$
[1394.5,1402],$
[1404,1440]]
for i=0,n_elements(goodind[0,*])-1 do begin
newind=INDGEN(VALUE_LOCATE(wavelength,goodind[1,i])-$
VALUE_LOCATE(wavelength,goodind[0,i]),$
START=VALUE_LOCATE(wavelength,goodind[0,i]))
if i eq 0 then indextofit = newind $
else indextofit = [indextofit,newind]
endfor
weight=dblarr(n_elements(error))
tolerance = 1d-80
ibd = where(error^2d LT tolerance)
igd = where(error^2d GE tolerance)
weight[ibd] = 0.0d0
weight[igd] = 1d/error[igd]^2d
contfitreg=[[1280,1440]]
fitfcn=['ifsf_fittemplate']
fitargs=HASH()
parinfo = replicate({value:0d,fixed:0b},4)
parinfo[0].value = 1d-14
fitargs['reg1'] = {templatefcn: 'cos_quasarcomposite',$
parinfo:parinfo, npar:4}
templatefile = '/Users/drupke/Box Sync/cosquest/spectra/template/'+$
'harris15_composite.fits'
fxbopen,tlun,templatefile,1
fxbread,tlun,twave,1
fxbread,tlun,tflux,2
fxbclose,tlun
twave *= 1d + zsys
itflux = double(ifsf_interptemp(wavelength,twave,tflux))
itflux /= median(itflux)
set_plot,'z'
cgplot, wavelength, flux, XRAN=contplotreg, $
YRAN=[-.3*MAX(flux[contplotind[0]:contplotind[1]]),$
1.5*MAX(flux[contplotind[0]:contplotind[1]])],$
XSTYLE=1,YSTYLE=1,backg='Black',axiscolor='White',color='White',$
xtit='Wavelength ($\Angstrom$)',$
ytit='Flux (ergs s$\up-1$ cm$\up-2$ $\Angstrom$$\up-1$)'
continuum=$
ifsf_fitmulticont(wavelength, flux, weight, wavelength, itflux, $
indextofit,0,fitreg=contfitreg,$
fitfcn=fitfcn, fitargs=fitargs)
cgoplot, wavelength, continuum, color='Red',thick=4
img = cgsnapshot(filename=directoryname+'/'+gal+'/'+'/'+gal+fittedline+$
'_continuum',/jpeg,/nodialog,quality=100)
nct = contplotind[1]-contplotind[0]+1
nflux = dblarr(nct)
nerr = dblarr(nct)
openw,outlun,directoryname+gal+'/'+gal+fittedline+'_contfit.txt',/get_lun
for i=0,nct-1 do $
printf,outlun,wavelength[contplotind[0]+i],flux[contplotind[0]+i],$
error[contplotind[0]+i],$
flux[contplotind[0]+i]/continuum[contplotind[0]+i],$
error[contplotind[0]+i]/continuum[contplotind[0]+i],$
format='(D12.4,E12.4,E12.4,D8.4,D8.4)'
free_lun,outlun
; spline/poly
; fittedline = 'Lyalpha'
; contplotreg=[1330,1354]
; contplotind=[VALUE_LOCATE(wavelength,contplotreg[0]),$
; VALUE_LOCATE(wavelength,contplotreg[1])]
; goodind = [[1330,1333.5],[1336.5,1339],[1344,1346.5],[1347.5,1349],$
; [1350.5,1354]]
; for i=0,n_elements(goodind[0,*])-1 do begin
; newind=INDGEN(VALUE_LOCATE(wavelength,goodind[1,i])-$
; VALUE_LOCATE(wavelength,goodind[0,i]),$
; START=VALUE_LOCATE(wavelength,goodind[0,i]))
; if i eq 0 then indextofit = newind $
; else indextofit = [indextofit,newind]
; endfor
; weight=1d/error^2
; contfitreg=[1330,1354]
; fitfcn=['ifsf_fitpoly']
; fitargs=HASH()
; fitargs['reg1'] = {}
;
; set_plot,'z'
; cgplot, wavelength, flux, XRAN=contplotreg, $
; YRAN=[-.3*MAX(flux[contplotind[0]:contplotind[1]]),$
; 1.5*MAX(flux[contplotind[0]:contplotind[1]])],$
; XSTYLE=1,YSTYLE=1,backg='Black',axiscolor='White',color='White',$
; xtit='Wavelength ($\Angstrom$)',$
; ytit='Flux (ergs s$\up-1$ cm$\up-2$ $\Angstrom$$\up-1$)'
; continuum=$
; ifsf_fitmulticont(wavelength, flux, weight, wavelength, itflux, $
; indextofit,0,fitreg=contfitreg,$
; fitfcn=fitfcn, fitargs=fitargs)
; cgoplot, wavelength, continuum, color='Red',thick=4
; img = cgsnapshot(filename=directoryname+'/'+gal+'/'+'/'+gal+fittedline+$
; '_continuum',/jpeg,/nodialog,quality=100)
;
; nct = contplotind[1]-contplotind[0]+1
; nflux = dblarr(nct)
; nerr = dblarr(nct)
; openw,outlun,directoryname+gal+'/'+gal+fittedline+'_contfit.txt',/get_lun
; for i=0,nct-1 do $
; printf,outlun,wavelength[contplotind[0]+i],flux[contplotind[0]+i],$
; error[contplotind[0]+i],$
; flux[contplotind[0]+i]/continuum[contplotind[0]+i],$
; error[contplotind[0]+i]/continuum[contplotind[0]+i],$
; format='(D12.4,E12.4,E12.4,D8.4,D8.4)'
; free_lun,outlun
; Lybeta
fittedline = 'Lybeta'
contplotreg=[1133,1175]
contplotind=[VALUE_LOCATE(wavelength,contplotreg[0]),$
VALUE_LOCATE(wavelength,contplotreg[1])]
goodind = [[1141,1142],[1147.5,1151.5],[1153,1189],[1191,1192.5],[1194,1198],$
[1201.5,1205],[1207.5,1224.5],[1225.5,1231.5],[1232.5,1236.5],$
[1237.7,1238.2],[1239.2,1239.3],[1240.5,1242],[1243.5,1250],$
[1251.5,1253.5],[1254.5,1257.5],[1261,1276.5],[1278.5,1301],$
[1305,1320],[1321,1325],[1326,1327],[1330,1333.5],[1336.5,1339],$
[1344,1346.5],[1347.5,1349],[1350.5,1360],[1369,1369.8],[1374,1390]]
for i=0,n_elements(goodind[0,*])-1 do begin
newind=INDGEN(VALUE_LOCATE(wavelength,goodind[1,i])-$
VALUE_LOCATE(wavelength,goodind[0,i]),$
START=VALUE_LOCATE(wavelength,goodind[0,i]))
if i eq 0 then indextofit = newind $
else indextofit = [indextofit,newind]
endfor
weight=dblarr(n_elements(error))
tolerance = 1d-80
ibd = where(error^2d LT tolerance)
igd = where(error^2d GE tolerance)
weight[ibd] = 0.0d0
weight[igd] = 1d/error[igd]^2d
contfitreg=[[1133,1175]]
fitfcn=['ifsf_fittemplate']
fitargs=HASH()
parinfo = replicate({value:0d,fixed:0b},4)
parinfo[0].value = 1d-14
fitargs['reg1'] = {templatefcn: 'cos_quasarcomposite',$
parinfo:parinfo, npar:4}
templatefile = '/Users/drupke/Box Sync/cosquest/spectra/template/'+$
'harris15_composite.fits'
fxbopen,tlun,templatefile,1
fxbread,tlun,twave,1
fxbread,tlun,tflux,2
fxbclose,tlun
twave *= 1d + zsys
itflux = double(ifsf_interptemp(wavelength,twave,tflux))
itflux /= median(itflux)
set_plot,'z'
cgplot, wavelength, flux, XRAN=contplotreg, $
YRAN=[-.3*MAX(flux[contplotind[0]:contplotind[1]]),$
1.5*MAX(flux[contplotind[0]:contplotind[1]])],$
XSTYLE=1,YSTYLE=1,backg='Black',axiscolor='White',color='White',$
xtit='Wavelength ($\Angstrom$)',$
ytit='Flux (ergs s$\up-1$ cm$\up-2$ $\Angstrom$$\up-1$)'
continuum=$
ifsf_fitmulticont(wavelength, flux, weight, wavelength, itflux, $
indextofit,0,fitreg=contfitreg,$
fitfcn=fitfcn, fitargs=fitargs)
cgoplot, wavelength, continuum, color='Red',thick=4
img = cgsnapshot(filename=directoryname+'/'+gal+'/'+'/'+gal+fittedline+$
'_continuum',/jpeg,/nodialog,quality=100)
nct = contplotind[1]-contplotind[0]+1
nflux = dblarr(nct)
nerr = dblarr(nct)
openw,outlun,directoryname+gal+'/'+gal+fittedline+'_contfit.txt',/get_lun
for i=0,nct-1 do $
printf,outlun,wavelength[contplotind[0]+i],flux[contplotind[0]+i],$
error[contplotind[0]+i],$
flux[contplotind[0]+i]/continuum[contplotind[0]+i],$
error[contplotind[0]+i]/continuum[contplotind[0]+i],$
format='(D12.4,E12.4,E12.4,D8.4,D8.4)'
free_lun,outlun
END