Viewing contents of file '../idllib/iuedac/iuelib/pro/com_spl.pro'
;************************************************************************
;+
;*NAME:
;
;	COM_SPL
;  
;*CLASS:
;
;	Spectral Data Reduction
;  
;*CATEGORY:
;  
;*PURPOSE:
;
;	Creates a new wavlength vector composed of those wavelengths of wave1 
;	less than or equal to wavel, and those of wave2 greater than or equal 
;	to wavel. Creates a new flux vector by splicing flux1 and flux2 at 
;	the same indices at which wave1 and wave2 were joined.
;  
;*CALLING SEQUENCE:
;
;	COM_SPL,WAVE1,FLUX1,EPS1,WAVE2,FLUX2,EPS2,WAVEL,WAVE3,FLUX3,EPS3
;  
;*PARAMETERS:
;
;	WAVE1	(REQ) (I) (1) (F D)
;		Wavelength vector to be merged.
;
;	WAVE2	(REQ) (I) (1) (F D)
;		Wavelength vector to be merged.
;
;       FLUX1	(REQ) (I) (1) (F D)
;		Flux vector to be merged.
;
;	FLUX2	(REQ) (I) (1) (F D)
;		Flux vector to be merged.
;
;       EPS1	(REQ) (I) (1) (F D)
;		Data quality vector to be merged.
;
;	EPS2	(REQ) (I) (1) (F D)
;		Data quality vector to be merged.
;
;       WAVEL	(REQ) (I) (1) (F D)
;		Wavelength for splicing.
;
;	WAVE3	(REQ) (O) (1) (F D)
;		Merged wavelength vector.
;
;       FLUX3	(REQ) (O) (1) (F D)
;		Merged flux vector.
;
;       EPS3	(REQ) (O) (1) (F D)
;		Merged data quality vector.
;
;*EXAMPLES:
;  
;*SYSTEM VARIABLES USED:
;
;*INTERACTIVE INPUT:
;  
;*SUBROUTINES CALLED:
;
;	PARCHECK
;  
;*FILES USED:
;
;*SIDE EFFECTS:
;  
;*RESTRICTIONS:
;  
;*NOTES:
;
;	tested IDL Version 2.1.0 (sunos sparc)  	19 Jul 91
;	tested IDL Version 2.1.0 (ultrix mispel)	N/A
;	tested IDL Version 2.1.0 (vms vax)      	22 Jul 91
;  
;*PROCEDURE:
;  
;	The procedure first collects the points where wave1 is less than 
;	wavel and wave2 gt wavel. After which, the splicing is done. Finally,
;	the splice index in array replacing splice point is returned.
;
;*I_HELP nn:
;  
;*MODIFICATION HISTORY:
;
;	 3-01-91 PJL unix/sun modifications; added PARCHECK and
;		     call print
;	 7-22-91 PJL cleaned up; tested on SUN and VAX; updated prolog
;	 8- 9-91 PJL corrected PARCHECK call
;
;-
;************************************************************************
 pro com_spl,wave1,flux1,eps1,wave2,flux2,eps2,wavel,wave3,flux3,eps3
;
 npar = n_params(0)
 if npar eq 0 then begin
    print,   $
     'COM_SPL,WAVE1,FLUX1,EPS1,WAVE2,FLUX2,EPS2,WAVEL,WAVE3,FLUX3,EPS3'
    retall
 endif  ; npar
 parcheck,npar,10,'COM_SPL'
;
 s2=n_elements(wave2)
;
; collect the points where wave1 is less than wavel and wave2 gt wavel
;
 nw1=total(wave1 le wavel)
 nw2=total(wave2 gt wavel)
;
; now do the splicing
;
 wave3=fltarr(nw1+nw2)
 flux3=wave3 
 eps3=wave3
 if nw1 gt 0 then begin
    wave3(0) = wave1(0:nw1-1)
    flux3(0) = flux1(0:nw1-1)
    eps3(0) = eps1(0:nw1-1)
 endif  ; nw1
 if nw2 gt 0 then begin
    wave3(nw1) = wave2(s2-nw2:s2-1)
    flux3(nw1) = flux2(s2-nw2:s2-1)
    eps3(nw1) = eps2(s2-nw2:s2-1)
 endif  ; nw2
;
; return splice index in array replacing splice point
;
 wavel=intarr(2)
 wavel([0,1]) = [nw1-1,nw1]
 return
 end  ; com_spl