function sxt_decomp,data,unc_data,silent=silent,uncertainty=uncertainty
;+
;  NAME:
;       sxt_decomp
;  PURPOSE:
;       Decompress an SXT image
;	Optionally return decompression uncertainty
;  CALLING SEQUENCE:
;	u_data = sxt_decomp(data,unc_data)
;	u_data = sxt_decomp(data,unc_data)
;	u_data = sxt_decomp(data,/silent)
;	unc_data = sxt_decomp(data,/uncertainty)   ; return uncertainties only
;  INPUT:
;	data	= Compressed DN (byte-type)
;		  data MUST be byte type.  If not, data is returned
;		  and an informational message is displayed at tty.
;  OPTIONAL INPUT PARAMETER:
;	silent	= If set, don't send a message if data is not byte type
;	uncertainty = If set, return uncertainties.
;  OUTPUT:
;	Returns decompressed data (integer type) 
;	or      uncertainties (byte type) if the /uncertainty switch is set.
;  OPTIONAL OUTPUT:
;	unc_data= Decompression uncertainty
;  HISTORY:
;	28-jan-93, J. Lemen, Added uncertainty code.  
;			     Adapted from J. Mctiernan Spring '92 version
;	22-feb-93, JRL, Force unc_data to be byte type
;	 9-mar-93, JRL, Added the /uncertainty switch
;-

;  Check to see if the data is byte type

ss = size(data)					; Get the size
if ss(ss(0)+1) ne 1 then begin			; NOT byte type
  if not keyword_set(silent) then 	$	; Silent running?
    print,'data must be BYTE type ==> use:  A = sxt_decomp(byte(B)) to override'
  unc_data = 0					; In case this already defined
  return,data					; Return original data
endif

;  Generate Lookup Table

Lkup = intarr(256)              ; Lookup table
Lkup(0:64) = findgen(65)

DN = findgen(191)+65
Lkup(65:255) = fix(.10526*DN^2 - 12.473*DN + 431.14 + 0.5)

;  Return the decompression uncertainty if 2nd parameter is present

Ulkup = byte(Lkup)
Ulkup(0:64) = 1
Ulkup(65:255) = fix(.10526*(2.0*DN - 1.0) - 12.473 + 0.5)

if n_params() gt 1 then $	; Return deccompression uncertainty
  unc_data=Ulkup(data)

; Lkup(data) = decompressed data // Ulkup(data) = Uncertainties
if keyword_set(uncertainty) then return,Ulkup(data) else return,Lkup(data)
end
