/** * Utility method for getting NoData from an input {@link Variable} * * @param var Variable instance * @return a Number representing NoData */ public static Number getNodata(Variable var) { if (var != null) { // Getting all the Variable attributes List<Attribute> attributes = var.getAttributes(); String fullName; // Searching for FILL_VALUE or MISSING_VALUE attributes for (Attribute attribute : attributes) { fullName = attribute.getFullName(); if (fullName.equalsIgnoreCase(FILL_VALUE) || fullName.equalsIgnoreCase(MISSING_VALUE)) { return attribute.getNumericValue(); } } } return null; }
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 static Attribute findCDMAtt(List<Attribute> atts, String attName){ Iterator<Attribute> it = atts.iterator(); Attribute target = null; while( it.hasNext() && target == null ){ Attribute att = it.next(); if( att.getFullName().equals(attName) || att.getShortName().equals(attName)){ target = att; } } return target; } }
public static Attribute findCDMAtt(List<Attribute> atts, String attName){ Iterator<Attribute> it = atts.iterator(); Attribute target = null; while( it.hasNext() && target == null ){ Attribute att = it.next(); if( att.getFullName().equals(attName) || att.getShortName().equals(attName)){ target = att; } } return target; } }
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());
/** * Returns all the metadata related with the experiments as key-value pairs. * * @return */ public Metadata getMetadata(){ HashMap<String, String> globalAttr = new HashMap<String, String>(); for (Attribute attr: inputFile.getGlobalAttributes()) globalAttr.put(attr.getFullName(), attr.getStringValue()); return new Metadata(globalAttr); } }
/** * Utility method for getting NoData from an input {@link Variable} * * @param var Variable instance * @return a Number representing NoData */ public static Number getNodata(Variable var) { if (var != null) { // Getting all the Variable attributes List<Attribute> attributes = var.getAttributes(); String fullName; // Searching for FILL_VALUE or MISSING_VALUE attributes for (Attribute attribute : attributes) { fullName = attribute.getFullName(); if (fullName.equalsIgnoreCase(FILL_VALUE) || fullName.equalsIgnoreCase(MISSING_VALUE)) { return attribute.getNumericValue(); } } } return null; }
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); } }
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); } }
@Test public void problemHugeHeapId() throws IOException { //H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header")); String filename = TestH5.testDir + "SMAP_L4_SM_aup_20140115T030000_V05007_001.h5"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { Group g = ncfile.findGroup("Metadata"); assert g != null; Attribute att = g.findAttribute("iso_19139_dataset_xml"); assert att != null; assert att.isString(); String val = att.getStringValue(); System.out.printf(" len of %s is %d%n", att.getFullName(), val.length()); assert val.length() > 200 * 1000; // silly rabbit } }
for (Attribute att : sourceVar.getAttributes()) { if (var.findAttribute(att.getFullName()) == null && !COPY_ATTRIBUTES_BLACKLIST.contains( att.getShortName())) {
for (Attribute att : sourceVar.getAttributes()) { if (var.findAttribute(att.getFullName()) == null && !isBlacklistedAttribute(att, dataPacking)) { writer.addVariableAttribute(var, att);
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());
Property property = resolveMetadataKey(attr.getFullName()); if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue());