@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));
}