PRO CHECK_EXP_FACTOR_DUPS,Tel,Date
;
;+
; NAME:
;	CHECK_EXP_FACTOR_DUPS
;
; PURPOSE:
;	This procedure reads the exposure factor file for a given date
;	and then writes it back out, eliminating any duplicate entries.
;
; CATEGORY:
;	EXPFAC
;
; CALLING SEQUENCE:
;	CHECK_EXP_FACTOR_DUPS,Tel,YYMMDD
;
; INPUTS:
;	Tel:		String indicating the telescope, 'c1','c2','c3'
;	Date:		Date for which the exposure factors are wanted
;			can be in either YYMMDD, MJD, or CDS time structure
;
; COMMON BLOCKS:
;	EXP_FACTOR_ARRAY:	The exposure facotor information for a given 
;			date.
;
; PROCEDURE:
;	READ_EXP_FACTOR is called to readin the exposure factor file for
;	the specified date.  Then WRITE_EXP_FACTOR is called to write
;	it back out.  Note that READ_EXP_FACTOR eliminates duplicates.
;
; MODIFICATION HISTORY:
; 	Written by:	RA Howard, NRL, 22 Feb 1998
;
; @(#)check_exp_factor_dups.pro	1.1 02/22/98 :LASCO IDL LIBRARY
;
;-

common exp_factor_array,telescope,filename,fname,factor,bias,mjd, $  
                   time,filter,polar,waveleng,nregion,sigma

;  
;  Read in the exposure factor file for the given date
;  
yymmdd = UTC2YYMMDD(YYMMDD2UTC(date))
result = READ_EXP_FACTOR(tel,yymmdd)
IF (result NE 0)  THEN RETURN
n = N_ELEMENTS(factor)
sd = GETENV('NRL_LIB')+'/lasco/expfac/data/'+STRMID(yymmdd,0,4)+'/'
sd = './'
print,'Opening file ',sd+filename
OPENW,lu,filename,/GET_LUN
GET_UTC,dte
FOR i=0,n-1 DO BEGIN
    tim = time(i)/1000.
    dte.mjd = mjd(i)
    ymd = UTC2YYMMDD(dte)
    PRINTF,lu,fname(i),factor(i),bias(i),ymd,tim,filter(i), $
          polar(i),waveleng(i),nregion(i),sigma(i), $ 
          FORMAT='(a12,f10.6,f10.1,2x,a6,2x,f10.2,2x,a12,a12,a9,i4,e10.2)'
ENDFOR
CLOSE,lu 
FREE_LUN,lu 
RETURN
END  
