Viewing contents of file '../idllib/iuedac/iuelib/pro/bcomp.pro'
;**************************************************************************
;+
;*NAME:
;
; BCOMP (RDAF General Production Library) 5 September, 1986
;
;*CLASS:
;
; Resampling
;
;*PURPOSE:
;
; To resample high dispersion IUE data onto a uniformly spaced
; wavelength grid. Data is averaged in each wavelength bin.
;
;*CALLING SEQUENCE:
;
; BCOMP,FILENAME
;
;*PARAMETERS:
;
; FILENAME (REQ) (I)
; The name of the data file containing the compression
; parameters (output from PRECOMP) to be used as input to
; BCOMP. If blank or null the default name 'comp.dat' is
; used. In batch mode on the VAX, this must be 'comp.dat'.
;
;*EXAMPLES
;
; To run BCOMP using comp.dat as the input file:
; bcomp,'0'
; bcomp,''
; bcomp,' '
; bcomp,'comp.dat'
;
; processes all files (max 10) whose information is
; described in the file COMP.DAT
;
; To run BCOMP using mycomp.dat as the input file:
; bcomp,'mycomp.dat'
;
; To run BCOMP in the background (UNIX) outside of IDL on a file named
; 'myfile.dat':
; if IUER_EXE defined (from earlier IDL session),
; $IUER_EXE/compress.bat 'myfile.dat'
; if IUER_EXE is not defined,
; /home/iuerdaf/iuelib/exe/compress.bat 'myfile.dat'
; To run BCOMP as a batch job (VMS) [filename must be 'comp.dat']:
; submit/noprint IUER_EXE:compress.bat
;
; processes all files (max 10) whose information is
; described in the file MYCOMP.DAT
;
; To create the input file run PRECOMP.
;
;*SYSTEMS VARIABLES USED:
;
; !NOPRINT - set to 1 temporarily, to suppress printout in BINS
; !err_string
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
; PARCHECK
; IUESAVE
; TEMPCOR
; COMBALL
;
;*FILES USED:
;
; filename (defaults to comp.dat) (I)
; File produced from PRECOMP.PRO which can contain information
; for up to ten files maximum to be resampled. In batch mode on
; the VAX, this must be 'comp.dat'.
;
; 'imagetcm.sav' (O)
; Disk files of compressed spectra and splice points in SAV
; format, where filename is the original image name without the
; H at the end. The standard epislon vector is replaced by
; the weight (WGT) vector obtained from the RDAF procedure BINS.
;
; 'imagetsp.sav' (O)
; The .SAV file of splice points.
;
;*SIDE EFFECTS:
;
; !NOPRINT could be reset
;
;*RESTRICTIONS:
;
; In batch mode on the VAX, the filename must be COMP.DAT.
;
;*NOTES:
;
; 1) BCOMP uses the disk file COMP.DAT (or name chosen by user),
; created by PRECOMP, for all processing information (see
; PRECOMP.PRO's documentation for more information). In batch
; mode on the VAX, the disk file must be named COMP.DAT.
; 2) On SUN, execution time can take at least 2 minutes per image.
; On VAX, execution time can be 7 to 8 minutes per image.
; 3) To run BCOMP in the background (UNIX) outside of IDL:
; if IUER_EXE defined (from earlier IDL session),
; $IUER_EXE/compress.bat filename
; if IUER_EXE is not defined,
; /home/iuerdaf/iuelib/exe/compress.bat filename
; To run BCOMP as a batch job (VMS):
; submit/noprint IUER_EXE:compress.bat
;
; tested with IDL Version 2.2.0 (sunos sparc) 22 Nov 91
; tested with IDL Version 2.2.0 (ultrix mipsel) 22 Nov 91
; tested with IDL Version 2.2.0 (vms vax) 22 Nov 91
;
;*PROCEDURE:
;
; PRECOMP.PRO must be run first to produce the disk file COMP.DAT (or
; filename chosen by user, although the file name must be COMP.DAT if
; BCOMP is to be run in batch mode on the VAX) which BCOMP reads in
; order to determine image files, wavelength interval to extract, and
; bin sizes. Orders are merged into one array, ripple corrected,
; absolutely calibrated (if exposure time > 0), and resampled. Final
; array is corrected for THDA sensitivity variations if requested.
; Final arrays are saved as disk files using IUESAVE. In the
; 'imagetcm.sav' file, the E vector contains data quality information -
; the weight (WGT) vector obtained from the RDAF procedure BINS. A
; separate SAV file, 'imagetsp.sav', is created of the splice points used.
;
;*MODIFICATION HISTORY:
;
; Written by R.J. Panek (SCRUNCH), G. Sonneborn (SCRUNCH3)
; & C. Grady (COMPRESS)
; 11-21-85 RWT modified for batch processing
; 12-17-85 RWT correct for monotonicity error and modify ripple
; parameters to agree with QIUEHI3
; 8-24-86 RWT use ABCAL for CALIB, use version numbers in file name,
; add TEMPCOR subroutine, and use new IUESAVE
; 12-18-86 RWT VAX mods added: N_ELEMENTS, OF changed to OFL, add
; IUER_USERDATA: to disk files, use array subscripts,
; input VNUM, & fix !MODE add PARCHECK, and remove INSERT
; & EXTRACT commands
; 5-4-87 RWT change WBINS reference to BINS
; 6-9-87 RWT remove REBIN subroutine (name conflict)
; 7-24-87 RWT use !NOPRINT for !MODE and add GET_LUN for unit numbers
; 8-12-87 RWT use new file naming convention
; 1-15-88 RWT add fix for image numbers > 32767 and for new LWP ITF
; 2-19-88 RWT separate subroutines into individual modules & rename
; 3-08-88 HAA add RDAF Prolog.
; 3-01-91 PJL unix/sun modifications; parameters changed from
; version number to filename
; 4-08-91 PJL directed input from user's home directory
; 4-11-91 GRA added branch for fname processing in vms
; 7-22-91 PJL cleaned up; changed logical; tested on SUN and VAX;
; updated prolog
; 8-19-91 PJL modified to accept file names with sm and lg in them
; and made the input file ascii; tested on SUN and VAX;
; updated prolog
; 10-23-91 PJL added to prolog
; 10-28-91 PJL added to prolog
; 22 Nov 91 GRA removed IUER_USERDATA logical; tested.
; 16 Dec 91 PJL corrected number of files equal 10 case
; 17 Dec 91 PJL changed number of points limit from 4000 to 10000;
; LWR and LWP no longer have to be split into two
; two files
; 7 Jan 92 PJL added to documentation
;
;-
;**********************************************************************
pro bcomp,fname
;
npar = n_params(0)
if npar eq 0 then begin
print,' BCOMP,FILENAME(quoted)'
retall
endif ; npar
parcheck,npar,1,'BCOMP'
;
s = size(fname)
if s(1) ne 7 then begin
print,'Filename must be quoted (null string for default)'
retall
endif ; s(1)
if fname eq '' or fname eq ' ' or fname eq '0' then fname = 'comp.dat'
n = 0
mode = !noprint
!noprint = 1 ; suppress auto prints for bins
;
; read disk file of parameters
;
openr,un,fname,ERROR=err,/get_lun
if err ne 0 then begin
printf,-2,!err_string
retall
endif ; err
line = strarr(1)
readf,un,line
n = fix(strmid(line(0),36,3))
im = strarr(n)
cam = intarr(n) & vn = cam
wa1=fltarr(n) & wa2=wa1 & del=wa1
for i = 0,n-1 do begin
readf,un,line
cam(i) = fix(strmid(line,37,1))
readf,un,line
im(i) = strtrim(strmid(line,37,12),1)
readf,un,line
vn(i) = fix(strmid(line,37,3))
readf,un,line
del(i) = float(strmid(line,37,8))
readf,un,line
wa1(i) = float(strmid(line,31,7))
readf,un,line
wa2(i) = float(strmid(line,31,7))
endfor ; i
free_lun,un
;
; list parameters read from compress.dat
;
print,' '
print,'Images to be compressed'
print,"$(1x,2x,a,t17,a,t25,a,t33,a)",'image','delw','wmin','wmax'
print,' '
for i=0,n-1 do begin
cm = strmid('lwplwrswpswr',3*cam(i)-3,3)
print,"$(1x,a,1x,i5,t17,f5.2,t25,f6.1,t33,f6.1)" $
,cm,im(i),del(i),wa1(i),wa2(i)
endfor ; i
;
; begin the compression (loop through selected images)
;
for i=0,n-1 do begin
if cam(i) eq 1 then cmn='lwp'
if cam(i) eq 2 then cmn='lwr'
if cam(i) eq 3 then cmn='swp'
if cam(i) ge 4 then cmn='swr'
if vn(i) gt 0 then a =';'+strtrim(string(vn(i)),1) else a = ''
imt= cmn + im(i) + '.dat' + a
print,' '
print,'Beginning compression for image ',imt
h=0 & w=0 & f=0 & e=0 & splice=0 ; initialize values
;
; Control the compressing in comball. Do no more than 10000 points
; to avoid requiring vectors longer than IDL can handle
; apply thda sensitivity correction if requested
;
comball,imt,wa1(i),wa2(i),del(i),h,w,fab,e,splice
if (h(68) lt 0) then tempcor,h,fab,f else f=fab
;
; image name is stored in header and is picked up by iuesave
; with the appending of the suffix cm
;
print,'Compression of interval has been completed'
iuesave,'cm',h,w,f,e
s = size(splice)
ss = s(1)
s1=fltarr(ss)
s2=s1
s1 = splice(0:ss-1,0)
s2 = splice(0:ss-1,1)
;
; save the intermediate results
;
iuesave,'sp',h,s1,s2,s1
endfor ; image loop
;
; no merging done on spectrum since can do up to 10000 points in one section
;
!noprint = mode ; reset !noprint
return
end ; bcomp