HashMap<AxisType, VarProcess> map = new HashMap<AxisType, VarProcess>();
// find existing axes, so we dont duplicate
for (VarProcess vp : varList) {
if (vp.isCoordinateAxis) {
AxisType atype = getAxisType(ds, (VariableEnhanced) vp.v);
if (atype != null)
map.put(atype, vp);
}
}
// look for time axes based on units
if (map.get(AxisType.Time) == null) {
for (VarProcess vp : varList) {
Variable ncvar = vp.v;
if (!(ncvar instanceof VariableDS)) continue; // cant be a structure
String unit = ncvar.getUnitsString();
if (SimpleUnit.isDateUnit(unit)) {
vp.isCoordinateAxis = true;
map.put(AxisType.Time, vp);
parseInfo.format(" Time Coordinate Axis added (unit) = %s from unit %s\n", vp.v.getFullName(), unit);
//break; // allow multiple time coords
}
}
}
// look for missing axes by using name hueristics
for (VarProcess vp : varList) {
if (vp.isCoordinateVariable) continue;
Variable ncvar = vp.v;
if (!(ncvar instanceof VariableDS)) continue; // cant be a structure
AxisType atype = getAxisType(ds, (VariableEnhanced) vp.v);
if (atype != null) {
if (map.get(atype) == null) {
vp.isCoordinateAxis = true;
parseInfo.format(" Coordinate Axis added (Default forced) = %s for axis %s\n", vp.v.getFullName(), atype);
map.put(atype, vp);