function exp_norm, data, index, back, original=original
;+
;NAME:
;        exp_norm
;PURPOSE:
;	Create time-series images with exposure duration taken into
;	account.  A decompression is performed if the data is byte
;	type.  Output is uncompressed DN/sec.  
;CATEGORY:
;        Yohkoh/SXT analysis 
;CALLING SEQUENCE:
;	img = exp_norm(data, index)
;	img = exp_norm(data, index, background)
;INPUT:
;	data	- data cube (from RD_SDA)
;	index	- index structure
;OPTIONAL INPUT:
;	back	- estimate of background (compressed pixel value)
;		  If not specified, then the offset is gotten from the
;		  routine "get_res_offset"
;OPTIONAL KEYWORD INPUT:
;	original - If set, use the original resolution when normalizing
;		  to DN/Sec/FR pixel
;OUTPUT:
;	returns	- normalized data (floating point data type) in 
;		  DN/sec/full_res_pixels
;MODIFICATION HISTORY:
;        HSH, Nov 1991
;	15-Nov-91 (MDM) - Changed name from "time_series" to "exp_norm"
;			  and "beefed" it up some.
;	 8-Jul-92 (MDM) - Modified to normalize to full resolution pixels
;			  Also, earlier version was normalized and then had
;			  the zero offset added back onto the image.  The
;			  array returned now has the zero signal level at
;			  value = 0.
;	19-Apr-93 (MDM) - Modified the documentation header
;	20-apr-93 (JRL) - Fixed for the case of one image with back=0
;	 7-May-93 (MDM) - Adjusted 20-Apr-93 modification
;	23-Jun-93 (MDM) - Added a call to HIS_INDEX
;	11-Jul-93 (MDM) - Added ORIGINAL switch
;-
;
expdur = gt_expdur(index)/1000.
npix = (2^gt_res(index, original=original))^2
siz = size(data)
nx = siz(1)
ny = siz(2)
n = 1 	;might be a 2-d array
if (siz(0) eq 3) then n = siz(3)
typ = siz( siz(0) + 1)
;
if (n_elements(back) eq 0) then back0 = get_res_offset(index) else begin
    ;back0 = back(0)				; JRL fix (20-apr-93) 
    back0 = back				; MDM fix (7-May-93)
    nn = n_elements(back)
    if (nn ne n) then back0 = fltarr(n) + back(0)
end
;
if (typ eq 1) then out = float(sxt_decomp(data)) else out = float(data)
;for i=0, n-1 do out(0, 0, i) = float(out(*,*,i) - back0(i)) / expdur(i) + back0(i)
 for i=0, n-1 do out(0, 0, i) = float(out(*,*,i) - back0(i)) / expdur(i) / npix(i)
;
his_index, index, -1, 'expdur', 1000.	;normalized to 1 sec = 1000 msec
;
return, out
end
