/** * Read the grid * * @param gr the grid record * @return the data */ public float[] readGrid(McIDASGridRecord gr) { float[] data = null; try { int te = (gr.getOffsetToHeader() + 64) * 4; int rows = gr.getRows(); int cols = gr.getColumns(); rf.seek(te); float scale = (float) gr.getParamScale(); data = new float[rows * cols]; rf.order(needToSwap ? rf.LITTLE_ENDIAN : rf.BIG_ENDIAN); int n = 0; // store such that 0,0 is in lower left corner... for (int nc = 0; nc < cols; nc++) { for (int nr = 0; nr < rows; nr++) { int temp = rf.readInt(); // check for missing value data[(rows - nr - 1) * cols + nc] = (temp == McIDASUtil.MCMISSING) ? Float.NaN : ((float) temp) / scale; } } rf.order(rf.BIG_ENDIAN); } catch (Exception esc) { System.out.println(esc); } return data; }