Viewing contents of file '../idllib/iuedac/iuelib/pro/bs_update.pro'
;******************************************************************************
;+
;*NAME:
;
; BS_UPDATE (RDAF Production Library) June 18, l985
;
;*CLASS:
;
; Data Editing
;
;*CATEGORY:
;
; IUESIPS NEWSIPS
;
;*PURPOSE:
;
; For IUESIPS, updates IMAGET output file with corrected data for line
; when called by BSPOT.
;
; For NEWSIPS, writes IMAGET output file with corrected data for line
; when called by BSPOT.
;
;*CALLING SEQUENCE:
;
; BS_UPDATE,IMAGET,FLUX,EPS,LINE,NLS,header,wave,fimage,eimage
;
;*PARAMETERS:
;
; IMAGET (REQ) (I/O) (1) (S)
; Output file name for modified IUESIPS LBLS or NEWSIPS-like
; SILO file.
;
; FLUX (REQ) (I) (1) (R)
; Modified input flux vector obtained from BSPOT to be updated
; in the IUESIPS LBLS imaget file or written in the NEWSIPS-like
; SILO imaget file.
;
; EPS (REQ) (I) (1) (R)
; For IUESIPS, modified input IUESIPS epsilon vector obtained
; from BSPOT to be updated in the IUESIPS LBLS imaget file.
; For NEWSIPS, modified input IUESIPS epsilon vector obtained
; from BSPOT to be written in the NEWSIPS-like SILO imaget file.
;
; LINE (REQ) (I) (0) (I)
; For IUESIPS, line number in IUESIPS LBLS file to be edited.
; For NEWSIPS, line number that was modified.
;
; NLS (REQ) (I) (0) (I)
; Total number of lines in IUESIPS LBLS or NEWSIPS SILO file able
; to be modified. Used as a check on the value of the LINE
; parameter.
;
; HEADER (OPT) (I/O) (1) (S)
; Not for use with IUESIPS data. Required for NEWSIPS data.
; The main fits header.
;
; WAVE (OPT) (I) (1) (R)
; Not for use with IUESIPS data. Required for NEWSIPS data.
; The wavelength vector.
;
; FIMAGE (OPT) (I/O) (2) (R)
; Not for use with IUESIPS data. Required for NEWSIPS data.
; The image array.
;
; EIMAGE (OPT) (I/O) (2) (R)
; Not for use with IUESIPS data. Required for NEWSIPS data.
; The nu flags array.
;
;*EXAMPLES:
;
; See BSPOT.PRO
;
;*SYSTEM VARIABLES USED:
;
; none
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
; PARCHECK
; ADDPAR
; WRITESI
;
;*FILES USED:
;
; IMAGET (I/O)
; Output IUESIPS LBLS or NEWSIPS SILO file.
;
;*SIDE EFFECTS:
;
; See BSPOT.PRO documentation
;
;*NOTES:
;
; See BSPOT.PRO documentation
;
;*PROCEDURE:
;
; For IUESIPS, the IMAGET file is opened and for each line to be updated
; the modified flux and epsilon vectors are inserted.
;
; For NEWSIPS, a new file is written via the procedure WRITESI.
;
;*I_HELP nn:
;
;*MODIFICATION HISTORY:
;
; 29-APR-88 HAA add RDAF Prolog
; jan-10-90 jtb @gsfc modified for unix / sun idl version 1.2
; jul-22-91 pjl @gsfc cleaned up; added npar equals 0 print and
; PARCHECK; tested on SUN and VAX; updated prolog
; 6 Apr 94 PJL added NEWSIPS compatibility (included header and wave
; parameters and procedures ADDPAR and WRITESI)
; 7 Apr 94 PJL added fimage and eimage parameters for NEWSIPS
; 2 Feb 95 RWT remove writesi command (add to end of BSPOT)
;-
;******************************************************************************
pro bs_update,imaget,flux,eps,line,nls,header,wave,fimage,eimage
;
npar = n_params(0)
if (npar eq 0) then begin
print,'BS_UPDATE,IMAGET,FLUX,EPS,LINE,NLS,main_fits_header,wave,' + $
'fimage,eimage'
retall
endif ; npar eq 0
parcheck,npar,[5,9],'BS_UPDATE'
;
; check header
;
if (npar eq 9) then begin
shead = size(header)
if (shead(shead(0)+1) ne 7) then begin
npar = 5
print,'Main fits header should be a string array. Assuming IUESIPS.'
endif ; shead(shead(0)+1) ne 7
endif ; npar eq 9
;
; output changes
;
case (npar) of
5: begin ; IUESIPS
openu,/get_lun,un,imaget
rec = assoc(un,intarr(40))
h = rec(0)
rec = assoc( un,intarr(h(1)) )
f = rec(line*3)
e = rec(line*3-1)
scale = h(20)*2.0^(-h(21)) ; old scaling
flux = flux / scale ; ...scales down fluxes
f(0) = fix(flux) ; replace fluxes
e(0) = fix(eps) ; replace eps
rec(line*3-1) = e
rec(line*3) = f
free_lun,un
end ; npar eq 5
9: begin ; NEWSIPS
;
; add comment to main fits header
;
addpar,header,'HISTORY',' BSPOT modified line ' + $
strtrim(line,2),'','IUEDAC'
;
; incorporate modified flux and nu flag lines back into the arrays
;
fimage(*,line-1) = flux
eimage(*,line-1) = eps
;
; write output file
;
; writesi,header,wave,fimage,eimage,filename=imaget
end ; npar eq 9
else: print,'This should not happen.'
endcase ; npar
;
return
end ; bs_update