Java Code Examples for ucar.nc2.VariableSimpleIF#getDataType()
The following examples show how to use
ucar.nc2.VariableSimpleIF#getDataType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StationObsDatasetInfo.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Element writeVariable(VariableSimpleIF v) { NcMLWriter ncmlWriter = new NcMLWriter(); 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 for (ucar.nc2.Attribute att : v.attributes()) { varElem.addContent(ncmlWriter.makeAttributeElement(att)); } return varElem; }
Example 2
Source File: FeatureDatasetCapabilitiesWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Element writeVariable(VariableSimpleIF v) { NcmlWriter ncMLWriter = new NcmlWriter(); 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 for (Attribute att : v.attributes()) { varElem.addContent(ncMLWriter.makeAttributeElement(att)); } return varElem; }
Example 3
Source File: FeatureDatasetCapabilitiesWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Element writeVariable(VariableSimpleIF v) { NcmlWriter ncMLWriter = new NcmlWriter(); Element varElem = new Element("variable"); varElem.setAttribute("name", v.getShortName()); DataType dt = v.getDataType(); if (dt != null) varElem.setAttribute("type", dt.toString()); // attributes for (Attribute att : v.attributes()) { varElem.addContent(ncMLWriter.makeAttributeElement(att)); } return varElem; }
Example 4
Source File: WriterCFPointAbstract.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
void addCoordinatesClassic(Dimension recordDim, List<VariableSimpleIF> coords, Set<String> varSet) { addDimensionsClassic(coords); for (VariableSimpleIF oldVar : coords) { List<Dimension> dims = makeDimensionList(oldVar.getDimensions()); dims.add(0, recordDim); Variable.Builder newVar; if (oldVar.getDataType() == DataType.STRING && !this.isExtendedModel) { // What should the string length be ?? Should read variable to find out....see old // writer.addStringVariable(null, (Variable) oldVar, dims) String name = oldVar.getShortName(); Dimension strlen = new Dimension(name + "_strlen", defaultStringLength); newVar = Variable.builder().setName(name).setDataType(DataType.CHAR).setDimensions(dims).addDimension(strlen); writerb.getRootGroup().addDimensionIfNotExists(strlen); } else { newVar = Variable.builder().setName(oldVar.getShortName()).setDataType(oldVar.getDataType()).setDimensions(dims); } if (writerb.getRootGroup().replaceVariable(newVar)) { logger.info("Variable was already added =" + oldVar.getShortName()); } newVar.addAttributes(oldVar.attributes()); varSet.add(oldVar.getShortName()); } }
Example 5
Source File: WriterCFPointAbstract.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addDataVariablesClassic(Dimension recordDim, StructureData stnData, HashSet<String> varSet, String coordVars) { addDimensionsClassic(dataVars); for (StructureMembers.Member m : stnData.getMembers()) { VariableSimpleIF oldVar = findDataVar(m.getName()); if (oldVar == null) continue; List<Dimension> dims = makeDimensionList(oldVar.getDimensions()); dims.add(0, recordDim); Variable.Builder newVar; if (oldVar.getDataType() == DataType.STRING && !isExtendedModel) { // What should the string length be ?? String name = oldVar.getShortName(); Dimension strlen = new Dimension(name + "_strlen", defaultStringLength); newVar = Variable.builder().setName(name).setDataType(DataType.CHAR).setDimensions(dims).addDimension(strlen); writerb.getRootGroup().addDimensionIfNotExists(strlen); } else { newVar = Variable.builder().setName(oldVar.getShortName()).setDataType(oldVar.getDataType()).setDimensions(dims); } if (writerb.getRootGroup().replaceVariable(newVar)) { logger.warn("Variable was already added =" + oldVar.getShortName()); } for (Attribute att : oldVar.attributes()) { String attName = att.getShortName(); if (!reservedVariableAtts.contains(attName) && !attName.startsWith("_Coordinate")) newVar.addAttribute(att); } newVar.addAttribute(new Attribute(CF.COORDINATES, coordVars)); varSet.add(oldVar.getShortName()); } }