function uly_lsf_read, lsf_file
lsf = uly_solut_tread(lsf_file, STATUS=status)
if status ne 0 then begin
message, '... try to use a simple tabular format', /INFO
readcol,lsf_file, v, sig, h3, h4, centrWL, F='D,D,D,D,I'
return, {v:v, sig:sig, h3:h3, h4:h4, centrWL:centrWL}
endif
if (size(lsf.losvd, /DIM))[0] ge 2 then begin
v = reform(lsf.losvd[0,*])
sig = reform(lsf.losvd[1,*])
endif
if (size(lsf.losvd, /DIM))[0] ge 3 then h3 = reform(lsf.losvd[2,*]) $
else h3 = 0*v
if (size(lsf.losvd, /DIM))[0] ge 4 then h4 = reform(lsf.losvd[3,*]) $
else h4 = 0*v
centrWL = 0*v
for k=0,n_elements(lsf)-1 do begin
if n_elements(*(lsf[k]).hdr) gt 0 then begin
wave_min = sxpar(*(lsf[k]).hdr, 'WAVE_MIN')
wave_max = sxpar(*(lsf[k]).hdr, 'WAVE_MAX')
centrWL[k] = (wave_min + wave_max) / 2
endif else message, 'Invalid LSF file, cannot find wavelengths'
endfor
if n_elements(v) eq 0 then begin
message, 'Invalid LSF file '+lsf_file
endif
return, {v:v, sig:sig, h3:h3, h4:h4, centrWL:centrWL}
end
pro uly_lsf_plot, lsf_file, CONNECT=connect, PLOT_VAR=plot_var, OVERPLOT=overplot, $
XTITLE=xtitle, YSTYLE=ystyle, $
YMODE=ymode, $
WAVERANGE=waverange, $
VRANGE=vrange, SRANGE=srange, $
TITLE=title, $
XLOG=xlog, YLOG=ylog, $
_EXTRA=extra
lsf = uly_lsf_read(lsf_file)
if size(plot_var, /TYPE) ne 8 then begin
if not keyword_set(psym) then psym=8
plot_var = uly_plot_init(PSYM=psym, _STRICT_EXTRA=extra)
endif
if n_elements(ystyle) eq 0 then ystyle=18
if n_elements(ymode) eq 0 then ymode=0
if keyword_set(waverange) then if size(waverange, /n_elem) ne 2 then $
message, '"WAVERANGE" should be 2 elements array...'
if n_elements(xtitle) eq 0 then xtitle = 'Wavelength, '+'!3' + STRING(197B) + '!X'
plotsym, 0, 1, /FILL
c = 299792.458d
plt = [0,0,0,0]
if min(lsf.v) lt max(lsf.v) then plt[0] = 1
if min(lsf.sig) lt max(lsf.sig) then plt[1] = 1
if min(lsf.h3) lt max(lsf.h3) then plt[2] = 1
if min(lsf.h4) lt max(lsf.h4) then plt[3] = 1
n = where(plt eq 1, nplt)
common plot_init, p1, x1, y1, p2, x2, y2
!p.multi=[0,1,nplt]
margin = 6./nplt
case ymode of
1 : begin
ytitv='Shift, '+'!3' + STRING(197B) + '!X'
vp = lsf.v/c * lsf.centrwl
ytits='FWHM, '+'!3' + STRING(197B) + '!X'
sigp = lsf.sig/c * lsf.centrwl * 2.355
end
else : begin
ytitv='cz, km/s'
vp = lsf.v
ytits='sigma, km/s'
sigp = lsf.sig
end
endcase
if not keyword_set(waverange) then waverange = minmax(lsf.centrwl)
ymargin=[-2,2+margin]
xtickn=replicate(' ', 30)
undefine, xtit
if plt[0] eq 1 then begin
ymargin +=[margin,-margin]
nplt -= 1
if nplt eq 0 then begin
undefine, xtickn
xtit = xtitle
endif
if not keyword_set(overplot) then begin
plot, lsf.centrwl, vp, $
XLOG=xlog, XTICKNAME=xtickn, XTITLE=xtit, XR=waverange, XST=3, $
YLOG=ylog, YRANGE=vrange, YSTYLE=ystyle, YTITLE=ytitv, YMARG=ymargin, $
CHARSIZE=plot_var.charsize, $
TITLE=title, BACK=plot_var.bgcolor, COLOR=plot_var.axiscolor, $
/NODATA, FONT=0
p1 = !P & x1 = !X & y1 = !Y
endif else begin
if n_elements(p1) ne 0 then $
!P = p1 & !X = x1 & !Y = y1
endelse
if keyword_set(connect) then $
oplot, lsf.centrwl, vp, COLOR=FSC_Color(connect), PSYM=0, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
oplot, lsf.centrwl, vp, COLOR=plot_var.linecolor, PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
endif
if plt[1] eq 1 then begin
ymargin += [margin,-margin]
nplt -= 1
if nplt eq 0 then begin
undefine, xtickn
xtit = xtitle
endif
if not keyword_set(overplot) then begin
plot, lsf.centrwl, sigp, $
XLOG=xlog, XTICKNAME=xtickn, XTITLE=xtit, XR=waverange, XST=3, $
YLOG=ylog, YRANGE=srange, YSTYLE=ystyle, YTITLE=ytits, YMARG=ymargin, $
CHARSIZE=plot_var.charsize, $
BACK=plot_var.bgcolor, COLOR=plot_var.axiscolor, $
/NODATA, FONT=0
p2 = !P & x2 = !X & y2 = !Y
endif else begin
if n_elements(p2) ne 0 then $
!P = p2 & !X = x2 & !Y = y2
endelse
if keyword_set(connect) then $
oplot, lsf.centrwl, sigp, COLOR=FSC_Color(connect), PSYM=0, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
oplot, lsf.centrwl, sigp, COLOR=plot_var.linecolor, PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
endif
if plt[2] eq 1 then begin
ymargin +=[margin,-margin]
nplt -= 1
if nplt eq 0 then begin
undefine, xtickn
xtit = xtitle
endif
if not keyword_set(overplot) then begin
plot, lsf.centrwl, lsf.h3, $
XLOG=xlog, XTICKNAME=xtickn, XTITLE=xtit, XR=waverange, XST=3, $
YLOG=ylog, YRANGE=srange, YSTYLE=ystyle, YTITLE='h3', YMARG=ymargin, $
CHARSIZE=plot_var.charsize, $
BACK=plot_var.bgcolor, COLOR=plot_var.axiscolor, $
/NODATA, FONT=0
p2 = !P & x2 = !X & y2 = !Y
endif else begin
if n_elements(p2) ne 0 then $
!P = p2 & !X = x2 & !Y = y2
endelse
if keyword_set(connect) then $
oplot, lsf.centrwl, lsf.h3, COLOR=FSC_Color(connect), PSYM=0, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
oplot, lsf.centrwl, lsf.h3, COLOR=plot_var.linecolor, PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
endif
if plt[3] eq 1 then begin
ymargin +=[margin,-margin]
nplt -= 1
if nplt eq 0 then begin
undefine, xtickn
xtit = xtitle
endif
if not keyword_set(overplot) then begin
plot, lsf.centrwl, lsf.h4, $
XLOG=xlog, XTICKNAME=xtickn, XTITLE=xtit, XR=waverange, XST=3, $
YLOG=ylog, YRANGE=srange, YSTYLE=ystyle, YTITLE='h4', YMARG=ymargin, $
CHARSIZE=plot_var.charsize, $
BACK=plot_var.bgcolor, COLOR=plot_var.axiscolor, $
/NODATA, FONT=0
p2 = !P & x2 = !X & y2 = !Y
endif else begin
if n_elements(p2) ne 0 then $
!P = p2 & !X = x2 & !Y = y2
endelse
if keyword_set(connect) then $
oplot, lsf.centrwl, lsf.h4, COLOR=FSC_Color(connect), PSYM=0, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
oplot, lsf.centrwl, lsf.h4, COLOR=plot_var.linecolor, PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
endif
!p.multi=0
end
Part of