Viewing contents of file '../idllib/ghrs/pro/coadd_exps.pro'
PRO COADD_EXPS,WAVE,FLUX,OUTWAVE,OUTFLUX
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+
;
;*NAME: COADD_EXPS
;
;*CLASS:
;
;*CATEGORY:
;
;*PURPOSE:
; Coadd multiple readouts (sub_exposures) by linearly interpolating
; each flux exposure onto the same scale, coadd and then average.
;
;*CALLING SEQUENCE:
; COADD_EXPS,WAVE,FLUX,OUTWAVE,OUTFLUX
;
;*PARAMETERS:
; WAVE - (2D array) - input array of wavelengths
; FLUX - (2D array) - input array of fluxes
; OUTPUT:
; OUTWAVE - wavelength vector. The first wavelength grid is used.
; OUTFLUX - averaged coadded flux vector.
;
;*EXAMPLES:
;
;*NOTES:
; Data quality and error vector are not taken into account.
;
;*PROCEDURE:
; Output has additional subexposures interpolated
; to first wavelength grid, and then averaged.
;
;*MODIFICATION HISTORY:
; R Robinson - version 1
; 28-apr-1992 JKF/ACC - moved to GHRS DAF (V2).
;-
;-------------------------------------------------------------------------------
on_error,2
if n_params(0) lt 1 then $
message,'Calling Sequence: COADD_EXPS,wave,flux,OUTWAVE,OUTFLUX'
S = SIZE(WAVE)
IF S(0) NE 2 THEN $
message,'Input array (wave,flux) must be 2-DIMENSIONAL'
NPTS=S(1) ;NUMBER OF POINTS PER SUB-EXPOSURE
NSUB=S(2) ;NUMBER OF SUB-EXPOSURES
OUTWAVE = WAVE(*,0)
OFI = FLUX
OUTFLUX = FLUX(*,0)
;
; INTERPOLATE SUB-EXPOSURES TO FIRST WAVELENGTH GRID AND AVERAGE
;
FOR I=1,NSUB-1 DO BEGIN
LINTERP,WAVE(*,I),FLUX(*,I),OUTWAVE,OFI
OUTFLUX=OUTFLUX+OFI
ENDFOR
OUTFLUX=OUTFLUX/FLOAT(NSUB) ; average here
;
RETURN
END