Viewing contents of file '../idllib/iuedac/iuelib/pro/dfcorr.pro'
;******************************************************************************
;+
;*NAME:
;
;  	DFCORR  3-21-90
;  
;*CLASS:
;
;	IUE Absolute Calibration Correction
;  
;*CATEGORY:
;
;	IUESIPS
;
;*PURPOSE:
;
;       To apply David Finley's absolute calibration correction to IUE data
;	sets.
;
;*CALLING SEQUENCE:
;
;       DFCORR,W,F,FCORR
;
;*PARAMETERS:
;
;	W     (REQ) (I) (1) (I)
;             Wavelength vector (in angstroms).
;
;	F     (REQ) (I) (1) (I)
;             Vector of absolutely calibrated fluxes (ergs/cm*cm/sec/A).
;
;	FCORR (REQ) (O) (0) (I)
;             Vector of corrected absolutely calibrated fluxes.
;
;*SYSTEM VARIABLES USED:
;
;	!iuer.dat
;  
;*INTERACTIVE INPUT:
;
;	none
;  
;*SUBROUTINES CALLED:
;
;    	PARCHECK
;       IFITSRD
;       TABINV
;  
;*FILES USED:
;    
;       !iuer.dat DFCOEFF.FIT
;		File containing correction factors as a function of wavelength
;		in a fits file format (see IUER_INF DFCOEFF.INF for more
;		information).
;  
;*SIDE EFFECTS:
;  
;*RESTRICTIONS:
;
;	For use with IUESIPS data ONLY.
;  
;*NOTES:
;
;	The long wavelength corrections are based on the LWR camera.
;
;	LWP data should not be corrected with this procedure.
;
;*PROCEDURE:
;
;	DFCOEFF.FIT is read to obtain vectors of wavelength, correction
;	factors, number of good points used to calculate each correction
;	factor, and the standard deviation of the mean.  The correction is
;	applied using the nearest neighbor value from the correction vector.
;	The correction is applied as FCORR = F / CORR.
;  
;*I_HELP nn:
;  
;*EXAMPLES:
;
;	dfcorr,w,f,fcorr
;  
;*MODIFICATION HISTORY:
;
;      	Written by Jennifer Sokolowski & RWT 4-26-89
;       3/30/90 RWT update prolog, rename DFCORR, and convert CORFILE.TXT
;               to DFCOEFF.SAV for easier access.
;	1/18/91 PJL transferred to sun/unix and added PARCHECK
;       4/11/91 GRA added branch for filename processing in vms
;	7/22/91 PJL cleaned up; changed logical; tested on SUN and VAX; 
;		    updated prolog
;	27 Aug 93  PJL  replaced IUEFETCH with IFITSRD; converted dfcoeff.sav
;			to dfcoeff.fit
;      2 Sep 94 LLT replace IUER_DAT with !iuer.dat
;-
;******************************************************************************
 pro dfcorr,w,f,fcorr
;
 npar = n_params(0)
 if (npar eq 0) then begin
    print,'DFCORR,W,F,FCORR'
    retall
 endif  ; npar eq 0
 parcheck,npar,3,'DFCORR'
;
;  set output flux = input flux (default)
;
 fcorr = f
;
; extract correction factors and wavelengths from sav file
;
 ifitsrd,!iuer.dat+'dfcoeff.fit',1,main,extd,corrw,corr,n,si,/silent
;
; correct fluxes using nearest neighbor correction terms
;
 tabinv,corrw,w,index
 index = fix(index+0.5) 
 fcorr = f/corr(index)
;
 return  
 end  ; dfcorr