/** * Amend the given NetcdfFile with metadata from HDF-EOS structMetadata. * All Variables named StructMetadata.n, where n= 1, 2, 3 ... are read in and their contents concatenated * to make the structMetadata String. * * @param ncfile Amend this file * @param eosGroup the group containing variables named StructMetadata.* * @throws IOException on read error * @return true if HDF-EOS info was found */ static public boolean amendFromODL(NetcdfFile ncfile, Group eosGroup) throws IOException { String smeta = getStructMetadata(eosGroup); if (smeta == null) return false; HdfEos fixer = new HdfEos(); fixer.fixAttributes(ncfile.getRootGroup()); fixer.amendFromODL(ncfile, smeta); return true; }
private 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 getEosInfo(Formatter f) throws IOException { HdfEos.getEosInfo(ncfile, ncfile.getRootGroup(), f); }
Group swathGroup = findGroupNested(rootg, swathName); featureType = amendSwath(ncfile, elemSwath, swathGroup); } else { log.warn("Cant find swath group {} {}", swathName, ncfile.getLocation()); Group gridGroup = findGroupNested(rootg, gridName); featureType = amendGrid(elemGrid, ncfile, gridGroup, ncfile.getLocation()); } else { log.warn("Cant find Grid group {} {}", gridName, ncfile.getLocation()); Group ptGroup = findGroupNested(rootg, name);
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(); }
parent.addVariable(crs); addAttributeIfExists(gridElem, HDFEOS_CRS_Projection, crs, false); addAttributeIfExists(gridElem, HDFEOS_CRS_UpperLeft, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_LowerRight, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_ProjParams, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_SphereCode, crs, false); setSharedDimensions( v, values, unknownDims, location); setSharedDimensions( v, values, unknownDims, location);
AxisType axis = addAxisType(ncfile, v); if (axis == AxisType.Lat) latAxis = v; if (axis == AxisType.Lon) lonAxis = v; setSharedDimensions( v, values, unknownDims, ncfile.getLocation()); if (showWork) System.out.printf(" set coordinate %s %n", v); setSharedDimensions( v, values, unknownDims, ncfile.getLocation());
private void fixAttributes(Group g) { for (Variable v : g.getVariables()) { for (Attribute a : v.getAttributes()) { if (a.getShortName().equalsIgnoreCase("UNIT") || a.getShortName().equalsIgnoreCase("UNITS")) a.setShortName(CDM.UNITS); if (a.getShortName().equalsIgnoreCase("SCALE_FACTOR")) a.setShortName(CDM.SCALE_FACTOR); if (a.getShortName().equalsIgnoreCase("OFFSET")) a.setShortName(CDM.ADD_OFFSET); } } for (Group ng : g.getGroups()) { fixAttributes(ng); } }
Dimension oldDim = oldDims.get(i); if (dim == null) dim = checkUnknownDims(dimName, unknownDims, oldDim, location);
Group swathGroup = findGroupNested(rootg, swathName); featureType = amendSwath(ncfile, elemSwath, swathGroup); } else { log.warn("Cant find swath group {} {}", swathName, ncfile.getLocation()); Group gridGroup = findGroupNested(rootg, gridName); featureType = amendGrid(elemGrid, ncfile, gridGroup, ncfile.getLocation()); } else { log.warn("Cant find Grid group {} {}", gridName, ncfile.getLocation()); Group ptGroup = findGroupNested(rootg, name);
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(); }
parent.addVariable(crs); addAttributeIfExists(gridElem, HDFEOS_CRS_Projection, crs, false); addAttributeIfExists(gridElem, HDFEOS_CRS_UpperLeft, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_LowerRight, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_ProjParams, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_SphereCode, crs, false); setSharedDimensions(v, values, unknownDims, location); setSharedDimensions(v, values, unknownDims, location);
AxisType axis = addAxisType(ncfile, v); if (axis == AxisType.Lat) { latAxis = v; } if (axis == AxisType.Lon) { lonAxis = v; } setSharedDimensions( v, values, unknownDims, ncfile.getLocation()); if (showWork) { log.debug(" set coordinate {}", v); setSharedDimensions(v, values, unknownDims, ncfile.getLocation());
private void fixAttributes(Group g) { for (Variable v : g.getVariables()) { for (Attribute a : v.getAttributes()) { if (a.getShortName().equalsIgnoreCase("UNIT")) a.setShortName(CDM.UNITS); if (a.getShortName().equalsIgnoreCase("SCALE_FACTOR")) a.setShortName(CDM.SCALE_FACTOR); if (a.getShortName().equalsIgnoreCase("OFFSET")) a.setShortName(CDM.ADD_OFFSET); } } for (Group ng : g.getGroups()) { fixAttributes(ng); } }
Dimension oldDim = oldDims.get(i); if (dim == null) { dim = checkUnknownDims(dimName, unknownDims, oldDim, location);
/** * Amend the given NetcdfFile with metadata from HDF-EOS structMetadata. * All Variables named StructMetadata.n, where n= 1, 2, 3 ... are read in and their contents concatenated * to make the structMetadata String. * * @param ncfile Amend this file * @param eosGroup the group containing variables named StructMetadata.* * @throws IOException on read error * @return true if HDF-EOS info was found */ static public boolean amendFromODL(NetcdfFile ncfile, Group eosGroup) throws IOException { String smeta = getStructMetadata(eosGroup); if (smeta == null) return false; HdfEos fixer = new HdfEos(); fixer.amendFromODL(ncfile, smeta); fixer.fixAttributes(ncfile.getRootGroup()); return true; }
Group swathGroup = findGroupNested(rootg, swathName); featureType = amendSwath(ncfile, elemSwath, swathGroup); } else { log.warn("Cant find swath group {} {}", swathName, ncfile.getLocation()); Group gridGroup = findGroupNested(rootg, gridName); featureType = amendGrid(elemGrid, ncfile, gridGroup, ncfile.getLocation()); } else { log.warn("Cant find Grid group {} {}", gridName, ncfile.getLocation()); Group ptGroup = findGroupNested(rootg, name);
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(); }
parent.addVariable(crs); addAttributeIfExists(gridElem, HDFEOS_CRS_Projection, crs, false); addAttributeIfExists(gridElem, HDFEOS_CRS_UpperLeft, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_LowerRight, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_ProjParams, crs, true); addAttributeIfExists(gridElem, HDFEOS_CRS_SphereCode, crs, false); setSharedDimensions( v, values, unknownDims, location); setSharedDimensions( v, values, unknownDims, location);
AxisType axis = addAxisType(ncfile, v); if (axis == AxisType.Lat) latAxis = v; if (axis == AxisType.Lon) lonAxis = v; setSharedDimensions( v, values, unknownDims, ncfile.getLocation()); if (showWork) System.out.printf(" set coordinate %s %n", v); setSharedDimensions( v, values, unknownDims, ncfile.getLocation());