grib/src/main/java/ucar/nc2/grib/collection/GribIosp.java
private Array makeLazyTime2Darray(Variable coord, Time2Dinfo info) {
    CoordinateTime2D time2D = info.time2D;
    CalendarPeriod timeUnit = time2D.getTimeUnit();

    int nruns = time2D.getNruns();
    int ntimes = time2D.getNtimes();

    int length = (int) coord.getSize();
    if (info.which == Time2DinfoType.bounds) {
      length *= 2;
    }

    double[] data = new double[length];
    for (int i = 0; i < length; i++) {
      data[i] = Double.NaN;
    }
    int count;

    // coordinate values
    switch (info.which) {
      case off:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (int val : coordTime.getOffsetSorted()) {
            data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * val + time2D.getOffset(runIdx);
            timeIdx++;
          }
        }
        break;

      case offU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx);
          for (int val : coordTime.getOffsetSorted()) {
            data[count++] = timeUnit.getValue() * val + time2D.getOffset(runIdx);
          }
        }
        break;

      case intv:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * tinv.getBounds2() + time2D
                .getOffset(runIdx); // use upper bounds for coord value
            timeIdx++;
          }
        }
        break;

      case intvU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D
                .getOffset(runIdx); // use upper bounds for coord value
          }
        }
        break;

      case is1Dtime:
        CoordinateRuntime runtime = time2D.getRuntimeCoordinate();
        count = 0;
        for (double val : runtime.getOffsetsInTimeUnits()) { // convert to udunits
          data[count++] = val;
        }
        break;

      case isUniqueRuntime:  // the aux runtime coordinate
        CoordinateRuntime runtimeU = time2D.getRuntimeCoordinate();
        List<Double> runOffsets = runtimeU.getOffsetsInTimeUnits();
        count = 0;
        for (int run = 0; run < time2D.getNruns(); run++) {
          CoordinateTimeAbstract timeCoord = time2D.getTimeCoordinate(run);
          for (int time = 0; time < timeCoord.getNCoords(); time++) {
            data[count++] = runOffsets.get(run);
          }
        }
        break;

      case bounds:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[runIdx * ntimes * 2 + timeIdx] =
                timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx);
            data[runIdx * ntimes * 2 + timeIdx + 1] =
                timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx);
            timeIdx += 2;
          }
        }
        break;

      case boundsU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[count++] = timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx);
            data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx);
          }
        }
        break;

      default:
        throw new IllegalStateException();
    }

    return Array.factory(DataType.DOUBLE, coord.getShape(), data);
  }
private Array makeLazyTime2Darray(Variable coord, Time2Dinfo info) {
    CoordinateTime2D time2D = info.time2D;
    CalendarPeriod timeUnit = time2D.getTimeUnit();

    int nruns = time2D.getNruns();
    int ntimes = time2D.getNtimes();

    int length = (int) coord.getSize();
    if (info.which == Time2DinfoType.bounds) {
      length *= 2;
    }

    double[] data = new double[length];
    for (int i = 0; i < length; i++) {
      data[i] = Double.NaN;
    }
    int count;

    // coordinate values
    switch (info.which) {
      case off:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (int val : coordTime.getOffsetSorted()) {
            data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * val + time2D.getOffset(runIdx);
            timeIdx++;
          }
        }
        break;

      case offU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx);
          for (int val : coordTime.getOffsetSorted()) {
            data[count++] = timeUnit.getValue() * val + time2D.getOffset(runIdx);
          }
        }
        break;

      case intv:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * tinv.getBounds2() + time2D
                .getOffset(runIdx); // use upper bounds for coord value
            timeIdx++;
          }
        }
        break;

      case intvU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D
                .getOffset(runIdx); // use upper bounds for coord value
          }
        }
        break;

      case is1Dtime:
        CoordinateRuntime runtime = time2D.getRuntimeCoordinate();
        count = 0;
        for (double val : runtime.getOffsetsInTimeUnits()) { // convert to udunits
          data[count++] = val;
        }
        break;

      case isUniqueRuntime:  // the aux runtime coordinate
        CoordinateRuntime runtimeU = time2D.getRuntimeCoordinate();
        List<Double> runOffsets = runtimeU.getOffsetsInTimeUnits();
        count = 0;
        for (int run = 0; run < time2D.getNruns(); run++) {
          CoordinateTimeAbstract timeCoord = time2D.getTimeCoordinate(run);
          for (int time = 0; time < timeCoord.getNCoords(); time++) {
            data[count++] = runOffsets.get(run);
          }
        }
        break;

      case bounds:
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          int timeIdx = 0;
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[runIdx * ntimes * 2 + timeIdx] =
                timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx);
            data[runIdx * ntimes * 2 + timeIdx + 1] =
                timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx);
            timeIdx += 2;
          }
        }
        break;

      case boundsU:
        count = 0;
        for (int runIdx = 0; runIdx < nruns; runIdx++) {
          CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx);
          for (TimeCoordIntvValue tinv : timeIntv.getTimeIntervals()) {
            data[count++] = timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx);
            data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx);
          }
        }
        break;

      default:
        throw new IllegalStateException();
    }

    return Array.factory(DataType.DOUBLE, coord.getShape(), data);
  }
