Package net.sf.saxon.functions

Examples of net.sf.saxon.functions.IndexOf$IndexIterator


    assert data.getRank() == 1;
    assert data.getSize() == ntimes;
    assert data.getShape()[0] == ntimes;
    assert data.getElementType() == double.class;

    IndexIterator dataI = data.getIndexIterator();
    while (dataI.hasNext())
      System.out.println(" coord="+dataI.getObjectNext());
  }
View Full Code Here


    assert data.getSize() == n;
    assert data.getShape()[0] == n;
    assert data.getElementType() == double.class;

    double prev = Double.NaN;
    IndexIterator dataI = data.getIndexIterator();
    while (dataI.hasNext()) {
      double dval = dataI.getDoubleNext();
      System.out.println(" coord=" + dval);
      assert (Double.isNaN(prev) || dval > prev);
      prev = dval;
    }
  }
View Full Code Here

        Variable var = ncf.findVariable( parameter );
        Dimension dim = var.getDimension( 0 );
        String bounds = dim.getName() +"_bounds";
        Variable interval = ncf.findVariable( bounds );
        Array data = interval.read();
        IndexIterator iter = data.getIndexIterator();
        int idx = 0;
        while (iter.hasNext()) {
          int start = iter.getIntNext();
          int end = iter.getIntNext();
          if( start != tb[idx][0] || end != tb[idx][1]) {
            System.out.printf( "bounds for file %s, parameter %s failed%n", grib, parameter);
            System.out.printf( "interval %d - %d  known %d - %d%n",
              start, end, tb[idx][0],  tb[idx][1] );
         
View Full Code Here

    int ntimes = shape[0];
    assert (ntimes == dateList.size());

    DataType coordType = (timeAxis.getDataType() == DataType.STRING) ? DataType.STRING : DataType.DOUBLE;
    Array timeCoordVals = Array.factory(coordType, shape);
    IndexIterator ii = timeCoordVals.getIndexIterator();

    // check if its a String or a udunit
    if (timeAxis.getDataType() == DataType.STRING) {

      for (Date date : dateList) {
        ii.setObjectNext(dateFormatter.toDateTimeStringISO(date));
      }

    } else {     
      timeAxis.setDataType(DataType.DOUBLE); // otherwise fractional values get lost

      DateUnit du;
      try {
        du = new DateUnit(timeUnits);
      } catch (Exception e) {
        throw new IOException(e.getMessage());
      }
      timeAxis.addAttribute(new Attribute("units", timeUnits));

      for (Date date : dateList) {
        double val = du.makeValue(date);
        ii.setDoubleNext(val);
      }
    }

    timeAxis.setCachedData(timeCoordVals, false);
  }
View Full Code Here

        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

TOP

Related Classes of net.sf.saxon.functions.IndexOf$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.