function img2dnpersec,img0,header
;
;+
; NAME:
;	IMG2DNPERSEC
;
; PURPOSE:
;	Convert an image in raw counts (DN) to DN/sec
;
; CATEGORY:
;	DATA_ANAL
;
; CALLING SEQUENCE:
;	Result = IMG2DNPERSEC(Img,Header)
;
; INPUTS:
;	Img = Input Image array.
;	Header = Image header
;
; OUTPUTS:
;	The function returns an image converted to DN/second.  The type will be 
;	double precision.
;
; PROCEDURE:
;	The corrected exposure time is determined. Bias is subtracted. 
;	If image is binned, the correct factor is applied. Then divide by exposre time.
;		output = (binning correction(input - bias))/exposure
;	Note that EXP_CORR will return the old exposure time and the current offset 
;	bias, if the correction factor is not found.
;
;	Calls:
;		EXP_CORR
;		REDUCE_STD_SIZE
;
; MODIFICATION HISTORY:
;	Written, RA Howard, NRL, 25 November 1997
;	Modified:
;		20 Feb 98	RAH	Added exposure factor correction
;	21 Nov 01, NBR - Add binning correction with REDUCE_STD_SIZE
;
;       @(#)img2dnpersec.pro	1.3 11/30/01     LASCO IDL LIBRARY
;
;-
;
IF (DATATYPE(header) EQ 'STC') THEN hdr=header $
                               ELSE hdr = LASCO_FITSHDR2STRUCT(header)
;
;  Get the corrected exposure time and bias
;
h = hdr
EXP_CORR,h
fac = 1./h.exptime
IF h.naxis1 GT 512 THEN fullsize=1 ELSE fullsize=0
img = REDUCE_STD_SIZE(img0,h,/bias,full=fullsize)
RETURN,fac*img
;RETURN,fac*(img-h.offset)
END
