Package ucar.ma2

Examples of ucar.ma2.StructureData


  public void utestNestedTableEnhanced() throws IOException, InvalidRangeException {
    String filename = TestAll.cdmLocalTestDataDir + "dataset/nestedTable.bufr";
    NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename);
    Structure outer = (Structure) ncd.findVariable(BufrIosp.obsRecord);
    StructureData data = outer.readStructure(0);
    //NCdumpW.printStructureData( new PrintWriter(System.out), data);

    assert Double.isNaN( data.getScalarFloat("Latitude"));

    ArrayStructure as = data.getArrayStructure("struct1");
    assert as != null;
    assert TestAll.closeEnough(as.getScalarFloat(0, as.findMember("Wind_speed")),6.1);

    ncd.close();
  }
View Full Code Here


      record = new StructurePseudo(ncfile, null, "precord", d);
      System.out.println("   use psuedo record");
    }
    StructureDataIterator iter = record.getStructureIterator();
    while (iter.hasNext()) {
      StructureData sd = iter.next();
      if (first) {
        System.out.println("   record size = " + sd.getStructureMembers().getStructureSize() + " " +
                "   nvars = " + sd.getStructureMembers().getMembers().size());
      }
      first = false;

    }
    double took = (System.currentTimeMillis() - start) * .001;
 
View Full Code Here

    double count = 0;
    long start = System.currentTimeMillis();
    DataIterator iter = tob.getDataIterator(0);
    while (iter.hasNext()) {
      PointObsDatatype pobs = (PointObsDatatype) iter.nextData();
      StructureData sdata = pobs.getData();
      count += pobs.getObservationTime();
    }
    double took = (System.currentTimeMillis() - start) * .001;
    System.out.println(" readIterator took=" + took + " secs " + count);

View Full Code Here

    try {
      stationHelper = new StationHelper();

      StructureDataIterator siter = ft.getStationDataIterator(-1);
      while (siter.hasNext()) {
        StructureData stationData = siter.next();
        Station s = makeStation(stationData, siter.getCurrentRecno());
        if (s != null)
          stationHelper.addStation( s);
      }
    } catch (IOException ioe) {
View Full Code Here

    CFPointObWriter writer = new CFPointObWriter(out, pobsDataset.getGlobalAttributes(), altUnits, nvars, -1);

    DataIterator iter = pobsDataset.getDataIterator(1000 * 1000);
    while (iter.hasNext()) {
      PointObsDatatype pobsData = (PointObsDatatype) iter.nextData();
      StructureData sdata = pobsData.getData();

      int dcount = 0;
      int scount = 0;
      for (PointObVar v : nvars) {
        if (v.getDataType().isNumeric()) {
          Array data = sdata.getArray(v.getName());
          data.resetLocalIterator();
          if (data.hasNext())
            dvals[dcount++] = data.nextDouble();

        } else if (v.getDataType().isString()) {
          ArrayChar data = (ArrayChar) sdata.getArray(v.getName());
          svals[scount++] = data.getString();
        }
      }

      ucar.unidata.geoloc.EarthLocation loc = pobsData.getLocation();
View Full Code Here

    int count = 0;
    pointFeatureCollection.resetIteration();
    while (pointFeatureCollection.hasNext()) {
      PointFeature pointFeature = (PointFeature) pointFeatureCollection.next();
      StructureData data = pointFeature.getData();
      if (count == 0) {
        EarthLocation loc = pointFeature.getLocation(); // LOOK we dont know this until we see the obs
        String altUnits = Double.isNaN(loc.getAltitude()) ? null : "meters"; // LOOK units may be wrong
        writer = new WriterCFPointDataset(out, pfDataset.getGlobalAttributes(), altUnits);
        writer.writeHeader(pfDataset.getDataVariables(), -1);
View Full Code Here

    this.linkVarName = linkVarName;
  }

  @Override
  public StructureData next() throws IOException {
    StructureData sdata;
    currRecno = nextRecno;
    try {
      sdata = s.readStructure( currRecno);
    } catch (ucar.ma2.InvalidRangeException e) {
      log.error("StructureDataLinkedIterator.nextStructureData recno=" + currRecno, e);
      throw new IOException(e.getMessage());
    }

    if (numRecords > 0) { // contiguous case
      nextRecno++;
      if (nextRecno >= firstRecord + numRecords)
        nextRecno = -1;

    } else {
      nextRecno = sdata.getScalarInt(linkVarName);
    }

    return sdata;
  }
View Full Code Here

  }

  private void entryTest( StructureDataIterator dodsIt, BasicEntry expectedEntry, float longDelta )
  {

    StructureData curData;
    try
    {
      if ( ! dodsIt.hasNext())
        assertTrue( "DODS result does not contain expected entry.", false);
      curData = dodsIt.next();
    }
    catch ( IOException e )
    {
      assertTrue( "Unexpected IOException reading from structure iterator: " + e.getMessage(),
                false);
      return;
    }
    int year = curData.getScalarInt( "year");
    int day = curData.getScalarInt( "day");
    int hours = curData.getScalarInt( "hours");
    int minutes = curData.getScalarInt( "minutes");
    int seconds = curData.getScalarInt( "seconds");
    int m_seconds = curData.getScalarInt( "m_seconds");
    float longitude = curData.getScalarFloat( "longitude");
    int rev_num = curData.getScalarInt( "rev_num");
    int wvc_rows = curData.getScalarInt( "wvc_rows");
    String dodsUrl = curData.getScalarString( "DODS_URL");
//    System.out.println( "year = " + year );
//    System.out.println( "day = " + day );
//    System.out.println( "hours = " + hours );
//    System.out.println( "minutes = " + minutes );
//    System.out.println( "longitude = " + longitude );
View Full Code Here

    System.out.printf(" count = %d%n", as.getStructureDataCount());

    int count = 0;
    StructureDataIterator iter = as.getStructureDataIterator();
    while (iter.hasNext()) {
      StructureData sdata = iter.next();
      count++;
    }
    System.out.printf(" count = %d%n", count);

    int count2 = 0;
    StructureDataIterator iter2 = record.getStructureIterator();
    while (iter2.hasNext()) {
      StructureData sdata = iter2.next();
      count2++;
    }
    System.out.printf(" count2 = %d%n", count2);

    assert count2 == count;
View Full Code Here

      return orgIter.hasNext();
    }

    @Override
    public StructureData next() throws IOException {
      StructureData sdata = orgIter.next();
      return newStruct.convert(sdata, count++);
    }
View Full Code Here

TOP

Related Classes of ucar.ma2.StructureData

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.