	PRO SUMWIN_UNPACK,INPUT,OUTPUT
;+
; Project     : SOHO - CDS
;
; Name        : 
;	SUMWIN_UNPACK
; Purpose     : 
;	Unpack 64-bit summed window data from 8 bit telemetry words.
; Explanation : 
;	Used to unpack values from the telemetry stream according to the SUMWIN
;	compression scheme used aboard the CDS instrument.  The values of
;	OUTPUT are taken from each sequential set of 64 bits in the INPUT
;	array, and are then converted into double precision numbers.
; Use         : 
;	SUMWIN_UNPACK, INPUT, OUTPUT
; Inputs      : 
;	INPUT	= Input array of telemetry values.  Must be of either byte or
;		  short integer type.
; Opt. Inputs : 
;	None.
; Outputs     : 
;	OUTPUT	= Output array of unpacked values.  For every eight bytes in
;		  the INPUT array, there will be one element in the output
;		  array.
; Opt. Outputs: 
;	None.
; Keywords    : 
;	None.
; Calls       : 
;	IEEE_TO_HOST
; Common      : 
;	None.
; Restrictions: 
;	None, except those described above for the INPUT array.
; Side effects: 
;	The conversion from a 64 bit integer to a double precision floating
;	point number results in a small loss in precision when the number is
;	large.
; Category    : 
;	Data Handling, Telemetry
; Prev. Hist. : 
;	None.
; Written     : 
;	William Thompson, GSFC, 19 August 1994
; Modified    : 
;	Version 1, William Thompson, GSFC, 19 August 1994
;	Version 2, William Thompson, GSFC, 13 March 1996
;		Corrected byte ordering
; Version     : 
;	Version 2, 13 March 1996
;-
;
	ON_ERROR,2
;
;  Check the number of parameters.
;
	IF N_PARAMS() NE 2 THEN MESSAGE,	$
		'Syntax:  SUMWIN_UNPACK, INPUT, OUTPUT'
;
;  Check the input array.
;
	TYPE = DATATYPE(INPUT,1)
	IF (TYPE NE 'Byte') AND (TYPE NE 'Integer') THEN MESSAGE,	$
		'INPUT must be either a byte or short integer array'
;
;  Extract the largest number of eight-byte groups that one can.
;
	IF TYPE EQ 'Integer' THEN BEGIN
		N_OUT = N_ELEMENTS(INPUT)/4
		TEMP = BYTE(INPUT,0,8,N_OUT)
	END ELSE BEGIN
		N_OUT = N_ELEMENTS(INPUT)/8
		TEMP = BYTARR(8,N_OUT)
		TEMP(0) = INPUT(0:8*N_OUT-1)
	ENDELSE
;
;  Reformat the output into a double precision number.
;
	C = 256.D0
	OUTPUT = TEMP(6,*)*C^7 + TEMP(7,*)*C^6 + TEMP(4,*)*C^5 +	$
		 TEMP(5,*)*C^4 + TEMP(2,*)*C^3 + TEMP(3,*)*C^2 +	$
		 TEMP(0,*)*C   + TEMP(1,*)
;
	RETURN
	END
