private float [ ] getData0 ( RandomAccessFile raf , Grib2Drs . Type0 gdrs ) throws IOException { int nb = gdrs . numberOfBits ; int D = gdrs . decimalScaleFactor ; float DD = ( float ) java . lang . Math . pow ( ( double ) 10 , ( double ) D ) ; float R = gdrs . referenceValue ; int E = gdrs . binaryScaleFactor ; float EE = ( float ) java . lang . Math . pow ( 2.0 , ( double ) E ) ; // LOOK: can # datapoints differ from bitmap and data ? // dataPoints are number of points encoded, it could be less than the // totalNPoints in the grid record if bitMap is used, otherwise equal float [ ] data = new float [ totalNPoints ] ; // Y * 10**D = R + (X1 + X2) * 2**E // E = binary scale factor // D = decimal scale factor // R = reference value // X1 = 0 // X2 = scaled encoded value // data[ i ] = (R + ( X1 + X2) * EE)/DD ; BitReader reader = new BitReader ( raf , startPos + 5 ) ; if ( bitmap == null ) { for ( int i = 0 ; i < totalNPoints ; i ++ ) { //data[ i ] = (R + ( X1 + X2) * EE)/DD ; data [ i ] = ( R + reader . bits2UInt ( nb ) * EE ) / DD ; } } else { for ( int i = 0 ; i < totalNPoints ; i ++ ) { if ( GribNumbers . testBitIsSet ( bitmap [ i / 8 ] , i % 8 ) ) { data [ i ] = ( R + reader . bits2UInt ( nb ) * EE ) / DD ; } else { data [ i ] = staticMissingValue ; //data[i] = R / DD; } } } return data ; }
Grid point data - simple packing