visad/src/main/java/ucar/nc2/iosp/grid/GridServiceProvider.java
private void readXY(Variable v2, int ensIdx, int timeIdx, int levIdx, Range yRange, Range xRange, IndexIterator ii)
          throws IOException, InvalidRangeException {

    GridVariable pv = (GridVariable) v2.getSPobject();
    GridHorizCoordSys hsys = pv.getHorizCoordSys();
    int nx = hsys.getNx();
    GridRecord record = pv.findRecord(ensIdx, timeIdx, levIdx);

    if (record == null) {
      Attribute att = v2.findAttribute("missing_value");
      float missing_value = (att == null) ? -9999.0f : att.getNumericValue().floatValue();

      int xyCount = yRange.length() * xRange.length();
      for (int j = 0; j < xyCount; j++) {
        ii.setFloatNext(missing_value);
      }
      return;
    }

    // otherwise read it
    float[] data = _readData(record);
    if (data == null) {
      _readData(record); // debug
      return;
    }

    // LOOK can improve with System.copy ??
    for (int y : yRange) {
      for (int x : xRange) {
        int index = y * nx + x;
        ii.setFloatNext(data[index]);
      }
    }
  }
private void readXY(Variable v2, int ensIdx, int timeIdx, int levIdx, Range yRange, Range xRange, IndexIterator ii)
          throws IOException, InvalidRangeException {

    GridVariable pv = (GridVariable) v2.getSPobject();
    GridHorizCoordSys hsys = pv.getHorizCoordSys();
    int nx = hsys.getNx();
    GridRecord record = pv.findRecord(ensIdx, timeIdx, levIdx);

    if (record == null) {
      Attribute att = v2.findAttribute("missing_value");
      float missing_value = (att == null) ? -9999.0f : att.getNumericValue().floatValue();

      int xyCount = yRange.length() * xRange.length();
      for (int j = 0; j < xyCount; j++) {
        ii.setFloatNext(missing_value);
      }
      return;
    }

    // otherwise read it
    float[] data = _readData(record);
    if (data == null) {
      _readData(record); // debug
      return;
    }

    // LOOK can improve with System.copy ??
    for (int y : yRange) {
      for (int x : xRange) {
        int index = y * nx + x;
        ii.setFloatNext(data[index]);
      }
    }
  }
read one YX array

@param v2      variable to put the data into
@param ensIdx  ensemble index
@param timeIdx time index
@param levIdx  level index
@param yRange  x range
@param xRange  y range
@param ii      index iterator
@throws IOException           problem reading the file
@throws InvalidRangeException invalid range