Package kameleon.document2

Examples of kameleon.document2.Array


        sbuff = new StringBuilder(64000);
        sbuff.append(structMetadata);
      }

      // read and parse the ODL
      Array A = structMetadataVar.read();
      ArrayChar ca = (ArrayChar) A;
      structMetadata = ca.getString(); // common case only StructMetadata.0, avoid extra copy

      if (sbuff != null)
        sbuff.append(structMetadata);
View Full Code Here


      // make new variable for this dimension map
      Variable v = new Variable(ncfile, parent, null, dataDimName);
      v.setDimensions(geoDimName);
      v.setDataType(DataType.INT);
      int npts = (int) v.getSize();
      Array data = Array.makeArray(v.getDataType(), npts, offset, incr);
      v.setCachedData(data, true);
      v.addAttribute(new Attribute("_DimensionMap", ""));
      parent.addVariable(v);
      if (showWork) System.out.printf(" Add dimensionMap %s %n", v);
    }
View Full Code Here

     */
    public Array readData1(ucar.nc2.Variable v2, Section section)
    throws IOException, InvalidRangeException {
        //doData(raf, ncfile, varList);
        int[] sh=section.getShape();
        Array temp=Array.factory(v2.getDataType(), sh);
        long pos0=0;
        // Suppose that the data has LayoutRegular
        LayoutRegular index=new LayoutRegular(pos0, v2.getElementSize(), v2.getShape(), section);
        if (v2.getShortName().startsWith("time") | v2.getShortName().startsWith("numGates")) {
            temp=readIntData(index, v2);
View Full Code Here

     // Vgroup vgroup = (Vgroup) v2.getSPobject();
     // Range scanRange = section.getRange(0);
     // Range radialRange = section.getRange(1);
     // Range gateRange = section.getRange(2);

      Array data = Array.factory(v2.getDataType().getPrimitiveClassType(), section.getShape());
      IndexIterator ii = data.getIndexIterator();

      List groups = null;
      String shortName = v2.getShortName();
      if( shortName.startsWith("Reflectivity"))
        groups = volScan.getReflectivityGroups();
View Full Code Here

     * @param channel  WritableByteChannel object - channel that can write bytes.
     * @return the number of bytes written, possibly zero.
     */
    public long readToByteChannel11(ucar.nc2.Variable v2, Section section, WritableByteChannel channel)
    throws java.io.IOException, ucar.ma2.InvalidRangeException {
        Array data = readData(v2, section);
        float[] ftdata=new float[(int)data.getSize()];
        byte[] bytedata=new byte[(int)data.getSize()*4];
        IndexIterator iter=data.getIndexIterator();
        int i=0;
        ByteBuffer buffer=ByteBuffer.allocateDirect(bytedata.length);
        while (iter.hasNext()) { ftdata[i]=iter.getFloatNext();
        bytedata[i]=new Float(ftdata[i]).byteValue();
        buffer.put(bytedata[i]);
View Full Code Here

        xout.writeBytes("  <metar>\n");
        for (Iterator iter = sdata.getMembers().iterator(); iter.hasNext();) {
          StructureMembers.Member m = (StructureMembers.Member) iter.next();
          xout.writeBytes("    <data name='" + m.getName() + "'>");

          Array sdataArray = sdata.getArray(m);
          // System.out.println(m.getName()+" "+m.getDataType()+" "+sdataArray.toString());
          xout.writeBytes(sdataArray.toString() + "</data>\n");
        }

        xout.writeBytes("  </metar>\n");
      }
    };
View Full Code Here

    GridDataset gds = GridDataset.open (filename);
    GeoGrid grid = gds.findGridByName("Temperature");

    long startTime = System.currentTimeMillis();

    Array data = grid.readDataSlice(0, -1, -1, -1);

    long endTime = System.currentTimeMillis();
    long diff = endTime - startTime;
    System.out.println("read "+data.getSize()+"  took "+diff+ " msecs");

    startTime = endTime;
    float[] jdata = (float []) data.get1DJavaArray(float.class);
    endTime = System.currentTimeMillis();
    diff = endTime - startTime;
    System.out.println("convert took "+diff+ " msecs "+jdata[0]);
  }
View Full Code Here

      GeoGrid gg = gridDs.findGridByName("Temperature");
      long took = System.currentTimeMillis() - start;
      System.out.println("open took = " + took+" msecs");

      start = System.currentTimeMillis();
      Array data = gg.readVolumeData(0);
      took = System.currentTimeMillis() - start;
      float size = (float) data.getSize() * gg.getDataType().getSize() / (1000 * 1000);
      System.out.println(size+" Mbytes, took = " + took+" msecs");

    } catch (Exception ioe) {
      ioe.printStackTrace();
    }
View Full Code Here

    NetcdfFile ncfile = TestH5.openH5("samples/opaque.h5");
    System.out.println( "\n"+ncfile);
    Variable v2 = ncfile.findVariable("Opaque");
    assert v2 != null;

    Array data = v2.read();
    assert data.getElementType() == ByteBuffer.class : data.getElementType();
    System.out.println( "data size= "+new Section(data.getShape()));
    NCdump.printArray(data, "Opaque data", System.out, null);


    Array odata = v2.read(new Section("1:20"));
    assert odata.getElementType() == ByteBuffer.class;
    assert odata.getSize() == 20;
    ncfile.close();
  }
View Full Code Here

  public void testEnum() throws InvalidRangeException, IOException {
    NetcdfFile ncfile = TestH5.openH5("support/enum.h5");
    Variable v2 = ncfile.findVariable("enum");
    assert v2 != null;

    Array data = v2.read();
    assert data.getElementType() == int.class;

    NetcdfDataset ncd = TestH5.openH5dataset("support/enum.h5");
    v2 = ncd.findVariable("enum");
    assert v2 != null;

    data = v2.read();
    assert data.getElementType() == String.class;
    ncfile.close();
  }
View Full Code Here

TOP

Related Classes of kameleon.document2.Array

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.