private Array makeLazyTime2Darray ( Variable coord , Time2Dinfo info ) { CoordinateTime2D time2D = info . time2D ; CalendarPeriod timeUnit = time2D . getTimeUnit ( ) ; int nruns = time2D . getNruns ( ) ; int ntimes = time2D . getNtimes ( ) ; int length = ( int ) coord . getSize ( ) ; if ( info . which == Time2DinfoType . bounds ) { length *= 2 ; } double [ ] data = new double [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { data [ i ] = Double . NaN ; } int count ; // coordinate values switch ( info . which ) { case off : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTime coordTime = ( CoordinateTime ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( int val : coordTime . getOffsetSorted ( ) ) { data [ runIdx * ntimes + timeIdx ] = timeUnit . getValue ( ) * val + time2D . getOffset ( runIdx ) ; timeIdx ++ ; } } break ; case offU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTime coordTime = ( CoordinateTime ) time2D . getTimeCoordinate ( runIdx ) ; for ( int val : coordTime . getOffsetSorted ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * val + time2D . getOffset ( runIdx ) ; } } break ; case intv : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ runIdx * ntimes + timeIdx ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; // use upper bounds for coord value timeIdx ++ ; } } break ; case intvU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; // use upper bounds for coord value } } break ; case is1Dtime : CoordinateRuntime runtime = time2D . getRuntimeCoordinate ( ) ; count = 0 ; for ( double val : runtime . getOffsetsInTimeUnits ( ) ) { // convert to udunits data [ count ++ ] = val ; } break ; case isUniqueRuntime : // the aux runtime coordinate CoordinateRuntime runtimeU = time2D . getRuntimeCoordinate ( ) ; List < Double > runOffsets = runtimeU . getOffsetsInTimeUnits ( ) ; count = 0 ; for ( int run = 0 ; run < time2D . getNruns ( ) ; run ++ ) { CoordinateTimeAbstract timeCoord = time2D . getTimeCoordinate ( run ) ; for ( int time = 0 ; time < timeCoord . getNCoords ( ) ; time ++ ) { data [ count ++ ] = runOffsets . get ( run ) ; } } break ; case bounds : for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; int timeIdx = 0 ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ runIdx * ntimes * 2 + timeIdx ] = timeUnit . getValue ( ) * tinv . getBounds1 ( ) + time2D . getOffset ( runIdx ) ; data [ runIdx * ntimes * 2 + timeIdx + 1 ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; timeIdx += 2 ; } } break ; case boundsU : count = 0 ; for ( int runIdx = 0 ; runIdx < nruns ; runIdx ++ ) { CoordinateTimeIntv timeIntv = ( CoordinateTimeIntv ) time2D . getTimeCoordinate ( runIdx ) ; for ( TimeCoordIntvValue tinv : timeIntv . getTimeIntervals ( ) ) { data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds1 ( ) + time2D . getOffset ( runIdx ) ; data [ count ++ ] = timeUnit . getValue ( ) * tinv . getBounds2 ( ) + time2D . getOffset ( runIdx ) ; } } break ; default : throw new IllegalStateException ( ) ; } return Array . factory ( DataType . DOUBLE , coord . getShape ( ) , data ) ; }
only for the 2d times
only for the 2d times