Viewing contents of file '../idllib/ghrs/pro/calhrs_ppc.pro'
pro calhrs_ppc,ih,data,eps,errors,log
;
;+
; calhrs_ppc
;
; Performs the paired pulse (deadtime) correction of GHRS
; data.
;
; CALLING SEQUENCE:
; calhrs_ppc,ih,data,eps,errors,log
;
; INPUT/OUTPUTS:
;
; ih - header array, 128xN (returned by HRS_READ)
; data - data array (512xN) previously converted to count rates
; eps - data quality array (512xN)
;
; OPTIONAL INPUT/OUTPUTS:
;
; errors - statistical error array. If not supplied or a scalar
; is supplied, error propagation is not performed.
; log - processing log (string array)
;
; METHOD:
;
; The true count rate, x, is computed from the observed count
; rate, y by:
; x = alog(1-ty)/(-t)
;
; where t is a time coef. set to 10.4 microseconds.
;
; The data quality array, EPS, is updated to indicate rates
; in the non-linear range (where the correction is good to a best
; 5 % and 20%) and saturated points (where to correction is good to only
; 50%).
; count rate epsilon
; 10,000 130
; 30,000 190
; 50,000 300
;
; HISTORY:
; version 1.0 D. Lindler March 1989
; version 1.1 D. Lindler March 1991
; changed epsilon flags to match FOS
;-
;--------------------------------------------------------------------------
;
; reduction parameters
;
version=1.1 ;should be updated if any parameter is changed
non_linear = 10000 ;count rate for 5 uncertain saturation corr.
eps_non_linear = 130
near_saturated = 30000 ;paired pulse correction error> 20%
eps_near_sat = 190
saturated = 50000 ;paired pulse correction error> 50%
eps_saturated = 300
t = 10.4d-6 ;time constant
;
; perform paired pulse correction
;
nerr=n_elements(error)
s=size(data) & n=n_elements(data)/s(1)
for i=0,n-1 do begin ;loop to minimize page swaping in ddlink
y = data(*,i)
x = alog((1.0 -y*t)>1e-6)/(-t)
data(0,i)=x
;
; update data quality vector
;
e=eps(*,i)
bad=where(y ge non_linear)
if !err gt 0 then e(bad)=e(bad)>eps_non_linear
bad=where(y ge near_saturated)
if !err gt 0 then e(bad)=e(bad)>eps_near_sat
bad=where(y ge saturated)
if !err gt 0 then e(bad)=e(bad)>eps_saturated
eps(0,i)=e
;
; update propagated error
;
if nerr gt 1 then begin
e=errors(*,I)
e= (x>1e-8)/(y>1e-8)
errors(0,i)=e
endif
;
; record completion of the step
;
ih(66,i)=ih(66,i) or 2
endfor
;
; update log
;
hist=strarr(2)
hist(0)='CALHRS_PPC version '+string(version,'(f5.2)')+ $
': Paired pulse correction performed'
hist(1)=' Time constant ='+string(t,'(e12.4)')
if n_params(0) gt 4 then sxaddhist,hist,log
if !dump gt 0 then printf,!textunit,hist
return
end