private ucar.nc2.Attribute findAttribute(Object parent, String name) { if (parent == null) return null; if (parent instanceof Group) return ((Group) parent).findAttribute(name); else if (parent instanceof Variable) return ((Variable) parent).findAttribute(name); return null; }
private ucar.nc2.Attribute findAttribute(Object parent, String name) { if (parent == null) return null; if (parent instanceof Group) return ((Group) parent).findAttribute(name); else if (parent instanceof Variable) return ((Variable) parent).findAttribute(name); return null; }
private ucar.nc2.Attribute findAttribute(Object parent, String name) { if (parent == null) return null; if (parent instanceof Group) return ((Group) parent).findAttribute(name); else if (parent instanceof Variable) return ((Variable) parent).findAttribute(name); return null; }
public Attribute findGlobalAttribute(String attName) { return ncfile.getRootGroup().findAttribute(attName); }
public Attribute findGlobalAttribute(String attName) { return ncfile.getRootGroup().findAttribute(attName); }
@Override protected DecodeQualification getDecodeQualification(NetcdfFile netcdfFile) { Attribute attribute = netcdfFile.getRootGroup().findAttribute("metadata_profile"); if (attribute != null) { String value = attribute.getStringValue(); if (value != null && value.equals("beam")) { return DecodeQualification.INTENDED; } } return DecodeQualification.UNABLE; }
/** * Delete a group Attribute. Must be in define mode. * * @param g the group to add to. if null, use root group * @param attName existing Attribute has this name * @return deleted Attribute, or null if not found */ public Attribute deleteGroupAttribute(Group g, String attName) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); if (g == null) g = ncfile.getRootGroup(); Attribute att = g.findAttribute(attName); if (null == att) return null; g.remove(att); return att; }
/** * Delete a group Attribute. Must be in define mode. * @param g the group to add to. if null, use root group * @param attName existing Attribute has this name * @return deleted Attribute, or null if not found */ public Attribute deleteGroupAttribute(Group g, String attName) { if (!defineMode) throw new UnsupportedOperationException("not in define mode"); if (g == null) g = ncfile.getRootGroup(); Attribute att = g.findAttribute(attName); if (null == att) return null; g.remove(att); return att; }
/** * 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); } }
@Override public String getAttributeValue(String path) { String groupName = getDirectory(path); String attributeName = getName(path); Group group = getGroup(groupName); Attribute attribute = group.findAttribute(attributeName); if (attribute == null) return null; return arrayToString(attribute.getValues()); }
@Override public String getAttributeValue(String path) { String groupName = getDirectory(path); String attributeName = getName(path); Group group = getGroup(groupName); Attribute attribute = group.findAttribute(attributeName); if (attribute == null) return null; return arrayToString(attribute.getValues()); }
public void rewrite() throws IOException, InvalidRangeException { Attribute attr = ncIn.getRootGroup().findAttribute("featureType"); if(attr.getStringValue().contains("RADIAL")) isRadial = true; createGroup(null, ncIn.getRootGroup()); ncOut.create(); transferData(ncIn.getRootGroup()); ncOut.close(); }
public void rewrite() throws IOException, InvalidRangeException { Attribute attr = ncIn.getRootGroup().findAttribute("featureType"); if(attr.getStringValue().contains("RADIAL")) isRadial = true; createGroup(null, ncIn.getRootGroup()); ncOut.create(); transferData(ncIn.getRootGroup()); ncOut.close(); }
@Override public void decode(ProfileReadContext ctx, Product p) throws IOException { for (String attribName : DESCRIPTION_ATTRIBUTE_NAMES) { Attribute attribute = ctx.getNetcdfFile().getRootGroup().findAttribute(attribName); if (attribute != null) { final String description = attribute.getStringValue(); if (description != null) { p.setDescription(description); return; } } } p.setDescription(Constants.FORMAT_DESCRIPTION); }
public void rewrite() throws IOException, InvalidRangeException { Attribute attr = ncIn.getRootGroup().findAttribute("featureType"); if(attr.getStringValue().contains("RADIAL")) isRadial = true; createGroup(null, ncIn.getRootGroup()); ncOut.create(); transferData(ncIn.getRootGroup()); ncOut.close(); }
@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 } }
@org.junit.Test public void testReadH5attributeString() throws IOException { try (NetcdfFile ncfile = TestH5.openH5("support/attstr.h5")) { Group g = ncfile.getRootGroup().findGroup("MyGroup"); assert null != g; Attribute att = g.findAttribute("data_contents"); assert (null != att); assert (!att.isArray()); assert (att.isString()); assert (att.getStringValue().equals("important_data")); } }
@Test public void testReadByName() throws IOException { NetcdfFile ncfile = TestDir.openFileLocal("testSpecialAttributes.nc4"); // Attempt to read special attributes by name for(String name : new String[]{CDM.NCPROPERTIES}) { Attribute special = ncfile.getRootGroup().findAttribute(name); Assert.assertTrue("Could not access special attribute: " + name, special != null && Attribute.isspecial(special)); } ncfile.close(); }