Hi Bruno: Yes, you're right, for some reason I am handling the case with only one vlen array differently. I will remove that special handling so that one can handle the returned Array uniformly. John On 11/25/2010 4:01 AM, Bruno Santos wrote:
Hello John, I think that there are another problem... If I read one section with more than one sub-arrays all is perfect. But if I select only one sub-array the data.next() returns each value of this sub-array instead of the entire sub-array. With the following code if I the finalIndex and initialIndex are the same (for example 5) I get this error: Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to ucar.ma2.Array at Simple_xy_rd.main(Simple_xy_rd.java:213) Java Result: 1 Thank you for your support, Bruno Santos Example: initialIndex = 5; finalIndex = 6; Array data = dataLevels.read(initialIndex + ":" + finalIndex + ",:"); //NCdumpW.printArray(data, "read()", new PrintWriter( System.out), null); System.out.println("Size: " + data.getSize()); System.out.println("Data: " + data); // loop over outer dimension ArrayList<Point> points = new ArrayList<Point>(); int x = 0; while (data.hasNext()) { System.out.println("Index: " + data.getIndex()); System.out.println("Rank: " + data.getRank()); System.out.println("Size: " + data.getSize()); System.out.println("Shape: " + data.getShape().toString()); Array as = (Array) data.next(); // inner variable length array of short System.out.println(as); 2010/11/24 Unidata netCDF Java Support <address@hidden <mailto:address@hidden>> Hi Bruno: This should be fixed in latest release 4.2.20101124.1758. thanks for reporting it. ive added some docs on how to read vlen variables: http://www.unidata.ucar.edu/software/netcdf-java/reference/DataType.html Johnthis looks like a bug in our code, ill let you know when i have a fix.Hello, I'm developing a data acquisition system with multiple data for each time stamp... Each time stamp have one array of shorts with variable lenght because the samples can have different lenght over the time. But I can't read the values from variable "levels" because its shape is -1... When I use the API read function I got the errors showed below. I'm using the last version of NetCDF Java Library. Can you help me to read a vlen_t variable with multiple data in Java? Thanks for your support, Bruno Santos P.S. Attached the .nc and .cdl files types: ushort(*) vlen_t; dimensions: acqtime = UNLIMITED ; variables: uint acqtime(acqtime) ; acqtime:long_name = "Acquisition time" ; (...) vlen_t levels(acqtime); levels:long_name = "Acquired values array" ; data: acqtime = 1,2,3,4,5,6,7,8,9,10; levels={1,1,1,2,3,4,5,6,7,8}, {2,2,2,3,4,5,6,7,8,9}, {3,3,3,4,5,6,7,8,9,10}, {4,4,4,5,6,7,8,9,10,11}, {5,5,5,6,7,8,9,10,11,12}, {6,6,6,7,8,9,10,11,12,13}, {7,7,7,8,9,10,11,12,13,14}, {8,8,8,9,10,11,12,13,14,15}, {9,9,9,10,11,12,13,14,15,16}, {10,10,10,11,12,13,14,15,16,17}; } ------------------------------- dataFile = NetcdfFile.open(filename, null); // Retrieve the variable named "data" Variable dataVar = dataFile.findVariable("levels"); if (dataVar == null) { System.out.println("Cant find Variable data"); return; } try { Array data = dataVar.read(); } catch (IOException ioe) { System.out.println("trying to read " + ioe); } __________________________________ Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at ucar.nc2.iosp.hdf5.Tiling.tile(Tiling.java:84) at ucar.nc2.iosp.hdf5.Tiling.order(Tiling.java:99) at ucar.nc2.iosp.hdf5.Tiling.compare(Tiling.java:113) at ucar.nc2.iosp.hdf5.H5header$DataBTree$Node.first(H5header.java:4265)atucar.nc2.iosp.hdf5.H5header$DataBTree$DataChunkIterator2.< init>(H5header.java:4137) at ucar.nc2.iosp.hdf5.H5header$DataBTree.getDataChunkIterator2( H5header.java:4118) at ucar.nc2.iosp.hdf5.H5tiledLayout.<init>(H5tiledLayout.java:90) at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:175) at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:121) at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:1759) at ucar.nc2.Variable.reallyRead(Variable.java:809) at ucar.nc2.Variable._read(Variable.java:781) at ucar.nc2.Variable.read(Variable.java:659) at ucar.nc2.Variable.getScalarData(Variable.java:759) at ucar.nc2.Variable.readScalarByte(Variable.java:675) Java Result: 1Ticket Details =================== Ticket ID: FUE-836943 Department: Support netCDF Java Priority: Normal Status: Closed