protected void unravelStringMet(NetcdfFile ncFile, Group group, Metadata met) { if (group == null) { group = ncFile.getRootGroup(); } // get file type met.set("File-Type-Description", ncFile.getFileTypeDescription()); // unravel its string attrs for (Attribute attribute : group.getAttributes()) { if (attribute.isString()) { met.add(attribute.getFullName(), attribute.getStringValue()); } else { // try and cast its value to a string met.add(attribute.getFullName(), String.valueOf(attribute .getNumericValue())); } } for (Group g : group.getGroups()) { unravelStringMet(ncFile, g, met); } }
public List getAttributes() { return ncd.getRootGroup().getAttributes(); }
public List getAttributes() { return ncd.getRootGroup().getAttributes(); }
public static NcAttributeMap create(Group group) { return new NcAttributeMap(group.getAttributes()); }
public List getAttributes() { return ncd.getRootGroup().getAttributes(); }
private static void addAttributes(final MetadataElement parentElem, final Group parentGroup) { final List<Attribute> attribList = parentGroup.getAttributes(); for (Attribute at : attribList) { createMetadataAttributes(parentElem, at, at.getName()); } }
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); } }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
/** * Copy attributes from src to target, skip ones that already exist (by name) * @param src copy from here * @param target copy to here */ static public void transferGroupAttributes(Group src, Group target) { for (Attribute a : src.getAttributes()) { if (null == target.findAttribute(a.getShortName())) target.addAttribute(a); } }
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); } }
@Test public void testReadAll() throws IOException { NetcdfFile ncfile = TestDir.openFileLocal("testSpecialAttributes.nc4"); // Iterate over all top-level attributes and see if it is special for(Attribute a : ncfile.getRootGroup().getAttributes()) { Assert.assertTrue("Attribute iteration found special attribute: " + a.getShortName(), !Attribute.isspecial(a)); } ncfile.close(); }
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); } }
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; }