@Override public String getDimensions() { return Dimension.makeDimensionList(netcdfFileWriteable.getRootGroup().getDimensions()); }
void dumpClasses(Group g, PrintStream out) { out.println("Dimensions:"); for (Dimension ds : g.getDimensions()) { out.println(" " + ds.getShortName() + " " + ds.getClass().getName()); } out.println("Atributes:"); for (Attribute a : g.getAttributes()) { out.println(" " + a.getShortName() + " " + a.getClass().getName()); } out.println("Variables:"); dumpVariables(g.getVariables(), out); out.println("Groups:"); for (Group nested : g.getGroups()) { out.println(" " + nested.getFullName() + " " + nested.getClass().getName()); dumpClasses(nested, out); } }
void dumpClasses(Group g, PrintWriter out) { out.println("Dimensions:"); for (Dimension ds : g.getDimensions()) { out.println(" " + ds.getShortName() + " " + ds.getClass().getName()); } out.println("Atributes:"); for (Attribute a : g.getAttributes()) { out.println(" " + a.getShortName() + " " + a.getClass().getName()); } out.println("Variables:"); dumpVariables(g.getVariables(), out); out.println("Groups:"); for (Group nested : g.getGroups()) { out.println(" " + nested.getFullName() + " " + nested.getClass().getName()); dumpClasses(nested, out); } }
void dumpClasses(Group g, PrintWriter out) { out.println("Dimensions:"); for (Dimension ds : g.getDimensions()) { out.println(" " + ds.getShortName() + " " + ds.getClass().getName()); } out.println("Atributes:"); for (Attribute a : g.getAttributes()) { out.println(" " + a.getShortName() + " " + a.getClass().getName()); } out.println("Variables:"); dumpVariables(g.getVariables(), out); out.println("Groups:"); for (Group nested : g.getGroups()) { out.println(" " + nested.getFullName() + " " + nested.getClass().getName()); dumpClasses(nested, out); } }
Iterator iter = ncfile.getRootGroup().getDimensions().iterator(); while (iter.hasNext()) { Dimension dim = (Dimension) iter.next();
Iterator iter = ncfile.getRootGroup().getDimensions().iterator(); while (iter.hasNext()) { Dimension dim = (Dimension) iter.next();
Iterator iter = ncfile.getRootGroup().getDimensions().iterator(); while (iter.hasNext()) { Dimension dim = (Dimension) iter.next();
/** * If an equivilent shared dimension already exists, use it, else add d to shared dimensions. * Equivilent is same name and length. * * @param group from this group, if null, use rootGroup * @param d find equivilent shared dimension to this one. * @return equivilent shared dimension or d. */ Dimension getSharedDimension(Group group, Dimension d) { if (d.getShortName() == null) return d; if (group == null) group = rootGroup; for (Dimension sd : group.getDimensions()) { if (sd.getShortName().equals(d.getShortName()) && sd.getLength() == d.getLength()) return sd; } d.setShared(true); group.addDimension(d); return d; }
private void count(Group g) { ndims += g.getDimensions().size(); nvars += g.getVariables().size(); ngatts += g.getAttributes().size(); ngroups += g.getGroups().size(); for (Variable v : g.getVariables()) { natts += v.getAttributes().size(); if (v instanceof Structure) { nstructFields += ((Structure) v).getVariables().size(); } } for (Group ng : g.getGroups()) count(ng); } }
private void count(Group g) { ndims += g.getDimensions().size(); nvars += g.getVariables().size(); ngatts += g.getAttributes().size(); ngroups += g.getGroups().size(); for (Variable v : g.getVariables()) { natts += v.getAttributes().size(); if (v instanceof Structure) { nstructFields += ((Structure) v).getVariables().size(); } } for (Group ng : g.getGroups()) count(ng); } }
newGroup.addAttribute(att); for (Dimension dim : oldGroup.getDimensions()) { ncOut.addDimension(newGroup, dim.getShortName(), dim.getLength(), true, dim.isUnlimited(), dim.isVariableLength());
private Element writeGroup(Element elem, Group group) { for (Dimension dim : group.getDimensions()) { elem.addContent(writeDimension(dim, ncNS));
private void convertGroup(Group g, Group from) { for (EnumTypedef et : from.getEnumTypedefs()) g.addEnumeration(et); for (Dimension d : from.getDimensions()) g.addDimension(new Dimension(d.getShortName(), d)); for (Attribute a : from.getAttributes()) g.addAttribute(a); for (Variable v : from.getVariables()) g.addVariable(convertVariable(g, v)); for (Group nested : from.getGroups()) { Group nnested = new Group(this, g, nested.getShortName()); g.addGroup(nnested); convertGroup(nnested, nested); } }
private void convertGroup(Group g, Group from) { for (EnumTypedef et : from.getEnumTypedefs()) g.addEnumeration(et); for (Dimension d : from.getDimensions()) g.addDimension(new Dimension(d.getShortName(), d)); for (Attribute a : from.getAttributes()) g.addAttribute(a); for (Variable v : from.getVariables()) g.addVariable(convertVariable(g, v)); for (Group nested : from.getGroups()) { Group nnested = new Group(this, g, nested.getShortName()); g.addGroup(nnested); convertGroup(nnested, nested); } }
private void convertGroup(Group g, Group from) { for (EnumTypedef et : from.getEnumTypedefs()) g.addEnumeration(et); for (Dimension d : from.getDimensions()) g.addDimension(new Dimension(d.getShortName(), d)); for (Attribute a : from.getAttributes()) g.addAttribute(a); for (Variable v : from.getVariables()) g.addVariable(convertVariable(g, v)); for (Group nested : from.getGroups()) { Group nnested = new Group(this, g, nested.getShortName()); g.addGroup(nnested); convertGroup(nnested, nested); } }
public Element makeGroupElement(Group group) { Element elem = new Element("group", namespace); elem.setAttribute("name", group.getShortName()); // enumTypeDef for (EnumTypedef etd : group.getEnumTypedefs()) { elem.addContent(makeEnumTypedefElement(etd)); } // dimensions for (Dimension dim : group.getDimensions()) { elem.addContent(makeDimensionElement(dim)); } // regular variables for (Variable var : group.getVariables()) { boolean showValues = writeVariablesPredicate.apply(var); elem.addContent(makeVariableElement(var, showValues)); } // nested groups for (Group g : group.getGroups()) { Element groupElem = new Element("group", namespace); groupElem.setAttribute("name", g.getShortName()); elem.addContent(makeGroupElement(g)); } // attributes for (Attribute att : group.getAttributes()) { elem.addContent(makeAttributeElement(att)); } return elem; }
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException { NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder(); groupBuilder.setName(g.getShortName()); for (Dimension dim : g.getDimensions()) groupBuilder.addDims(NcStream.encodeDim(dim)); for (Attribute att : g.getAttributes()) groupBuilder.addAtts(NcStream.encodeAtt(att)); for (EnumTypedef enumType : g.getEnumTypedefs()) groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType)); for (Variable var : g.getVariables()) { if (var instanceof Structure) groupBuilder.addStructs(NcStream.encodeStructure((Structure) var)); else groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache)); } for (Group ng : g.getGroups()) groupBuilder.addGroups(encodeGroup(ng, sizeToCache)); return groupBuilder; }
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException { NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder(); groupBuilder.setName(g.getShortName()); for (Dimension dim : g.getDimensions()) groupBuilder.addDims(NcStream.encodeDim(dim)); for (Attribute att : g.getAttributes()) groupBuilder.addAtts(NcStream.encodeAtt(att)); for (EnumTypedef enumType : g.getEnumTypedefs()) groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType)); for (Variable var : g.getVariables()) { if (var instanceof Structure) groupBuilder.addStructs(NcStream.encodeStructure((Structure) var)); else groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache)); } for (Group ng : g.getGroups()) groupBuilder.addGroups(encodeGroup(ng, sizeToCache)); return groupBuilder; }
static NcStreamProto.Group.Builder encodeGroup(Group g, int sizeToCache) throws IOException { NcStreamProto.Group.Builder groupBuilder = NcStreamProto.Group.newBuilder(); groupBuilder.setName(g.getShortName()); for (Dimension dim : g.getDimensions()) groupBuilder.addDims(NcStream.encodeDim(dim)); for (Attribute att : g.getAttributes()) groupBuilder.addAtts(NcStream.encodeAtt(att)); for (EnumTypedef enumType : g.getEnumTypedefs()) groupBuilder.addEnumTypes(NcStream.encodeEnumTypedef(enumType)); for (Variable var : g.getVariables()) { if (var instanceof Structure) groupBuilder.addStructs(NcStream.encodeStructure((Structure) var)); else groupBuilder.addVars(NcStream.encodeVar(var, sizeToCache)); } for (Group ng : g.getGroups()) groupBuilder.addGroups(encodeGroup(ng, sizeToCache)); return groupBuilder; }
public void testWriteFlagCoding() throws Exception { Band flagBand = new Band("flag_band", ProductData.TYPE_UINT8, 10, 10); FlagCoding flagCoding = new FlagCoding("some_flags"); flagBand.setSampleCoding(flagCoding); flagCoding.setDescription("A Flag Coding"); for (int i = 0; i < 8; i++) { addFlag(flagCoding, i); } NetcdfFileWriteable writeable = NetcdfFileWriteable.createNew("not stored"); writeable.addDimension("y", flagBand.getSceneRasterHeight()); writeable.addDimension("x", flagBand.getSceneRasterWidth()); final DataType ncDataType = DataTypeUtils.getNetcdfDataType(flagBand.getDataType()); Variable variable = writeable.addVariable(flagBand.getName(), ncDataType, writeable.getRootGroup().getDimensions()); CfBandPart.writeCfBandAttributes(flagBand, new N3Variable(variable, writeable)); CfFlagCodingPart.writeFlagCoding(flagBand, new N3FileWriteable(writeable)); Variable someFlagsVariable = writeable.findVariable("flag_band"); assertNotNull(someFlagsVariable); Attribute flagMasksAttrib = someFlagsVariable.findAttribute("flag_masks"); assertNotNull(flagMasksAttrib); assertEquals(someFlagsVariable.getDataType(), flagMasksAttrib.getDataType()); assertEquals(8, flagMasksAttrib.getLength()); assertTrue(flagMasksAttrib.isUnsigned()); for (int i = 0; i < 8; i++) { assertEquals(1 << i, flagMasksAttrib.getValues().getInt(i)); } Attribute descriptionAttrib = someFlagsVariable.findAttribute("long_name"); assertNotNull(flagCoding.getDescription(), descriptionAttrib.getStringValue()); }