• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IndexIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ucar.ma2.IndexIterator的典型用法代码示例。如果您正苦于以下问题:Java IndexIterator类的具体用法?Java IndexIterator怎么用?Java IndexIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndexIterator类属于ucar.ma2包,在下文中一共展示了IndexIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTimeAxisDataAsString

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Gets time axis data values.
 *
 * @return a list constains time axis data values
 * @throws MotuException the motu exception
 * @throws NetCdfVariableException the net cdf variable exception
 */
public List<String> getTimeAxisDataAsString() throws MotuException {
    List<String> list = new ArrayList<String>();

    Array array = getTimeAxisData();
    if (array == null) {
        return list;
    }

    double datetime = 0.0;

    for (IndexIterator it = array.getIndexIterator(); it.hasNext();) {
        datetime = it.getDoubleNext();
        list.add(0, NetCdfReader.getDateAsGMTNoZeroTimeString(datetime, productMetaData.getTimeAxis().getUnitsString()));
    }

    return list;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:25,代码来源:Product.java


示例2: getZAxisDataAsString

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Gets Z (depth) axis data values.
 *
 * @return a list constains depth axis data values
 * @throws MotuException the motu exception
 * @throws NetCdfVariableException the net cdf variable exception
 */
public List<String> getZAxisDataAsString() throws MotuException, NetCdfVariableException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getZAxisDataAsString() - entering");
    }

    List<String> list = new ArrayList<String>();

    Array array = getZAxisData();

    double depth = 0.0;

    for (IndexIterator it = array.getIndexIterator(); it.hasNext();) {
        depth = it.getDoubleNext();
        list.add(NetCdfReader.getStandardZAsString(depth));
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getZAxisDataAsString() - exiting");
    }
    return list;

}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:30,代码来源:Product.java


示例3: getZAxisDataAsDouble

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Gets the z axis data as double.
 * 
 * @return the z axis data as string
 * 
 * @throws MotuException the motu exception
 * @throws NetCdfVariableException the net cdf variable exception
 */
public List<Double> getZAxisDataAsDouble() throws MotuException, NetCdfVariableException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getZAxisDataAsDouble() - entering");
    }

    List<Double> list = new ArrayList<Double>();

    Array array = getZAxisData();

    double depth = 0.0;

    for (IndexIterator it = array.getIndexIterator(); it.hasNext();) {
        depth = it.getDoubleNext();
        list.add(depth);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getZAxisDataAsDouble() - exiting");
    }
    return list;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:30,代码来源:Product.java


示例4: readXY_1

