/** * Find a Group, with the specified (full) name. * An embedded "/" is interpreted as separating group names. * * @param fullName eg "/group/subgroup/wantGroup". Null or empty string returns the root group. * @return Group or null if not found. */ public Group findGroup(String fullName) { if (fullName == null || fullName.length() == 0) return rootGroup; Group g = rootGroup; StringTokenizer stoke = new StringTokenizer(fullName, "/"); while (stoke.hasMoreTokens()) { String groupName = NetcdfFile.makeNameUnescaped(stoke.nextToken()); g = g.findGroup(groupName); if (g == null) return null; } return g; }
/** * Find a Group, with the specified (full) name. * An embedded "/" is interpreted as separating group names. * * @param fullName eg "/group/subgroup/wantGroup". Null or empty string returns the root group. * @return Group or null if not found. */ public Group findGroup(String fullName) { if (fullName == null || fullName.length() == 0) return rootGroup; Group g = rootGroup; StringTokenizer stoke = new StringTokenizer(fullName, "/"); while (stoke.hasMoreTokens()) { String groupName = NetcdfFile.makeNameUnescaped(stoke.nextToken()); g = g.findGroup(groupName); if (g == null) return null; } return g; }
/** * Find a Group, with the specified (full) name. * An embedded "/" is interpreted as separating group names. * * @param fullName eg "/group/subgroup/wantGroup". Null or empty string returns the root group. * @return Group or null if not found. */ public Group findGroup(String fullName) { if (fullName == null || fullName.length() == 0) return rootGroup; Group g = rootGroup; StringTokenizer stoke = new StringTokenizer(fullName, "/"); while (stoke.hasMoreTokens()) { String groupName = NetcdfFile.makeNameUnescaped(stoke.nextToken()); g = g.findGroup(groupName); if (g == null) return null; } return g; }
public void getEosInfo(Formatter f) throws IOException { NetcdfFile ncfile = headerParser.ncfile; Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null) { HdfEos.getEosInfo(ncfile, eosInfo, f); } else { f.format("Cant find GROUP '%s'", HdfEos.HDF5_GROUP); } }
public void getEosInfo(Formatter f) throws IOException { NetcdfFile ncfile = headerParser.ncfile; Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null) { HdfEos.getEosInfo(ncfile, eosInfo, f); } else { f.format("Cant find GROUP '%s'", HdfEos.HDF5_GROUP); } }
public void getEosInfo(Formatter f) throws IOException { NetcdfFile ncfile = headerParser.ncfile; Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null) { HdfEos.getEosInfo(ncfile, eosInfo, f); } else { f.format("Cant find GROUP '%s'", HdfEos.HDF5_GROUP); } }
/** * Add a nested Group * * @param g add this Group. */ public void addGroup(Group g) { if (immutable) throw new IllegalStateException("Cant modify"); if (findGroup(g.getShortName()) != null) throw new IllegalArgumentException("Group name (" + g.getShortName() + ") must be unique within Group " + getShortName()); groups.add(g); g.setParentGroup(this); // groups are a tree - only one parent }
/** * Add a nested Group * * @param g add this Group. */ public void addGroup(Group g) { if (immutable) throw new IllegalStateException("Cant modify"); if (findGroup(g.getShortName()) != null) throw new IllegalArgumentException("Group name (" + g.getShortName() + ") must be unique within Group " + getShortName()); groups.add(g); g.setParentGroup(this); // groups are a tree - only one parent }
/** * Add a nested Group * * @param g add this Group. */ public void addGroup(Group g) { if (immutable) throw new IllegalStateException("Cant modify"); if (findGroup(g.getShortName()) != null) throw new IllegalArgumentException("Group name (" + g.getShortName() + ") must be unique within Group " + getShortName()); groups.add(g); g.setParentGroup(this); // groups are a tree - only one parent }
private void addGroupToGroup(Group parent, Group g, Tag tag) { Group groupExisting = parent.findGroup(g.getShortName()); if (groupExisting != null) { g.setName(g.getShortName() + tag.refno); } parent.addGroup(g); }
private void addGroupToGroup(Group parent, Group g, Tag tag) { Group groupExisting = parent.findGroup(g.getShortName()); if (groupExisting != null) { g.setName(g.getShortName() + tag.refno); } parent.addGroup(g); }
private void addGroupToGroup(Group parent, Group g, Tag tag) { Group groupExisting = parent.findGroup(g.getShortName()); if (groupExisting != null) { g.setName(g.getShortName() + tag.refno); } parent.addGroup(g); }
private static boolean checkGroup(Group g) { Variable crs = g.findVariable(HdfEos.HDFEOS_CRS); Group dataG = g.findGroup(DATA_GROUP); if (crs != null && dataG != null) { Attribute att = crs.findAttribute(HdfEos.HDFEOS_CRS_Projection); if (att == null) return false; if (!att.getStringValue().equals("GCTP_SNSOID") && !att.getStringValue().equals("GCTP_GEO")) return false; return !(dataG.findDimensionLocal(DIMX_NAME) == null || dataG.findDimensionLocal(DIMY_NAME) == null); } for (Group ng : g.getGroups()) { if (checkGroup(ng)) return true; } return false; }
private static boolean checkGroup(Group g) { Variable crs = g.findVariable(HdfEos.HDFEOS_CRS); Group dataG = g.findGroup(DATA_GROUP); if (crs != null && dataG != null) { Attribute att = crs.findAttribute(HdfEos.HDFEOS_CRS_Projection); if (att == null) return false; if (!att.getStringValue().equals("GCTP_SNSOID") && !att.getStringValue().equals("GCTP_GEO")) return false; return !(dataG.findDimensionLocal(DIMX_NAME) == null || dataG.findDimensionLocal(DIMY_NAME) == null); } for (Group ng : g.getGroups()) { if (checkGroup(ng)) return true; } return false; }
private static boolean checkGroup(Group g) { Variable crs = g.findVariable(HdfEos.HDFEOS_CRS); Group dataG = g.findGroup(DATA_GROUP); if (crs != null && dataG != null) { Attribute att = crs.findAttribute(HdfEos.HDFEOS_CRS_Projection); if (att == null) return false; if (!att.getStringValue().equals("GCTP_SNSOID") && !att.getStringValue().equals("GCTP_GEO")) return false; if (dataG.findDimensionLocal(DIMX_NAME) == null || dataG.findDimensionLocal(DIMY_NAME) == null) return false; return true; } for (Group ng : g.getGroups()) { if (checkGroup(ng)) return true; } return false; }
public void open(RandomAccessFile raf, ucar.nc2.NetcdfFile ncfile, ucar.nc2.util.CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); headerParser = new H5header(this.raf, ncfile, this); headerParser.read(null); // check if its an HDF5-EOS file Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null && !skipEos) { isEos = HdfEos.amendFromODL(ncfile, eosInfo); } ncfile.finish(); }
public void open(RandomAccessFile raf, ucar.nc2.NetcdfFile ncfile, ucar.nc2.util.CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); headerParser = new H5header(this.raf, ncfile, this); headerParser.read(null); // check if its an HDF5-EOS file Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null && useHdfEos) { isEos = HdfEos.amendFromODL(ncfile, eosInfo); } ncfile.finish(); }
public void open(RandomAccessFile raf, ucar.nc2.NetcdfFile ncfile, ucar.nc2.util.CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); headerParser = new H5header(this.raf, ncfile, this); headerParser.read(null); // check if its an HDF5-EOS file Group eosInfo = ncfile.getRootGroup().findGroup(HdfEos.HDF5_GROUP); if (eosInfo != null && !skipEos) { isEos = HdfEos.amendFromODL(ncfile, eosInfo); } ncfile.finish(); }
@Test public void testForStructMetadata() throws IOException { System.out.printf("TestH4eosReadAll %s%n", filename); try (NetcdfFile ncfile = NetcdfFile.open(filename)) { Group root = ncfile.getRootGroup(); Group g = root.findGroup("HDFEOS INFORMATION"); if (g == null) g = ncfile.getRootGroup(); Variable dset = g.findVariable("StructMetadata.0"); assert (dset != null); } } }
@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")); } }