Viewing contents of file '../idllib/iuedac/iuelib/pro/crstrim.pro'
;*******************************************************************************
;+
;*NAME:
;
;      CRSTRIM (IUE Production Library) (01 April 1988)
;
;*CLASS:
;
;      cross-correlation, spectral extraction, resampling
;
;*CATEGORY:
;
;*PURPOSE:
;
;   To extract the spectral data within the user-specified wavelength
;   range, and to interpolate the spectral data to a common log(lambda)
;   scale. 
;
;*CALLING SEQUENCE:
;
;   CRSTRIM,BEGLAM,ENDLAM,FILEN,W,F,N,RWLOG,FF,M,JUMP
;
;*PARAMETERS:
;
;   BEGLAM  (REQ) (I)  (0)   (F)
;           Beginning wavelength for the extraction, given in the same
;           units as the spectral data.
;
;   ENDLAM  (REQ) (I)  (0)   (F)
;           Ending wavelength for the extraction, given in the same
;           units as the spectral data.
;
;   FILEN   (REQ) (I)  (0)   (S)
;           Required input string variable giving the name of the .SAV
;           formatted file to be extracted and resampled.
;
;   W       (REQ) (I)  (1)   (F)
;           Required input vector giving the wavelength data for the 
;           spectrum of interest.
;
;   F       (REQ) (I)  (1)   (F)
;           Required input vector giving the flux data for the spectrum of
;           interest.
;
;   N       (REQ) (I)  (0)   (I)
;           Required input parameter giving the number of data points
;           in the spectrum.
;
;   RWLOG   (REQ) (I)  (1)   (F)
;           Required input vector giving the log(lambda) grid for the
;           spectral data to be resampled onto.
;
;   FF      (REQ) (O)  (1)   (F)
;           Required output vector containing the resampled flux data
;
;   M       (REQ) (O)  (0)   (I)
;           Required output scalar giving the number of points in the
;           extracted and resampled spectrum.
;
;   JUMP    (REQ) (O)  (0)   (I)
;           Required output error flag. If JUMP=0, the data are O.K..
;           If JUMP=1 then the spectral data do not include the 
;           wavelength range specified by the user for the cross-correlation.
;
;*EXAMPLES:
;
;  To trim and resample a spectrum from wave1 to wave2 onto a log(lambda)
;  grid given by RWLOG,
;
;  CRSTRIM,wave1,wave2,'SWP33315FE3',wave,flux,N_elements(wave),RWLOG,ff,m1,JUMP
;
;*SYSTEM VARIABLES USED:
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
;      TABINV
;      QUADTERP
;      PARCHECK
;
;*FILES USED:
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
;     Used by procedure CRSCOR
;
;	tested with IDL Version 2.1.0 (sunos sparc)  	25 Jun 91
;	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
;	tested with IDL Version 2.1.0 (vms vax)      	25 Jun 91
;
;*PROCEDURE:
;
;     see documentation for CRSCOR
;
;*MODIFICATION HISTORY:
;
;     for earlier modification history, see CRSCOR
;     05  May 1988  CAG   GSFC   add VAX RDAF-style prolog, PARCHECK
;     25  Jun 1991  PJL   GSFC   cleaned up; lowercase; added parameters
;				 eq 0 print; tested on SUN and VAX; 
;				 updated prolog
;
;-
;*******************************************************************************
 pro crstrim,beglam,endlam,filen,w,f,n,rwlog,ff,m,jump
;
 npar = n_params(0)
 if npar eq 0 then begin
    print,' CRSTRIM,BEGLAM,ENDLAM,FILEN,W,F,N,RWLOG,FF,M,JUMP'
    retall
 endif  ; npar
 parcheck,npar,10,'CRSTRIM'
;
; check wavelengths and interpolate to log-lambda scale
;
 if (w(0) gt beglam) or (w(n-1) lt endlam) then begin
    print,' Wavelengths not inclusive,',w(0),' to ',w(n-1),' from ',filen
    jump=1
 endif else begin
    tabinv,w,beglam,j
    tabinv,w,endlam,k
    j=fix(j)-1>0
    m=fix(k+1)<(n-1)
    f = f(j:m)
    wlog=alog10(w(j:m))
    quadterp,wlog-alog10(beglam),f,rwlog,ff
 endelse  ; w
 return
 end  ; crstrim