/** * Look for Axis by Type, assign to TableConfig if found. * Looks for Lat, Lon, Time, Height. * @param nt assign coordinates to this table. * @param ds look in this dataset's "Best" coordinate system. If no CoordSystem, try list of coordinate axes */ static public void findCoords(TableConfig nt, NetcdfDataset ds) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) findCoords(nt, ds.getCoordinateAxes()); else findCoords(nt, use.getCoordinateAxes()); }
/** * Look for Axis by Type and test against a predicate * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. * @param p match this predicate; may be null * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype, Predicate p) { // try the "best" coordinate system CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return null; CoordinateAxis result = findCoordByType(use.getCoordinateAxes(), atype, p); if (result != null) return result; // try all the axes return findCoordByType(ds.getCoordinateAxes(), atype, p); }
/** * search for Axis by Type and test against a predicate * @param ds search in this dataset's "Best" coordinate system. * @param atype search for this type of CoordinateAxis. * @param p match this predicate; may be null * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype, Predicate p) { // try the "best" coordinate system CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return null; CoordinateAxis result = findCoordByType(use.getCoordinateAxes(), atype, p); if (result != null) return result; // try all the axes return findCoordByType(ds.getCoordinateAxes(), atype, p); }
/** * Look for Axis by Type and test against a predicate * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. * @param p match this predicate * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype, Predicate p) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return null; // try the "best" cs for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) if (p.match(axis)) return axis; } // try all the axes for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == atype) if (p.match(axis)) return axis; } return null; }
/** * Look for Axis by Type. * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. takes the first one it finds. * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use != null) { // first look for matching AxisType and "CF axis" attribute for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) { Attribute att = axis.findAttribute(CF.AXIS); if (att != null && att.getStringValue().equals(atype.getCFAxisName())) return axis; } } // now match on just the AxisType for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) return axis; } } // try all the axes for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == atype) return axis; } return null; }
static public void findCoordWithDimension(TableConfig nt, NetcdfDataset ds, Dimension outer) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return; for (CoordinateAxis axis : use.getCoordinateAxes()) { if (!outer.equals(axis.getDimension(0))) continue; if (axis.getAxisType() == AxisType.Lat) nt.lat = axis.getShortName(); else if (axis.getAxisType() == AxisType.Lon) nt.lon = axis.getShortName(); else if (axis.getAxisType() == AxisType.Time) nt.time = axis.getShortName(); else if (axis.getAxisType() == AxisType.Height) nt.elev = axis.getShortName(); else if (axis.getAxisType() == AxisType.Pressure) nt.elev = axis.getShortName(); } }