Package org.apache.lucene.facet.collections

Examples of org.apache.lucene.facet.collections.IntToIntMap$IndexIterator


        assert(null != a);
    } catch (java.io.IOException e) {
        e.printStackTrace();
        assert(false);
    }
    IndexIterator ii = a.getIndexIterator();
    return ii.getFloatNext();
  }
View Full Code Here


        assert scanR.getLength() == scanV.getLength();

        Variable elevR =  nexrad2.findVariable("elevationR");
        assert elevR != null;
        Array elevRdata = elevR.read();
        IndexIterator elevRiter = elevRdata.getIndexIterator();
        Variable elevR_HI =  nexrad2.findVariable("elevationR_HI");
        assert elevR_HI != null;
        Array elevRdataHI = elevR_HI.read();
        IndexIterator elevRiterHI = elevRdataHI.getIndexIterator();

        Variable elevV =  nexrad2.findVariable("elevationV");
        assert elevV != null;
        Array elevVdata = elevV.read();
        IndexIterator elevViter = elevVdata.getIndexIterator();
        Variable elevV_HI =  nexrad2.findVariable("elevationV_HI");
        assert elevV_HI != null;
        Array elevVdataHI = elevV.read();
        IndexIterator elevViterHI = elevVdataHI.getIndexIterator();

        assert elevRdata.getSize() ==  elevVdata.getSize();

        int count = 0;
        boolean ok = true;
        while (elevRiter.hasNext()) {
          if (elevRiter.getFloatNext() != elevViter.getFloatNext()) {
            ok = false;
            System.out.println(count+" "+elevRiter.getFloatCurrent()+" != "+elevViter.getFloatCurrent());
          }
          count++;
        }
        count = 0;
        while (elevRiterHI.hasNext()) {
          if (Float.isNaN(elevRiterHI.getFloatNext())) {
            ok = false;
            System.out.println("elevationR_HI contains Float.NAN " + count );
          }
          count++;
        }
        count = 0;
        while (elevViterHI.hasNext()) {
          if (Float.isNaN(elevViterHI.getFloatNext())) {
            ok = false;
            System.out.println("elevationV_HI contains Float.NAN " + count );
          }
          count++;
        }
