pro uly_spect_plot, filein, OVERPLOT=over, $
WAVERANGE=waverange, YRANGE=fluxrange, $
NORM=norm, ONED=oned, $
XLOG=xlog, YLOG=ylog, $
TITLE=title, $
PLOT_VAR=plot_var, QUIET=quiet, _EXTRA=extra
if size(filein,/TYPE) eq 8 then begin
sp = uly_spect_extract(filein, ONED=oned)
file = '<spectrum>'
endif else begin
if size(filein, /TYPE) ne 7 then $
message,'The input must be a file name or a spect structure'
file = filein
endelse
if file ne '<spectrum>' then begin
testinp = file_test(file)
if testinp eq 0 then $
message,'The file:'+file+' does not exist. Give correct name for the input file.'
sp = uly_spect_read(filein, QUIET=quiet)
sp = uly_spect_extract(sp, ONED=oned, /OVERWRITE)
endif
if keyword_set(over) then if size(over, /type) ne 7 then over='Blue'
if keyword_set(waverange) then if size(waverange, /n_elem) ne 2 then $
message, '"WAVERANGE" should be 2 elements array...'
if keyword_set(fluxrange) then if size(fluxrange, /n_elem) ne 2 then $
message, '"YRANGE" should be 2 elements array...'
if keyword_set(norm) then if size(norm, /n_elem) ne 2 then $
message, '"NORM" should be 2 elements array...'
if not keyword_set(plot_var) or size(plot_var, /type) ne 8 then begin
if not keyword_set(linecolor) then linecolor='Black'
plot_var = uly_plot_init(LINECOLOR=linecolor, _extra=extra)
endif
if sp.sampling le 1 then begin
wl = (sp.start+sp.step*findgen(n_elements(*sp.data)))
if sp.sampling eq 1 then wl = exp(wl)
endif else if sp.sampling eq 2 then wl = *sp.wavelen
if n_elements(*sp.goodpix) gt 0 then goodpix = *sp.goodpix $
else goodpix = where(finite(*sp.data))
if keyword_set(norm) then $
*sp.data = *sp.data/mean((*sp.data)[where(wl ge norm[0] and wl le norm[1] )])
if not keyword_set(waverange) then waverange = minmax(wl)
if not keyword_set(fluxrange) then fluxrange = minmax((*sp.data)[goodpix])
if not keyword_set(over) then begin
if n_elements(title) eq 0 then title=sp.title
plot, wl, *sp.data, XR=waverange, YR=fluxrange, XSTYLE=3, YSTYLE=3, $
XTITLE='Wavelength, '+'!3' + STRING(197B) + '!X', YTITLE='Flux', TITLE=title, $
CHARSIZE=plot_var.charsize, $
BACK=plot_var.bgcolor, COLOR=plot_var.axiscolor, $
XLOG=xlog, YLOG=ylog, /NODATA
endif
goodspec = *sp.data*!VALUES.F_NAN
badspec = *sp.data*!VALUES.F_NAN
goodspec[goodpix] = (*sp.data)[goodpix]
badpix = uly_plot_padpixelrange(where(finite(goodspec, /NAN), badcount) )
if badcount gt 0 then begin
badpix = uly_plot_padpixelrange(badpix)
badspec[badpix] = (*sp.data)[badpix]
endif
oplot, wl, goodspec, COLOR=plot_var.linecolor, $
PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
if badcount gt 1 then $
oplot, wl, badspec, COLOR=FSC_Color(plot_var.badcolor), $
PSYM=plot_var.psym, LINESTYLE=plot_var.linestyle, THICK=plot_var.linethick
uly_spect_free, sp
end
Part of