ucar.ma2.Section
m.out.println( NCdumpW.printArray(as, "", null)); new TestStructureArray().testArrayStructure(as); // get f2 out of the 3nd "s" StructureMembers.Member f2 = as.getStructureMembers().findMember("f2"); short[] f2data = as.getJavaArrayShort(2, f2); assert f2data[0] == 20; assert f2data[1] == 21; assert f2data[2] == 22; // get nested1 out of the 3nd "s" StructureMembers.Member nested1 = as.getStructureMembers().findMember("nested1"); ArrayStructure nested1Data = as.getArrayStructure(2, nested1); // get g1 out of the 7th "nested1" StructureMembers.Member g1 = nested1Data.getStructureMembers().findMember("g1"); int g1data = nested1Data.getScalarInt(6, g1); assert g1data == 26; // get nested2 out of the 7th "nested1" StructureMembers.Member nested2 = nested1Data.getStructureMembers().findMember("nested2"); ArrayStructure nested2Data = nested1Data.getArrayStructure(6, nested2); // get h1 out of the 4th "nested2" StructureMembers.Member h1 = nested2Data.getStructureMembers().findMember("h1"); int val = nested2Data.getScalarInt(4, h1); assert (val == 264); } public ArrayStructure makeNested1(StructureMembers.Member parent) throws IOException, InvalidRangeException { StructureMembers members = new StructureMembers(parent.getName()); parent.setStructureMembers(members); StructureMembers.Member m = members.addMember("g1", "desc", "units", DataType.INT, new int[]{1}); Array data = Array.factory(DataType.INT, new int[]{4, 9}); m.setDataArray(data); fill(data); m = members.addMember("g2", "desc", "units", DataType.DOUBLE, new int[]{2}); data = Array.factory(DataType.DOUBLE, new int[]{4, 9, 2}); m.setDataArray(data); fill(data); m = members.addMember("g3", "desc", "units", DataType.DOUBLE, new int[]{3, 4}); data = Array.factory(DataType.DOUBLE, new int[]{4, 9, 3, 4}); m.setDataArray(data); fill(data); m = members.addMember("nested2", "desc", "units", DataType.STRUCTURE, new int[]{7}); data = makeNested2(m); m.setDataArray(data); return new ArrayStructureMA(members, new int[]{4, 9}); } public ArrayStructure makeNested2(StructureMembers.Member parent) throws IOException, InvalidRangeException { StructureMembers members = new StructureMembers(parent.getName()); parent.setStructureMembers(members); StructureMembers.Member m = members.addMember("h1", "desc", "units", DataType.INT, new int[]{1}); Array data = Array.factory(DataType.INT, new int[]{4, 9, 7}); m.setDataArray(data); fill(data); m = members.addMember("h2", "desc", "units", DataType.DOUBLE, new int[]{2}); data = Array.factory(DataType.DOUBLE, new int[]{4, 9, 7, 2}); m.setDataArray(data); fill(data); return new ArrayStructureMA(members, new int[]{4, 9, 7}); }
@author caron
@see Array