;+
;
; NAME: 
;	TGRS_LIVETIME
;
; PURPOSE:
;	This function returns the first-order livetime fraction (0-1) for the 
;	TGRS spectrometer.
;
; CATEGORY:
;	ANALYSIS, INSTRUMENT, TGRS, SPEX
;
; CALLING SEQUENCE:
;	Livefrac = TGRS_LIVETIME( Flux )
;
; CALLS:
;	F_DIV    
;
; INPUTS:
;       Flux - the 8192 TGRS flux in units of Raw-Counts/sec 
;
; OPTIONAL INPUTS:
;       none
;
; OUTPUTS:
;       Returns the livetime fraction from 0-1.
;
; OPTIONAL OUTPUTS:
;       none
;
; KEYWORDS:
;       none
; COMMON BLOCKS:
;       none
;
; SIDE EFFECTS:
;       none
;
; RESTRICTIONS:
;       none
;
; PROCEDURE:
;       Based on the description in the electronics section of the TGRS homepage.
;
; MODIFICATION HISTORY:
;	RAS, 25-July-1996
;-
function tgrs_livetime, flux


dead=findgen(8192)*2.e-8+30e-6
livefrac = 1 -total( flux*rebin(dead,8192,n_elements(flux(0,*))),1)

return, livefrac
end
