Viewing contents of file '../idllib/ghrs/pro/calhrs_dqi.pro'
pro calhrs_dqi,fname,udls,eps,log
;***************************************************************************
;+
;*NAME:
; calhrs_dqi
;
;*PURPOSE:
; Routine to perform data quality initialization
;
;*CALLING SEQUENCE:
; calhrs_dqi,fname,udls,eps,log
;
;*PARAMTERS:
; INPUTS:
; fname - file name of the data quality initialization file
; udls - unique data logs
;
; INPUTS/OUTPUTS:
; eps -data quality array (512xN)
;
; OPTIONAL INPUT/OUTPUT:
; log - update log (string array)
;
; METHOD:
; The 512 point initialization vector, DQI, is read from the
; reference file (fname). Where DQI(i) is greater then
; EPS(i,j), EPS(i,j) is set to DQI(i).
;
; OPERATIONAL NOTES:
; unit 8 is used for reading the reference file.
;
; HISTORY:
; version 1 D. Lindler Mar 89
; version 2.0 D. Lindler Mar 91 added combaddition affect on epsilons
;-
;---------------------------------------------------------------------------
version = 2.0 ;software version number
;
; read reference file
;
sxopen,8,strtrim(fname,2),h
dqi=sxread(8)
if n_elements(dqi) ne 512 then begin
print,'CALHRS_DQI--Invalid data quality initialization file '+$
strtrim(fname,2)
retall
endif
;
; determine number of diodes used for combaddition
;
last = where(udls(37:41) eq 0) ;initial xdeflections > 0
if !err lt 0 then ncomb=5 else ncomb = last(0)
;
; correct DQI for combaddition
;
dq1 = dqi(0:5) ;first special diodes
dq2 = dqi(506:511) ;last special diodes
dqi = dqi(6:505) ;main array diodes
dq = dqi
if ncomb gt 1 then for i=1,ncomb-1 do dqi(i) = dqi(i:499)>dq
dqi = [dq1,dqi,dq2]
;
; update epsilon values
;
n = n_elements(eps)/512
for i=0,n-1 do eps(0,i)=eps(*,i)>dqi
;
; update log
;
hist=strarr(3)
hist(0)='CALHRS_DQI version '+string(version,'(f5.2)')+ $
': Data quality initialization performed'
hist(1)=' Reference file = '+strtrim(fname,2)
hist(2)=' Epsilon propagation for comb-addition over'+ $
string(ncomb,'(I2)')+' diodes'
if n_params(0) gt 3 then sxaddhist,hist,log
if !dump gt 0 then printf,!textunit,hist
return
end