本文整理汇总了Java中ucar.nc2.Variable.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Variable.getAttributes方法的具体用法?Java Variable.getAttributes怎么用?Java Variable.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ucar.nc2.Variable
的用法示例。
在下文中一共展示了Variable.getAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyAttributes
import ucar.nc2.Variable; //导入方法依赖的package包/类
/**
* Copies attributes of a variable to another variable.
*
* @param src variable to copy from
* @param dest variable to copy to
* @param overwrite the overwrite
*/
public static void copyAttributes(Variable src, Variable dest, boolean overwrite) {
if ((src == null) || (dest == null)) {
return;
}
List<Attribute> attributes = src.getAttributes();
for (Attribute att : attributes) {
if (!overwrite) {
if (dest.findAttributeIgnoreCase(att.getName()) == null) {
continue;
}
}
dest.addAttribute(new Attribute(att.getName(), att));
}
}
示例2: writeVariable
import ucar.nc2.Variable; //导入方法依赖的package包/类
/**
* Add a Variable to the file. The data is also copied when finish() is called.
*
* @param var copy this Variable (not the data)
* @param varAttrToRemove variable attribute to remove
* @throws MotuException the motu exception
*/
public void writeVariable(Variable var, String[] varAttrToRemove) throws MotuException {
// Dimension[] dims = new Dimension[oldVar.getRank()];
List<Dimension> dims = new ArrayList<Dimension>();
List<Dimension> dimvList = var.getDimensions();
for (Dimension dim : dimvList) {
Dimension dimToWrite = dimHash.get(dim.getName());
if (dimToWrite == null) {
throw new MotuException(
ErrorType.NETCDF_VARIABLE,
String.format("Error in NetCdfWriter writeVariable - Variable %s - Dimension %s must be added first",
var.getName(),
dim.getName()));
}
dims.add(dimToWrite);
}
long d1 = System.nanoTime();
ncfile.addVariable(var.getName(), var.getDataType(), dims);
long d2 = System.nanoTime();
this.writingTime += (d2 - d1);
boolean removeAttr = false;
List<Attribute> attributeList = var.getAttributes();
for (Attribute attribute : attributeList) {
removeAttr = false;
if (varAttrToRemove != null) {
for (String attrToRemove : varAttrToRemove) {
if (attrToRemove.equalsIgnoreCase(attribute.getName())) {
removeAttr = true;
break;
}
}
}
if (!removeAttr) {
writeAttribute(var.getName(), attribute);
}
}
}