当前位置: 首页>>代码示例>>Java>>正文


Java Variable.getAttributes方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:24,代码来源:NetCdfWriter.java

示例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);
        }
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:48,代码来源:NetCdfWriter.java


注:本文中的ucar.nc2.Variable.getAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。