@Override protected DecodeQualification getDecodeQualification(NetcdfFile netcdfFile) { try { Element eosElement = HdfEosUtils.getEosElement(HdfEosUtils.STRUCT_METADATA, netcdfFile.getRootGroup()); // check for GRID if (!HdfEosGridInfo.createGridInfos(eosElement).isEmpty()) { return DecodeQualification.INTENDED; } } catch (Exception ignore) { } return DecodeQualification.UNABLE; }
public static Element getEosElement(String name, Group eosGroup) throws IOException { String smeta = getEosMetadata(name, eosGroup); if (smeta == null) { return null; } smeta = smeta.replaceAll("\\s+=\\s+", "="); smeta = smeta.replaceAll("\\?", "_"); // XML names cannot contain the character "?". StringBuilder sb = new StringBuilder(smeta.length()); StringTokenizer lineFinder = new StringTokenizer(smeta, "\t\n\r\f"); while (lineFinder.hasMoreTokens()) { String line = lineFinder.nextToken().trim(); sb.append(line); sb.append("\n"); } ODLparser parser = new ODLparser(); return parser.parseFromString(sb.toString());// now we have the ODL in JDOM elements }
private ProductData.UTC readEosTime(Element element, String dateElemName, String timeElemName) { String date = HdfEosUtils.getValue(element, "INVENTORYMETADATA", "MASTERGROUP", "RANGEDATETIME", dateElemName, "VALUE"); String time = HdfEosUtils.getValue(element, "INVENTORYMETADATA", "MASTERGROUP", "RANGEDATETIME", timeElemName, "VALUE"); if (date != null && !date.isEmpty() && time != null && !time.isEmpty()) { return TimeUtils.parseDateTime(date + " " + time); } return null; }
@Override protected void initReadContext(ProfileReadContext ctx) throws IOException { Group eosGroup = ctx.getNetcdfFile().getRootGroup(); Element eosElement = HdfEosUtils.getEosElement(HdfEosUtils.STRUCT_METADATA, eosGroup); List<HdfEosGridInfo> gridInfos = HdfEosGridInfo.createGridInfos(eosElement); List<HdfEosGridInfo> compatibleGridInfos = HdfEosGridInfo.getCompatibleGridInfos(gridInfos); if (compatibleGridInfos.isEmpty()) { throw new ProductIOException("Could not find grids."); } List<Group> gridGroups = new ArrayList<Group>(); for (HdfEosGridInfo gridInfo : compatibleGridInfos) { gridGroups.add(HdfEosUtils.findGroupNested(eosGroup, gridInfo.gridName)); } if (gridGroups.isEmpty()) { throw new ProductIOException("Could not find grid group."); } Group[] groups = gridGroups.toArray(new Group[gridGroups.size()]); RasterDigest rasterDigest = RasterDigest.createRasterDigest(groups); ctx.setRasterDigest(rasterDigest); ctx.setProperty(HdfEosUtils.STRUCT_METADATA, eosElement); ctx.setProperty(HdfEosUtils.CORE_METADATA, HdfEosUtils.getEosElement(HdfEosUtils.CORE_METADATA, eosGroup)); ctx.setProperty(HdfEosUtils.ARCHIVE_METADATA, HdfEosUtils.getEosElement(HdfEosUtils.ARCHIVE_METADATA, eosGroup)); }
static Group findGroupNested(Group parent, String name) { for (Group g : parent.getGroups()) { if (g.getShortName().equals(name)) return g; } for (Group g : parent.getGroups()) { Group result = findGroupNested(g, name); if (result != null) return result; } return null; }
public void addGlobalAttributeModisL1B() { Element eosElement = null; try { eosElement = HdfEosUtils.getEosElement("CoreMetadata", ncFile.getRootGroup()); } catch (IOException e) {
@Override public void decode(ProfileReadContext ctx, Product p) throws IOException { Element element = (Element) ctx.getProperty(HdfEosUtils.ARCHIVE_METADATA); if (element != null) { p.setDescription(HdfEosUtils.getValue(element, "ARCHIVEDMETADATA", "MASTERGROUP", "LONGNAME", "VALUE")); } }