;	(26-may-93)
function sxt_dn2ph,DN,wave=wave,energy=energy,gain=gain
;+
;  Name:
;    sxt_dn2ph
;
;  Purpose:
;    Convert SXT DN into photon COUNTS.
;
;  Calling Sequence:
;    Photon = sxt_dn2ph(DN)
;    Photon = sxt_dn2ph(DN,Energy=energy)
;    Photon = sxt_dn2ph(DN,Energy=energy,gain=gain)
;    Photon = sxt_dn2ph(DN,Wave=Wave,gain=gain)
;
;  Inputs:
;    DN	= scalar or array of compressed (byte-type) DN values
;			or uncompressed (non-byte)  DN values
;
;  Optional Input Keywords:
;    Gain	= Sxt Gain constant (electrons/DN)
;		  If not supplied, defaults to 100.
;    Energy	= Photon energy (keV).  If not supplied, defaults to 1.5 keV.
;    Wave	= Photon wavelength (Ang).  If not supplied, uses the 
;		  Energy default.  Ignored if Energy keyword is supplied.
;
;  Returns:
;    Photon counts.
;
;  Method:
;	Assumes that 3.65 eV produces 1 electron-hole pair
;
;	The equation is:
;	# Photons = ( Wavelength (Ang) / 1.98648e-8 erg )
;		    * 1.602192e-12 erg/eV * 3.65 eV/e * Gain (e/DN) * DN
;
;  Modification History:
;   26-May-93, JRL, LPARL.
;-

if n_elements(DN)   eq 0 then DN = 1.
if n_elements(gain) eq 0 then begin
   gg = 100. & print,'Assume Gain = ',gg,' e/DN'
endif else gg = gain

if n_elements(energy) eq 0 then begin
    ee = 1.5		; Energy in keV
    if n_elements(wave) ne 0 then ee = 12.399 / wave
endif else ee = Energy
ww = 12.399 / ee
if (n_elements(energy) eq 0) and (n_elements(wave) eq 0) then $
	print,'Assume Wave = ',ww,' Ang'

return,(ww / 1.98648e-8 ) * 1.602192e-12 * 3.65 * gg * sxt_decomp(DN,/silent)
end
