@Override public Structure select(List<String> memberNames) { StructureDS result = new StructureDS(getParentGroup(), orgVar); List<Variable> members = new ArrayList<>(); for (String name : memberNames) { Variable m = findVariable(name); if (null != m) members.add(m); } result.setMemberVariables(members); result.isSubset = true; return result; }
@Override public String getName() { return stype.toString()+"("+struct.getShortName()+")"; } }
@Override public String getName() { return "MultidimStructure(" + struct.getFullName() + ")"; }
@Override public String setName(String newName) { this.orgName = getShortName(); setShortName(newName); return newName; }
@Override protected Variable copy() { return new StructureDS(getParentGroup(), this); }
public void testDatasetAddRecordAfter() throws InvalidRangeException, IOException { NetcdfDataset nc = NetcdfDataset.openDataset(TestDir.cdmLocalTestDataDir + "testWriteRecord.nc"); assert (Boolean) nc.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE); // record variable Variable record = nc.findVariable("record"); assert record instanceof StructureDS; StructureDS rs = (StructureDS) record; assert rs.getRank() == 1; assert rs.getDimension(0).getLength() == 2; /* Read a record */ Array rsValues = rs.read("1:1:2"); assert (rsValues instanceof ArrayStructure); assert rsValues.getRank() == 1; assert rsValues.getShape()[0] == 1; StructureData sdata = (StructureData) rsValues.getObject(rsValues.getIndex()); Array gdata = sdata.getArray("time"); assert gdata instanceof ArrayInt.D0 : gdata.getClass().getName(); ArrayInt.D0 tdata = (ArrayInt.D0) gdata; int t = tdata.get(); assert t == 18; int t2 = sdata.getScalarInt("time"); assert t2 == 18; /* Read the times: unlimited dimension */ Variable time = rs.findVariable("time"); Array timeValues = time.read(); assert (timeValues instanceof ArrayInt.D0); ArrayInt.D0 ta = (ArrayInt.D0) timeValues; assert (ta.get() == 6) : ta.get(); nc.close(); }
throw new IllegalStateException("Cant find Structure " + config.structName); dim = struct.getDimension(0); struct = (StructureDS) struct.select(config.vars); // limit to list of vars break; for (Variable v : struct.getVariables()) { struct.removeMemberVariable(v); } else { this.cols.add(v);
@Override public VariableDS findVariable(String axisName) { String structPrefix = struct.getShortName() + "."; if (axisName.startsWith(structPrefix)) axisName = axisName.substring(structPrefix.length()); return (VariableDS) struct.findVariable(axisName); }
private void convertMemberInfo(StructureMembers wrapperSm) { for (StructureMembers.Member m : wrapperSm.getMembers()) { Variable v = findVariable(m.getName()); if ((v == null) && (orgVar != null)) // may have been renamed v = (Variable) findVariableFromOrgName(m.getName()); if (v != null) // a section will have missing variables LOOK wrapperSm probbably wrong in that case // log.error("Cant find " + m.getName()); //else m.setVariableInfo(v.getShortName(), v.getDescription(), v.getUnitsString(), v.getDataType()); // nested structures if (v instanceof StructureDS) { StructureDS innerStruct = (StructureDS) v; innerStruct.convertMemberInfo(m.getStructureMembers()); } } }
@Override public VariableDS findVariable(String axisName) { return (VariableDS) parentStructure.findVariable(axisName); }
void add(int recnum) throws IOException { recnumList.add(recnum); if (sdata != null) return; try { sdata = struct.readStructure( recnum); } catch (ucar.ma2.InvalidRangeException e) { log.error("TableParentId read recno=" + recnum, e); throw new RuntimeException(e.getMessage()); } } }
private boolean convertNeeded(StructureMembers smData) { for (Variable v : getVariables()) { if (v instanceof VariableDS) { VariableDS vds = (VariableDS) v; if (vds.needConvert()) return true; } else if (v instanceof StructureDS) { StructureDS nested = (StructureDS) v; if (nested.convertNeeded(null)) return true; } // a variable with no data in the underlying smData if ((smData != null) && !varHasData(v, smData)) return true; } return false; }
StructureDS newStructure = new StructureDS(this, root, null, "record", udim.getShortName(), null, null); newStructure.setOriginalVariable(orgStructure); newStructure.addMemberVariable(memberV);
public StructureDataIterator getStructureDataIterator(Cursor cursor, int bufferSize) throws IOException { int recnum = cursor.getParentRecnum(); try { Section section = new Section().appendRange(recnum, recnum); int count = 1; while (count++ < struct.getRank()) // handles multidim case section.appendRange(null); ArrayStructure data = (ArrayStructure) struct.read(section); // read all the data for a fixed outer index return data.getStructureDataIterator(); } catch (InvalidRangeException e) { throw new IllegalStateException(e); } }
/** * DO NOT USE DIRECTLY. public by accident. * recalc any enhancement info */ public void enhance(Set<NetcdfDataset.Enhance> mode) { for (Variable v : getVariables()) { VariableEnhanced ve = (VariableEnhanced) v; ve.enhance(mode); } }
/** * Constructor. * @param parentStructure get data from this Structure * @param parentIndex name of member variable in leaf StructureData */ public JoinParentIndex(StructureDS parentStructure, String parentIndex) { this.parentStructure = parentStructure; this.parentIndex = parentIndex; try { parentData = (ArrayStructure) parentStructure.read(); // cache entire ArrayStructure LOOK } catch (IOException e) { e.printStackTrace(); } }
private Variable convertVariable(Group g, Variable v) { Variable newVar; if (v instanceof Sequence) { newVar = new SequenceDS(g, (Sequence) v); } else if (v instanceof Structure) { newVar = new StructureDS(g, (Structure) v); } else { newVar = new VariableDS(g, v, false); // enhancement done later } return newVar; }
public StructureDataIterator getStructureDataIterator(Cursor cursor, int bufferSize) throws IOException { return struct.getStructureIterator(bufferSize); }
assert record instanceof StructureDS; StructureDS rs = (StructureDS) record; assert rs.getRank() == 1; assert rs.getDimension(0).getLength() == 2; Array rsValues = rs.read("1:1:2"); assert (rsValues instanceof ArrayStructure); assert rsValues.getRank() == 1; Variable time = rs.findVariable("time"); assert time != null; Array timeValues = time.read();
throw new IllegalStateException("Cant find Structure " + config.structName); dim = struct.getDimension(0); struct = (StructureDS) struct.select(config.vars); // limit to list of vars break; for (Variable v : struct.getVariables()) { struct.removeMemberVariable(v); } else { this.cols.put(v.getShortName(), v);