Viewing contents of file '../idllib/ghrs/pro/calhrs_exp.pro'
pro calhrs_exp,ih,data,errors,log
;
;+
;*NAME:
;			calhrs_exp
;
;*PURPOSE:
; Routine to convert to count rates.
;
;*CALLING SEQUENCE:
;	calhrs_exp,ih,data,errors
;
;*PARAMETERS:
; INPUTS:
;	ih - header array (128xN)
;
; INPUT/OUTPUT:
;	data - data array (512xN)
;	errors - propagated error array (512xN).
;		if set to a scalar (errors calculation is not done)
;
; OPTIONAL INPUT/OUTPUT:
;	log - processing log (string array)
;
; METHOD:
;	exposure time is computed as
;		((NPER * 0.05) - 0.002) * NCOADDS
;	where NPER is the number of 50 millisecond periods per coadd
;	      NCOADDS is the number of times data was coadded to the bin
; HISTORY:
;	version 1  D. Lindler  March 89
;-
;--------------------------------------------------------------------------
 
		VERSION = 1.0			; software version number
 
;
; get sizes
;
	;	s=size(data) & n=s(2)
	s=size(data) & n=n_elements(data)/s(1)		; IDLV2
	if n_elements(errors) lt 2 then err_flag=0 else err_flag=1
;
; loop on substep bins
;
	for i=0,n-1 do begin
		expo = (ih(45,i)*0.05 - 0.002) * (ih(46,i)>1)
		data(0,i)=data(*,i)/expo
		if err_flag then errors(0,i)=errors(*,i)/expo
		ih(66,i)=ih(66,i) or 1		;record completion
	end
;
; update log
;
	hist='CALHRS_EXP version '+string(version,'(f5.2)')+ $
			': Data converted to count rates'
	if n_params(0) gt 3 then sxaddhist,hist,log
	if !dump gt 0 then printf,!textunit,hist
	return
	end