static public VariableSimpleImpl changeShape(VariableSimpleIF proxy, List<Dimension> dims) { VariableSimpleImpl result = new VariableSimpleImpl(proxy.getShortName(), proxy.getDescription(), proxy.getUnitsString(), proxy.getDataType(), dims); for (Attribute att : proxy.getAttributes()) result.add(att); return result; }
public ucar.nc2.Attribute findAttributeIgnoreCase(String attName){ return v.findAttributeIgnoreCase(attName); }
protected void addCoordinatesExtended(Structure parent, List<VariableSimpleIF> coords) throws IOException { for (VariableSimpleIF vs : coords) { String dims = Dimension.makeDimensionsString(vs.getDimensions()); Variable member = writer.addStructureMember(parent, vs.getShortName(), vs.getDataType(), dims); if (member == null) { logger.warn("Variable already exists =" + vs.getShortName()); // LOOK barf continue; } for (Attribute att : vs.getAttributes()) member.addAttribute(att); } }
private void addDataVariables(List<VariableSimpleIF> list, Table t) { if (t.parent != null) addDataVariables(list, t.parent); for (VariableSimpleIF col : t.cols.values()) { if (t.nondataVars.contains(col.getFullName())) continue; if (t.nondataVars.contains(col.getShortName())) continue; // fishy list.add(col); } }
public ThreddsMetadata.VariableGroup extractVariables(FeatureDatasetPoint fd) { List<ThreddsMetadata.Variable> vars = new ArrayList<>(); List<VariableSimpleIF> dataVars = fd.getDataVariables(); if (dataVars == null) return null; for (VariableSimpleIF v : dataVars) { String name = v.getShortName(); String desc = v.getDescription(); String units = v.getUnitsString(); String vname = null; String id = null; ucar.nc2.Attribute att = v.findAttributeIgnoreCase("standard_name"); if (att != null) vname = att.getStringValue(); vars.add(new ThreddsMetadata.Variable(name, desc, vname, units, id)); } Collections.sort(vars); // String vocab, String vocabHref, URI vocabUri, URI mapUri, List<Variable> variables return new ThreddsMetadata.VariableGroup("CF-1.0", null, null, vars); }
protected void replaceDataVars(StructureMembers sm) { for (StructureMembers.Member m : sm.getMembers()) { VariableSimpleIF org = this.cols.get(m.getName()); int rank = org.getRank(); List<Dimension> orgDims = org.getDimensions(); // only keep the last n int n = m.getShape().length; List<Dimension> dims = orgDims.subList(rank-n, rank); VariableSimpleImpl result = new VariableSimpleImpl(org.getShortName(), org.getDescription(), org.getUnitsString(), org.getDataType(), dims); for (Attribute att : org.getAttributes()) result.add(att); this.cols.put(m.getName(), result); } }
private Element writeVariable(VariableSimpleIF v) { Element varElem = new Element("variable"); varElem.setAttribute("name", v.getShortName()); ucar.ma2.DataType dt = v.getDataType(); if (dt != null) varElem.setAttribute("type", dt.toString()); // attributes Iterator atts = v.getAttributes().iterator(); while (atts.hasNext()) { ucar.nc2.Attribute att = (ucar.nc2.Attribute) atts.next(); varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); } return varElem; }
@Override public int compareTo(VariableSimpleIF o) { return name.compareTo(o.getShortName()); // ?? } }
public String getName() { return v.getFullName(); } public String getShortName() { return v.getShortName(); }
public List<Dimension> getDimensions() { return v.getDimensions(); } public List<Attribute> getAttributes() { return v.getAttributes(); }
public String getDescription() { return v.getDescription(); } public String getInfo() { return v.toString(); }
public String getUnitsString() { return v.getUnitsString(); }
public List<Attribute> getAttributes() { return v.getAttributes(); } public ucar.nc2.Attribute findAttributeIgnoreCase(String attName){
public DataType getDataType() { return v.getDataType(); } public String getDescription() { return v.getDescription(); }
public int getRank() { return v.getRank(); } public int[] getShape() { return v.getShape(); }
public int[] getShape() { return v.getShape(); } public List<Dimension> getDimensions() { return v.getDimensions(); }
static public ThreddsMetadata.Variables extractVariables(FeatureDatasetPoint fd) { ThreddsMetadata.Variables vars = new ThreddsMetadata.Variables("CF-1.5"); List<VariableSimpleIF> dataVars = fd.getDataVariables(); if (dataVars == null) return vars; for (VariableSimpleIF v : dataVars) { ThreddsMetadata.Variable tv = new ThreddsMetadata.Variable(); vars.addVariable(tv); tv.setName(v.getShortName()); tv.setDescription(v.getDescription()); tv.setUnits(v.getUnitsString()); ucar.nc2.Attribute att = v.findAttributeIgnoreCase("standard_name"); if (att != null) tv.setVocabularyName(att.getStringValue()); } vars.sort(); return vars; }
private Element writeVariable(VariableSimpleIF v) { Element varElem = new Element("variable"); varElem.setAttribute("name", v.getShortName()); ucar.ma2.DataType dt = v.getDataType(); if (dt != null) varElem.setAttribute("type", dt.toString()); // attributes Iterator atts = v.getAttributes().iterator(); while (atts.hasNext()) { ucar.nc2.Attribute att = (ucar.nc2.Attribute) atts.next(); varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); } return varElem; }
public VariableSimpleIF getDataVariable(String shortName) { for (VariableSimpleIF s : dataVariables) { String ss = s.getShortName(); if (shortName.equals(ss)) return s; } return null; }
private void addDataVariables(List<VariableSimpleIF> list, Table t) { if (t.parent != null) addDataVariables(list, t.parent); for (VariableSimpleIF col : t.cols.values()) { if (t.nondataVars.contains(col.getFullName())) continue; if (t.nondataVars.contains(col.getShortName())) continue; // fishy list.add(col); } }