imap_processing.idex.decode#
Decompress IDEX raw wavelength data.
Originally written by Corinne Wuerthner. A compressed data frame starts on a byte boundary, and begins with the 8-bit sequence 0xF5 to indicate the start of a frame. A frame contains one or more subframes of compressed data. Subframes are packed as tightly as possible, and are not aligned to any byte or word boundary. The compression parameters are varied for each subframe to optimize the data compression. Within a subframe the same predictor, and the same Rice parameter is used for all the samples in that subframe. The predictor and rice parameter is allowed to vary from subframe to subframe.
- The start of each subframe consists of the following bits:
- 00: Constant value
The predictor assumes that every sample in the frame is equal to the first sample in the frame. In this case, the first sample is stored as the original NBIT binary value and no other samples are included in the frame. The constant value predictor will only be selected for a subframe where every sample is the same value.
- 01: Verbatim
The predictor assumes that the data is not well correlated, and simply stores every sample in the frame using the original NBIT binary representation. This predictor minimizes the impact of data expansion for uncorrelated data samples where the golomb-rice coding would actually make the encoded data significantly larger than the original data set.
- 10: Linear predictor #1
This predictor assumes that each sample will have the same value as the sample immediately before it (sample X(n) = sampleX(n-1)). The predicted value is subtracted from the actual value of the sample and only the error (residual) between the actual value, and the predicted value is stored. This predictor requires a single uncompressed sample as a “warmup sample” to be used in predicting the other samples in the subframe.
- 11: Linear Predictor #2
This predictor assumes that sample X(n) = 2*X(n-1)-X(n-2). This predictor calculates the slope of the signal based on the two previous values (slope = X(n-1)-X(n-2)) and predicts the value of X(n) will follow on a straight line drawn between the two previous points. X(n) = X(n-1) + (X(n-1)-X(n-2)) = 2*X(n-1)-X(n-2).
M bits for the rice parameter k. The bit width of k is equal to ceiling(log2(NBITS)). For 10 bits, the bit width of k is 4 because log2(10) = 3.32 and ceiling(3.32) = 4. The rice parameter k is stored in the bit stream as an unsigned binary value. The rice parameter is omitted from the bit stream if the predictor type is set to “00” or ‘01’. The next NBITS contain the raw binary value of the first sample in the subframe.
Functions
|
Read bits from a binary string and convert to an int. |
|
Decode compressed IDEX wavelength data using linear prediction and Golomb-RICE. |