void put(Attribute attribute) { _map.put(attribute.getName(), attribute); }
List<KeyValuePair> getCoordinateAttributes(){ List<KeyValuePair> attribs = Collections.emptyList(); if (horizontalGrid!=null){ List<Attribute> attributes = horizontalGrid.getAttributes(); attribs = new LinkedList<KeyValuePair>(); for (Attribute attribute: attributes){ final String attribName = attribute.getName(); if (attribName.startsWith(GRIB1Utilities.GRIB_PARAM_PREFIX)){ KeyValuePair kvp = new KeyValuePair(attribName.substring(GRIB1Utilities.GRIB_PARAM_PREFIX.length()) ,NetCDFUtilities.getAttributesAsString(attribute)); attribs.add(kvp); } } } return attribs; }
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()); } }
public static MetadataElement addAttributes(final MetadataElement parentElem, final String elemName, final List<Attribute> attribList) { final MetadataElement globalElem = new MetadataElement(elemName); parentElem.addElement(globalElem); for (Attribute at : attribList) { createMetadataAttributes(globalElem, at, at.getName()); } return globalElem; }
/** * Recursively parses attribute and variable paths, filling * <code>attributeList</code> and <code>variableList</code>. * @param groups List of groups to recursively parse. */ private void parseAttributesAndVariables(List<Group> groups) { for (Group group : groups) { String groupName = group.getName(); List<Attribute> attributes = group.getAttributes(); for (Attribute attribute : attributes) { String attributeName = attribute.getName(); if (!groupName.endsWith("/")) attributeName = "/" + attributeName; attributeList.add(groupName + attributeName); } List<Variable> variables = group.getVariables(); for (Variable variable : variables) { String variableName = variable.getName(); if (!groupName.endsWith("/")) variableName = "/" + variableName; variableList.add(variableName); } groups = group.getGroups(); parseAttributesAndVariables(groups); } }
/** * Recursively parses attribute and variable paths, filling * <code>attributeList</code> and <code>variableList</code>. * @param groups List of groups to recursively parse. */ private void parseAttributesAndVariables(List<Group> groups) { for (Group group : groups) { String groupName = group.getName(); List<Attribute> attributes = group.getAttributes(); for (Attribute attribute : attributes) { String attributeName = attribute.getName(); if (!groupName.endsWith("/")) attributeName = "/" + attributeName; attributeList.add(groupName + attributeName); } List<Variable> variables = group.getVariables(); for (Variable variable : variables) { String variableName = variable.getName(); if (!groupName.endsWith("/")) variableName = "/" + variableName; variableList.add(variableName); } groups = group.getGroups(); parseAttributesAndVariables(groups); } }
@Override public Hashtable<String, Object> getVariableAttributes(String name) { String groupName = getDirectory(name); String variableName = getName(name); Group group = getGroup(groupName); Variable variable = group.findVariable(variableName); Hashtable<String, Object> toReturn = new Hashtable<String, Object>(); if (variable != null) { List<Attribute> attributes = variable.getAttributes(); for (Attribute attribute: attributes) { toReturn.put(attribute.getName(), arrayToString(attribute.getValues())); } } return toReturn; }
@Override public Hashtable<String, Object> getVariableAttributes(String name) { String groupName = getDirectory(name); String variableName = getName(name); Group group = getGroup(groupName); Variable variable = group.findVariable(variableName); Hashtable<String, Object> toReturn = new Hashtable<String, Object>(); if (variable != null) { List<Attribute> attributes = variable.getAttributes(); for (Attribute attribute: attributes) { toReturn.put(attribute.getName(), arrayToString(attribute.getValues())); } } return toReturn; }
/** converts a ucar.nc2.Attribute into an ncsa.hdf.object.Attribute */ public static ncsa.hdf.object.Attribute convertAttribute( ucar.nc2.Attribute netcdfAttr) { ncsa.hdf.object.Attribute ncsaAttr = null; if (netcdfAttr == null) { return null; } String attrName = netcdfAttr.getName(); long[] attrDims = { netcdfAttr.getLength() }; Datatype attrType = new NC2Datatype(netcdfAttr.getDataType()); ncsaAttr = new ncsa.hdf.object.Attribute(attrName, attrType, attrDims); ncsaAttr.setValue(netcdfAttr.getValues()); return ncsaAttr; }
String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); Attribute useAtt; if (att.isArray()) String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues()); String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues());
String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); Attribute useAtt; if (att.isArray()) String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues()); String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues());
String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); Attribute useAtt; if (att.isArray()) String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues()); String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues());
String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); Attribute useAtt; if (att.isArray()) String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues()); String useName = N3iosp.makeValidNetcdfObjectName(att.getName()); if (att.isArray()) ncfile.addVariableAttribute(varName, useName, att.getValues());