import ucar.ma2.IndexIterator; //导入依赖的package包/类
private void readXY_1(Range yRange, Range xRange, IndexIterator ii) throws IOException {
    byte[] imageBytes = getIamgeData();

    //Get grid data
    int i, j;
    int xNum = (int) _width;
    int yNum = (int) _height;

    float[] data = new float[yNum * xNum];
    for (i = 0; i < yNum; i++) {
        for (j = 0; j < xNum; j++) {
            data[(yNum - i - 1) * xNum + j] = DataConvert.byte2Int(imageBytes[i * xNum + j]);
        }
    }

    for (int y = yRange.first(); y <= yRange.last();
            y += yRange.stride()) {
        for (int x = xRange.first(); x <= xRange.last();
                x += xRange.stride()) {
            int index = y * xNum + x;
            ii.setFloatNext(data[index]);
        }
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:AWXDataInfo.java


示例5: read

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    try {
        Section section = new Section(origin, size, stride);
        Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
        int rangeIdx = 2;
        Range yRange = section.getRange(rangeIdx++);
        Range xRange = section.getRange(rangeIdx);
        IndexIterator ii = dataArray.getIndexIterator();
        readXY(yRange, xRange, ii);

        return dataArray;
    } catch (InvalidRangeException ex) {
        Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:MICAPS4DataInfo.java


示例6: read

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    try {
        Section section = new Section(origin, size, stride);
        Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
        int rangeIdx = 2;
        Range yRange = section.getRange(rangeIdx++);
        Range xRange = section.getRange(rangeIdx);
        IndexIterator ii = dataArray.getIndexIterator();
        readXY(varName, yRange, xRange, ii);

        return dataArray;
    } catch (InvalidRangeException ex) {
        Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:MICAPS11DataInfo.java


示例7: read

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    try {
        Section section = new Section(origin, size, stride);
        Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
        int rangeIdx = 0;
        Range yRange = section.getRange(rangeIdx++);
        Range xRange = section.getRange(rangeIdx);
        IndexIterator ii = dataArray.getIndexIterator();
        readXY(yRange, xRange, ii);

        return dataArray;
    } catch (InvalidRangeException ex) {
        Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:SurferGridDataInfo.java


示例8: identity

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Return the identity array - a square array with ones on the main
 * diagonal.
 *
 * @param n Number of rows (and columns) in n x n output.
 * @param dtype Data type
 * @return Identity array
 */
public static Array identity(int n, String dtype) {
    DataType dt = toDataType(dtype);
    int[] shape = new int[]{n, n};
    Array a = Array.factory(dt, shape);
    IndexIterator index = a.getIndexIterator();
    int[] current;
    while (index.hasNext()) {
        index.next();
        current = index.getCurrentCounter();
        if (current[0] == current[1]) {
            index.setObjectCurrent(1);
        } else {
            index.setObjectCurrent(0);
        }
    }

    return a;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:ArrayUtil.java


示例9: eye

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Return a 2-D array with ones on the diagonal and zeros elsewhere.
 *
 * @param n Number of rows in the output.
 * @param m Number of columns in the output.
 * @param k Index of the diagonal: 0 (the default) refers to the main
 * diagonal, a positive value refers to an upper diagonal, and a negative
 * value to a lower diagonal.
 * @param dtype Data type
 * @return Created array
 */
public static Array eye(int n, int m, int k, String dtype) {
    DataType dt = toDataType(dtype);
    int[] shape = new int[]{n, m};
    Array a = Array.factory(dt, shape);
    IndexIterator index = a.getIndexIterator();
    int[] current;
    int i, j;
    while (index.hasNext()) {
        index.next();
        current = index.getCurrentCounter();
        i = current[0];
        j = current[1] - k;
        if (i == j) {
            index.setObjectCurrent(1);
        } else {
            index.setObjectCurrent(0);
        }
    }

    return a;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:33,代码来源:ArrayUtil.java


示例10: trapz

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Integrate vector array using the composite trapezoidal rule.
 *
 * @param y Vecotr array
 * @param dx Spacing between all y elements
 * @param ranges
 * @return Definite integral as approximated by trapezoidal rule
 * @throws ucar.ma2.InvalidRangeException
 */
public static double trapz(Array y, double dx, List<Range> ranges) throws InvalidRangeException {
    int n = 1;
    for (Range range : ranges) {
        n = n * range.length();
    }
    n -= 1;
    double a = 1;
    double b = n * dx + a;
    double r = 0;
    double v;
    IndexIterator ii = y.getRangeIterator(ranges);
    int i = 0;
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        r += v;
        if (i > 0 && i < n) {
            r += v;
        }
        i += 1;
    }
    r = r * ((b - a) / (2 * n));
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:33,代码来源:ArrayMath.java


示例11: setSection

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Set section
 *
 * @param a Array a
 * @param ranges Ranges
 * @param v Array value
 * @return Result array
 * @throws InvalidRangeException
 */
public static Array setSection(Array a, List<Range> ranges, Array v) throws InvalidRangeException {
    Array r = a.section(ranges);
    IndexIterator iter = r.getIndexIterator();
    //int[] current;
    Index index = v.getIndex();
    while (iter.hasNext()) {
        iter.next();
        //current = iter.getCurrentCounter();
        //index.set(current);
        iter.setObjectCurrent(v.getObject(index));
        index.incr();
    }
    r = Array.factory(a.getDataType(), a.getShape(), r.getStorage());
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java


示例12: getMinimum

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Get minimum value
 *
 * @param a Array a
 * @return Minimum value
 */
public static double getMinimum(Array a) {
    IndexIterator iter = a.getIndexIterator();
    double min = 1.7976931348623157E+308D;
    while (iter.hasNext()) {
        double val = iter.getDoubleNext();
        if (!Double.isNaN(val)) {
            if (val < min) {
                min = val;
            }
        }
    }
    if (min == 1.7976931348623157E+308D) {
        return Double.NaN;
    } else {
        return min;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:24,代码来源:ArrayMath.java


示例13: getMaximum

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Get maximum value
 *
 * @param a Array a
 * @return Maximum value
 */
public static double getMaximum(Array a) {
    IndexIterator iter = a.getIndexIterator();
    double max = -1.797693134862316E+307D;
    while (iter.hasNext()) {
        double val = iter.getDoubleNext();
        if (!Double.isNaN(val)) {
            if (val > max) {
                max = val;
            }
        }
    }
    if (max == -1.797693134862316E+307D) {
        return Double.NaN;
    } else {
        return max;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:24,代码来源:ArrayMath.java


示例14: sum

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Compute sum value of an array
 *
 * @param a Array a
 * @param ranges Range list
 * @return Sum value
 * @throws ucar.ma2.InvalidRangeException
 */
public static double sum(Array a, List<Range> ranges) throws InvalidRangeException {
    double s = 0.0, v;
    int n = 0;
    IndexIterator ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            s += v;
            n += 1;
        }
    }
    if (n == 0) {            
        s = Double.NaN;
    }
    return s;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java


示例15: aveDouble

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Average array
 *
 * @param a Array a
 * @return Average value
 */
public static double aveDouble(Array a) {
    double sum = 0.0D;
    double v;
    int n = 0;
    IndexIterator iterA = a.getIndexIterator();
    while (iterA.hasNext()) {
        v = iterA.getDoubleNext();
        if (!Double.isNaN(v)) {
            sum += v;
            n += 1;
        }
    }
    if (n == 0) {
        return Double.NaN;
    } else {
        return sum / n;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java


示例16: argMin

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Get the index of the minimum value into the flattened array.
 *
 * @param a Array a
 * @return Minimum value index
 * @throws ucar.ma2.InvalidRangeException
 */
public static int argMin(Array a) throws InvalidRangeException {
    double min = Double.MAX_VALUE, v;
    int idx = 0;
    IndexIterator iterator = a.getIndexIterator();
    int i = 0;
    while (iterator.hasNext()){
        v = iterator.getDoubleNext();
        if (!Double.isNaN(v)){
            if (min > v){
                min = v;
                idx = i;
            }
        }
        i += 1;
    }
    return idx;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java


示例17: argMax

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Get the index of the maximum value into the flattened array.
 *
 * @param a Array a
 * @return Maximum value index
 * @throws ucar.ma2.InvalidRangeException
 */
public static int argMax(Array a) throws InvalidRangeException {
    double max = Double.MIN_VALUE, v;
    int idx = 0;
    IndexIterator iterator = a.getIndexIterator();
    int i = 0;
    while (iterator.hasNext()){
        v = iterator.getDoubleNext();
        if (!Double.isNaN(v)){
            if (max < v){
                max = v;
                idx = i;
            }
        }
        i += 1;
    }
    return idx;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java


示例18: mean

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Compute mean value of an array
 *
 * @param a Array a
 * @param ranges Range list
 * @return Mean value
 * @throws ucar.ma2.InvalidRangeException
 */
public static double mean(Array a, List<Range> ranges) throws InvalidRangeException {
    double mean = 0.0, v;
    int n = 0;
    IndexIterator ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            mean += v;
            n += 1;
        }
    }
    if (n > 0) {
        mean = mean / n;
    } else {
        mean = Double.NaN;
    }
    return mean;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:ArrayMath.java


示例19: initializeMissingData

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Initializes all array elements vith a value.
 * 
 * @param data array to initialize
 * @param fillValue value to set
 */
public static void initializeMissingData(Array data, double fillValue) {

    IndexIterator iter = data.getIndexIterator();
    while (iter.hasNext()) {
        iter.setDoubleNext(fillValue);
    }

}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:15,代码来源:NetCdfReader.java


示例20: getTimeAxisDataAsDate

import ucar.ma2.IndexIterator; //导入依赖的package包/类
/**
 * Gets time axis data values.
 *
 * @return a list constains time axis date values
 * @throws MotuException the motu exception if string to date conversion fails
 * @throws NetCdfVariableException the net cdf variable exception
 */
public List<Date> getTimeAxisDataAsDate() throws MotuException, NetCdfVariableException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getTimeAxisDataAsDate() - entering");
    }
    final DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    final Array array = getTimeAxisData();
    final List<Date> list = new LinkedList<Date>();

    double datetime = 0.0;

    for (IndexIterator it = array.getIndexIterator(); it.hasNext();) {
        datetime = it.getDoubleNext();
        String dateString = NetCdfReader.getDateAsGMTString(datetime, productMetaData.getTimeAxis().getUnitsString());
        try {
            list.add(dateFormatter.parse(dateString));
        } catch (ParseException e) {
            throw new MotuException(
                    ErrorType.INVALID_DATE,
                    "Failed to parse date '" + dateString + "'. Expected format '" + dateFormatter.toString() + "'");
        }
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getTimeAxisDataAsDate() - exiting");
    }
    return list;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:36,代码来源:Product.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParameterizedSingleTypeReference类代码示例发布时间:2022-05-22
下一篇:
Java NodeFactoryManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap