visad/src/main/java/ucar/nc2/iosp/vis5d/Vis5DIosp.java
public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
    // long startTime = System.currentTimeMillis();
    Integer varIdx = varTable.get(v2);
    if (varIdx == null) {
      throw new IOException("unable to find variable index");
    }

    int count = 0;
    int[] shape = v2.getShape();
    boolean haveZ = shape.length == 4;
    int nt = shape[count++];
    int nz = haveZ
            ? shape[count++]
            : 1;
    int ny = shape[count++];
    int nx = shape[count];
    count = 0;

    Range timeRange = section.getRange(count++);
    Range zRange = haveZ
            ? section.getRange(count++)
            : null;
    Range yRange = section.getRange(count++);
    Range xRange = section.getRange(count);
    int grid_size = nx * ny * nz;

    Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
    IndexIterator ii = dataArray.getIndexIterator();

    // loop over time
    for (int timeIdx : timeRange) {

      float[] data = new float[grid_size];
      float[] ranges = new float[2];
      try {
        v5dstruct.v5d_read(timeIdx, varIdx, ranges, data);
      } catch (BadFormException bfe) {
        throw new IOException("Vis5DIosp.readData: "
                + bfe.getMessage());
      }

      if ((ranges[0] >= 0.99E30) && (ranges[1] <= -0.99E30)) {
        //range_sets[j] = new Linear1DSet(0.0, 1.0, 255);
      } else if (ranges[0] > ranges[1]) {
        throw new IOException("Vis5DIosp.readData: bad read "
                + v2.getFullName());
      }

      // invert the rows
      float[] tmp_data = new float[grid_size];

      if (zRange == null) {
        int cnt = 0;
        for (int mm = 0; mm < ny; mm++) {
          int start = (mm + 1) * nx - 1;
          for (int nn = 0; nn < nx; nn++) {
            tmp_data[cnt++] = data[start--];
          }
        }
      } else {
        int cnt = 0;
        for (int ll = 0; ll < nz; ll++) {
          for (int mm = 0; mm < ny; mm++) {
            int start = ((mm + 1) * nx - 1) + nx * ny * ll;
            for (int nn = 0; nn < nx; nn++) {
              tmp_data[cnt++] = data[start--];
            }
          }
        }
      }
      data = tmp_data;

      // copy the data into the array
      for (float aData : data) {
        ii.setFloatNext(aData);
      }
    }

    // long end = System.currentTimeMillis() - startTime;
    return dataArray;
  }
public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
    // long startTime = System.currentTimeMillis();
    Integer varIdx = varTable.get(v2);
    if (varIdx == null) {
      throw new IOException("unable to find variable index");
    }

    int count = 0;
    int[] shape = v2.getShape();
    boolean haveZ = shape.length == 4;
    int nt = shape[count++];
    int nz = haveZ
            ? shape[count++]
            : 1;
    int ny = shape[count++];
    int nx = shape[count];
    count = 0;

    Range timeRange = section.getRange(count++);
    Range zRange = haveZ
            ? section.getRange(count++)
            : null;
    Range yRange = section.getRange(count++);
    Range xRange = section.getRange(count);
    int grid_size = nx * ny * nz;

    Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
    IndexIterator ii = dataArray.getIndexIterator();

    // loop over time
    for (int timeIdx : timeRange) {

      float[] data = new float[grid_size];
      float[] ranges = new float[2];
      try {
        v5dstruct.v5d_read(timeIdx, varIdx, ranges, data);
      } catch (BadFormException bfe) {
        throw new IOException("Vis5DIosp.readData: "
                + bfe.getMessage());
      }

      if ((ranges[0] >= 0.99E30) && (ranges[1] <= -0.99E30)) {
        //range_sets[j] = new Linear1DSet(0.0, 1.0, 255);
      } else if (ranges[0] > ranges[1]) {
        throw new IOException("Vis5DIosp.readData: bad read "
                + v2.getFullName());
      }

      // invert the rows
      float[] tmp_data = new float[grid_size];

      if (zRange == null) {
        int cnt = 0;
        for (int mm = 0; mm < ny; mm++) {
          int start = (mm + 1) * nx - 1;
          for (int nn = 0; nn < nx; nn++) {
            tmp_data[cnt++] = data[start--];
          }
        }
      } else {
        int cnt = 0;
        for (int ll = 0; ll < nz; ll++) {
          for (int mm = 0; mm < ny; mm++) {
            int start = ((mm + 1) * nx - 1) + nx * ny * ll;
            for (int nn = 0; nn < nx; nn++) {
              tmp_data[cnt++] = data[start--];
            }
          }
        }
      }
      data = tmp_data;

      // copy the data into the array
      for (float aData : data) {
        ii.setFloatNext(aData);
      }
    }

    // long end = System.currentTimeMillis() - startTime;
    return dataArray;
  }
public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { // long startTime = System.currentTimeMillis(); Integer varIdx = varTable . get ( v2 ) ; if ( varIdx == null ) { throw new IOException ( "unable to find variable index" ) ; } int count = 0 ; int [ ] shape = v2 . getShape ( ) ; boolean haveZ = shape . length == 4 ; int nt = shape [ count ++ ] ; int nz = haveZ ? shape [ count ++ ] : 1 ; int ny = shape [ count ++ ] ; int nx = shape [ count ] ; count = 0 ; Range timeRange = section . getRange ( count ++ ) ; Range zRange = haveZ ? section . getRange ( count ++ ) : null ; Range yRange = section . getRange ( count ++ ) ; Range xRange = section . getRange ( count ) ; int grid_size = nx * ny * nz ; Array dataArray = Array . factory ( DataType . FLOAT , section . getShape ( ) ) ; IndexIterator ii = dataArray . getIndexIterator ( ) ; // loop over time for ( int timeIdx : timeRange ) { float [ ] data = new float [ grid_size ] ; float [ ] ranges = new float [ 2 ] ; try { v5dstruct . v5d_read ( timeIdx , varIdx , ranges , data ) ; } catch ( BadFormException bfe ) { throw new IOException ( "Vis5DIosp.readData: " + bfe . getMessage ( ) ) ; } if ( ( ranges [ 0 ] >= 0.99E30 ) && ( ranges [ 1 ] <= - 0.99E30 ) ) { //range_sets[j] = new Linear1DSet(0.0, 1.0, 255); } else if ( ranges [ 0 ] > ranges [ 1 ] ) { throw new IOException ( "Vis5DIosp.readData: bad read " + v2 . getFullName ( ) ) ; } // invert the rows float [ ] tmp_data = new float [ grid_size ] ; if ( zRange == null ) { int cnt = 0 ; for ( int mm = 0 ; mm < ny ; mm ++ ) { int start = ( mm + 1 ) * nx - 1 ; for ( int nn = 0 ; nn < nx ; nn ++ ) { tmp_data [ cnt ++ ] = data [ start -- ] ; } } } else { int cnt = 0 ; for ( int ll = 0 ; ll < nz ; ll ++ ) { for ( int mm = 0 ; mm < ny ; mm ++ ) { int start = ( ( mm + 1 ) * nx - 1 ) + nx * ny * ll ; for ( int nn = 0 ; nn < nx ; nn ++ ) { tmp_data [ cnt ++ ] = data [ start -- ] ; } } } } data = tmp_data ; // copy the data into the array for ( float aData : data ) { ii . setFloatNext ( aData ) ; } } // long end = System.currentTimeMillis() - startTime; return dataArray ; }
Read the data for the variable

@param v2      Variable to read
@param section section infomation
@return Array of data
@throws IOException           problem reading from file
@throws InvalidRangeException invalid Range
Read the data for the variable