View Full Code Here

    {
      assertTrue( "Unexpected IOException reading \"year\" variable: " + e.getMessage(),
                  false );
    }
    int val = 0;
    IndexIterator iter = year.getIndexIterator();
    while (iter.hasNext()) {
      val = iter.getIntNext();
      assertTrue( "Value of variable \"year\" <" + val + "> not expected <2003>.",
                  val == 2003 );
    }

    // Test reading dayOfYear.
    ucar.ma2.Array dayOfYear = null;
    try
    {
      dayOfYear = meNcf.findVariable( "dayOfYear").read();
    }
    catch ( IOException e )
    {
      assertTrue( "Unexpected IOException reading \"dayOfYear\" variable: " + e.getMessage(),
                  false );
    }
    val = 0;
    iter = dayOfYear.getIndexIterator();
    while (iter.hasNext()) {
      val = iter.getIntNext();
      assertTrue( "Value of variable \"dayOfYear\" <" + val + "> not expected <200>.",
                  val == 200 );
    }

    // Test reading dayOfYear.
    ucar.ma2.Array secondsOfDay = null;
    try
    {
      secondsOfDay = meNcf.findVariable( "secondsOfDay").read();
    }
    catch ( IOException e )
    {
      assertTrue( "Unexpected IOException reading \"secondsOfDay\" variable: " + e.getMessage(),
                  false );
    }
    double prevVal = 0;
    double curVal = 0;
    double timeInterval = 0;
    double timeIntervalGuess = 0.42;
    double delta = 0.01;

    iter = secondsOfDay.getIndexIterator();
    if ( iter.hasNext())
    {
      prevVal = iter.getDoubleNext();
      int timeStep = 1;
      while (iter.hasNext())
      {
        curVal = iter.getDoubleNext();
        timeInterval = curVal - prevVal;
        StringBuffer tmpMsg = new StringBuffer( "Variable \"secondsOfDay\": [" )
                .append( timeStep ).append( "]=<" ).append( curVal).append( ">, [")
                .append( (timeStep-1) ).append( "]=<" ).append( prevVal ).append( "> difference <")
                .append( timeInterval).append( "> not within delta <" ).append( delta )
View Full Code Here

      assertTrue( "Unexpected IOException reading \"latitude\" variable: " + e.getMessage(),
                  false );
    }

    // Test that difference between neighboring pixels in first scan is small
    IndexIterator iter = latitude.getIndexIterator();
    float curVal = 0.0F;
    float diff = 0.0F;
    float biggestDiff = 0.0F;
    float smallestDiff = 0.0F;
    float prevVal = iter.getFloatNext();
    int cnt = 1;
    while (iter.hasNext() && cnt < 1465) {
      curVal = iter.getFloatNext();
      diff = curVal - prevVal;
      if ( cnt == 1)
      {
        biggestDiff = diff;
        smallestDiff = diff;
View Full Code Here

    DateUnit du = new DateUnit(time.getUnitsString());
    System.out.printf("units= %s%n", units);
    System.out.printf("DateUnit= %s (%s)%n", du, du.getUnitsString());

    Array data = time.read();
    IndexIterator ii = data.getIndexIterator();
    while (ii.hasNext()) {
      double val = ii.getDoubleNext();
      Date date = du.makeDate(val);
      System.out.printf(" %f %s ==  %s%n", val, units, format.toDateTimeStringISO(date));
      if (first == null) first = date;
    }
View Full Code Here

      logger.severe(e.toString());
      throw (new IOException(
          "Could not read from variable scan_index from file " + file));
    }

    IndexIterator scanIndexIterator = scanIndexArray.getIndexIterator();
    int ind = 0;
    while (scanIndexIterator.hasNext()) {
      scanStartPositions[ind] = ((Integer) scanIndexIterator.next())
          .intValue();
      ind++;
    }
    scanIndexIterator = null;
    scanIndexArray = null;
    scanIndexVariable = null;

    // Calc stop position for the last scan
    // This defines the end index of the last scan
    scanStartPositions[totalScans] = (int) massValueVariable.getSize();

    // Read retention times
    double[] retentionTimes = new double[totalScans];

    Variable scanTimeVariable = inputFile
        .findVariable("scan_acquisition_time");
    if (scanTimeVariable == null) {
      logger.severe("Could not find variable scan_acquisition_time from file "
          + file);
      throw (new IOException(
          "Could not find variable scan_acquisition_time from file "
              + file));
    }
    Array scanTimeArray = null;
    try {
      scanTimeArray = scanTimeVariable.read();
    } catch (Exception e) {
      logger.severe(e.toString());
      throw (new IOException(
          "Could not read from variable scan_acquisition_time from file "
              + file));
    }

    IndexIterator scanTimeIterator = scanTimeArray.getIndexIterator();
    ind = 0;
    while (scanTimeIterator.hasNext()) {
      if (scanTimeVariable.getDataType().getPrimitiveClassType() == float.class) {
        retentionTimes[ind] = ((Double) scanTimeIterator.next()) / 60d;
      }
      if (scanTimeVariable.getDataType().getPrimitiveClassType() == double.class) {
        retentionTimes[ind] = ((Double) scanTimeIterator.next()) / 60d;
      }
      ind++;
    }

    scanTimeIterator = null;
View Full Code Here

                    wrapper.variableDS.read(section);
            } catch (InvalidRangeException e) {
                throw netcdfFailure(e);
            }
            if (flipYAxis) {
                final IndexIterator it = array.getIndexIterator();
                for (int y = ymax; --y >= ymin; ) {
                    for (int x = xmin; x < xmax; x++) {
                        switch (type) {
                            case DataBuffer.TYPE_DOUBLE: {
                                raster.setSample(x, y, dstBand, it.getDoubleNext());
                                break;
                            }
                            case DataBuffer.TYPE_FLOAT: {
                                raster.setSample(x, y, dstBand, it.getFloatNext());
                                break;
                            }
                            case DataBuffer.TYPE_BYTE: {
                                byte b = it.getByteNext();
                                // int myByte = (0x000000FF & ((int) b));
                                // short anUnsignedByte = (short) myByte;
                                // raster.setSample(x, y, dstBand, anUnsignedByte);
                                raster.setSample(x, y, dstBand, b);
                                break;
                            }
                            default: {
                                raster.setSample(x, y, dstBand, it.getIntNext());
                                break;
                            }
                        }
                    }
                }
            }else{
                switch( type ) {
                    case DataBuffer.TYPE_DOUBLE: {
                        DoubleBuffer doubleBuffer = array.getDataAsByteBuffer().asDoubleBuffer();
                        double[] samples = new double[destRegion.width * destRegion.height];
                        doubleBuffer.get(samples);
                        raster.setSamples(xmin, ymin, destRegion.width, destRegion.height, dstBand, samples);
                        break;
                    }
                    case DataBuffer.TYPE_FLOAT:
                        float[] samples = new float[destRegion.width * destRegion.height];
                        FloatBuffer floatBuffer = array.getDataAsByteBuffer().asFloatBuffer();
                        floatBuffer.get(samples);
                        raster.setSamples(xmin,ymin,destRegion.width,destRegion.height,dstBand,samples);
                        break;
                    case DataBuffer.TYPE_BYTE:
                        //THIS ONLY WORKS FOR ONE BAND!!
                        raster.setDataElements(xmin,ymin,destRegion.width,destRegion.height,array.getDataAsByteBuffer().array());
                        break;
                    case DataBuffer.TYPE_INT:
                        IntBuffer intBuffer = array.getDataAsByteBuffer().asIntBuffer();
                        int[] intSamples = new int[destRegion.width * destRegion.height];
                        intBuffer.get(intSamples);
                        raster.setSamples(xmin, ymin, destRegion.width, destRegion.height, dstBand, intSamples);
                        break;
                    default: {
                        final IndexIterator it = array.getIndexIterator();
                        for (int y = ymin; y < ymax; y++ ) {
                            for (int x = xmin; x < xmax; x++) {
                                raster.setSample(x, y, dstBand, it.getIntNext());
                            }
                        }
                        break;
                    }

View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.collections.IntToIntMap$IndexIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.