Viewing contents of file '../idllib/ghrs/pro/calfos_ccs2.pro'
pro calfos_ccs2,name,config,pattern,h,line_beg,line_end
;+
; CALFOS_CCS2
;
; Read sky emission line table
;
; CALLING SEQUENCE:
; calfos_ccs2,name,config,h,line_beg,line_end
;
; INPUTS:
; name - CCS2 table name
; config - configuration vector (from CALFOS_RD)
; pattern - pattern vector (from CALFOS_RD)
;
; INPUT/OUTPUTS:
; h - FITS header for the observation
;
; OUTPUTS:
; line_beg - vector of beginning positions
; line_end - vector of ending positions
;
; HISTORY:
; version 1.0 D. Lindler Jan 1990
;-
;---------------------------------------------------------------------------
;
; read table
;
fname = strtrim(name)
if fname eq '' then return ;Do we need the values?
tab_read,fname,tcb,tab
;
; add history
;
hist = 'Sky emission line table: '+fname
sxaddhist,hist,h
if !dump gt 0 then print,hist
;
; extract columns to be searched on
;
detector = strtrim(config(0))
fgwa_id = strtrim(config(3))
nxsteps = pattern(3)
det = tab_val(tcb,tab,'DETECTOR')
fgwa = tab_val(tcb,tab,'FGWA_ID')
nxs = tab_val(tcb,tab,'NXSTEPS')
nrows = n_elements(nxs)
;
; search table for correct detector and aper_id
;
good = bytarr(nrows)
for i=0,nrows-1 do begin
if (strtrim(fgwa(i)) eq fgwa_id) and $
(strtrim(det(i)) eq detector) and $
(nxs(i) eq nxsteps) then good(i) = 1b
endfor
good = where(good) & ngood = !err
if ngood lt 1 then goto,none_found
;
; extract positions
;
line_beg = fix(tab_val(tcb,tab,'LINE_BEG',good)+0.5)
line_end = fix(tab_val(tcb,tab,'LINE_END',good)+0.5)
fc = tab_val(tcb,tab,'FCHNL',good)
;
; correct for differences in first channel
;
fchnl = pattern(0)
offset = (fchnl-fc)*nxsteps
line_beg = line_beg - offset
line_end = line_end - offset
;
; delete lines outside of range
;
ns = pattern(8)
good = where((line_beg lt ns) and (line_end gt 0)) & ngood=!err
if ngood lt 1 then goto,none_found
line_beg = line_beg(good)>0
line_end = line_end(good)<(ns-1)
return
none_found:
line_beg = intarr(1)-1
line_end = line_beg
return
end