; f channel compression algorythm 16 bits to 8 bits ; taken from Functional Requirements GLL-4-2034, Rev A ; written by Scott Lasica, 1/10/95 pro comp_f,data_in,data_out ; since IDL does not have a log base 2 routine, I am forced to use ; the conversion: log base(b) X = ln X / ln b ; so: log base 2 of X is equivalent to ln X / ln 2 (where ln = natural log) X = fix( ( alog(data_in)/alog(2) ) +1 ) ; X in this case is the most significant bits ( 4-7 ) C = fix( (data_in * 2.^(5-X)) -16. ) ; C in this case is the least significant bits ( 0-3 ) ; now I need to reassemble these bits into a number X = X * 16 ; this will change this number to the upper 4 bits ; of an 8 bit byte data_out = byte (X + C) ; this should re-assemble these numbers into ; an 8 bit byte return end