static public Variable findVariableWithAttributeAndDimension(NetcdfDataset ds, String att_name, String att_value, Dimension outer, Formatter errlog) { for (Variable v : ds.getVariables()) { String attValue = ds.findAttValueIgnoreCase(v, att_name, null); if ((attValue != null) && attValue.equalsIgnoreCase(att_value)) { if (v.getRank() > 0 && v.getDimension(0).equals(outer)) return v; if (isEffectivelyScaler(v) && (outer == null)) return v; } } // descend into structures for (Variable v : ds.getVariables()) { if (v instanceof Structure) { Structure s = (Structure) v; if (s.getRank() > 0 && s.getDimension(0).equals(outer) || (s.getRank() == 0 && outer == null)) { for (Variable vs : s.getVariables()) { Attribute att = vs.findAttributeIgnoreCase(att_name); if ((att != null) && att.isString() && att.getStringValue().equalsIgnoreCase(att_value)) return vs; } } } } // failed return null; }
static public Variable findVariableWithAttributeAndDimension(NetcdfDataset ds, String att_name, String att_value, Dimension outer, Formatter errlog) { for (Variable v : ds.getVariables()) { String attValue = ds.findAttValueIgnoreCase(v, att_name, null); if ((attValue != null) && attValue.equalsIgnoreCase(att_value)) { if (v.getRank() > 0 && v.getDimension(0).equals(outer)) return v; if (isEffectivelyScaler(v) && (outer == null)) return v; } } // descend into structures for (Variable v : ds.getVariables()) { if (v instanceof Structure) { Structure s = (Structure) v; if (s.getRank() > 0 && s.getDimension(0).equals(outer) || (s.getRank() == 0 && outer == null)) { for (Variable vs : s.getVariables()) { Attribute att = vs.findAttributeIgnoreCase(att_name); if ((att != null) && att.isString() && att.getStringValue().equalsIgnoreCase(att_value)) return vs; } } } } // failed return null; }