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


Java DataType.FLOAT属性代码示例

本文整理汇总了Java中ucar.ma2.DataType.FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.FLOAT属性的具体用法?Java DataType.FLOAT怎么用?Java DataType.FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ucar.ma2.DataType的用法示例。


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

示例1: read

/**
 * 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) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0) {
        return null;
    }
    int[] shape = new int[1];
    shape[0] = this.stNum;
    DataType dt = DataType.FLOAT;
    if (varName.equals("Stid"))
        dt = DataType.STRING;
    Array r = Array.factory(dt, shape);
    List<String> dataList;
    for (int i = 0; i < _dataList.size(); i++) {
        dataList = _dataList.get(i);
        r.setFloat(i, Float.parseFloat(dataList.get(varIdx)));
    }
    
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:29,代码来源:MICAPS3DataInfo.java

示例2: arrayRange1

/**
 * Array range
 *
 * @param start Start value
 * @param length Length
 * @param step Step value
 * @return Array
 */
public static Array arrayRange1(Number start, final int length, final Number step) {
    DataType dataType = ArrayUtil.objectsToType(new Object[]{
        start,
        step});
    double startv = start.doubleValue();
    double stepv = step.doubleValue();
    Array a = Array.factory(dataType, new int[]{length});
    if (dataType == DataType.FLOAT || dataType == DataType.DOUBLE) {
        for (int i = 0; i < length; i++) {
            a.setObject(i, BigDecimalUtil.add(BigDecimalUtil.mul(i, stepv), startv));
        }
    } else {
        for (int i = 0; i < length; i++) {
            a.setObject(i, i * stepv + startv);
        }
    }
    return a;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:26,代码来源:ArrayUtil.java

示例3: netcdfTypeFromJDBCType

public DataType netcdfTypeFromJDBCType(int col, ResultSetMetaData resultSetMetadata) throws SQLException {
    int columnType = resultSetMetadata.getColumnType(col);
    if (columnType == Types.DOUBLE) {
        return DataType.DOUBLE;
    } else if ( columnType == Types.FLOAT) {
        return DataType.FLOAT;
    } else if ( columnType == Types.REAL) {
        return DataType.FLOAT;
    } else if ( columnType == Types.INTEGER) {
        return DataType.INT;
    } else if ( columnType == Types.DECIMAL) {
        return DataType.FLOAT;
    } else if ( columnType == Types.SMALLINT) {
        return DataType.SHORT;
    } else if ( columnType == Types.TINYINT) {
        return DataType.BYTE;
    } else if ( columnType == Types.NUMERIC) {
        if ( resultSetMetadata.getScale(col) < 0) {
           return DataType.DOUBLE;
        }
        else if ( resultSetMetadata.getScale(col) > 0 &&
                  resultSetMetadata.getPrecision(col) > 0 ) {
           return DataType.DOUBLE;
        } else if ( resultSetMetadata.getScale(col) == 0 && 
                    resultSetMetadata.getPrecision(col) > 0 ) {
           return DataType.INT;
        } else {
           return DataType.DOUBLE;
        }
    } else if ( columnType == Types.CHAR || columnType == Types.VARCHAR) {
        return DataType.CHAR;
    } else {
        return DataType.CHAR;
    }
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:35,代码来源:IntermediateNetcdfFile.java

示例4: arrayRange

/**
 * Array range
 *
 * @param start Start value
 * @param stop Stop value
 * @param step Step value
 * @return Array
 */
public static Array arrayRange(Number start, Number stop, final Number step) {
    if (stop == null) {
        stop = start;
        start = 0;
    }
    DataType dataType = ArrayUtil.objectsToType(new Object[]{
        start,
        stop,
        step});
    double startv = start.doubleValue();
    double stopv = stop.doubleValue();
    double stepv = step.doubleValue();
    List<Object> data = new ArrayList<>();        
    if (dataType == DataType.FLOAT || dataType == DataType.DOUBLE) {
        while (startv < stopv) {
            data.add(startv);
            startv = BigDecimalUtil.add(startv, stepv);
        }
    } else {
        while (startv < stopv) {
            data.add(startv);
            startv += stepv;
        }
    }
    int length = data.size();
    Array a = Array.factory(dataType, new int[]{length});
    for (int i = 0; i < length; i++){
        a.setObject(i, data.get(i));
    }
    return a;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:39,代码来源:ArrayUtil.java

示例5: arrayRange_bak

/**
 * Array range
 *
 * @param start Start value
 * @param stop Stop value
 * @param step Step value
 * @return Array
 */
public static Array arrayRange_bak(Number start, Number stop, final Number step) {
    if (stop == null) {
        stop = start;
        start = 0;
    }
    DataType dataType = ArrayUtil.objectsToType(new Object[]{
        start,
        stop,
        step});
    double startv = start.doubleValue();
    double stopv = stop.doubleValue();
    double stepv = step.doubleValue();
    final int length = Math.max(0, (int) Math.ceil((stopv
            - startv) / stepv));
    Array a = Array.factory(dataType, new int[]{length});
    if (dataType == DataType.FLOAT || dataType == DataType.DOUBLE) {
        for (int i = 0; i < length; i++) {
            a.setObject(i, BigDecimalUtil.add(BigDecimalUtil.mul(i, stepv), startv));
        }
    } else {
        for (int i = 0; i < length; i++) {
            a.setObject(i, i * stepv + startv);
        }
    }
    return a;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:34,代码来源:ArrayUtil.java

示例6: toDataType

/**
 * To data type - ucar.ma2
 *
 * @param dt Data type string
 * @return Data type
 */
public static DataType toDataType(String dt) {
    if (dt.contains("%")) {
        dt = dt.split("%")[1];
    }
    switch (dt.toLowerCase()) {
        case "c":
        case "s":
        case "string":
            return DataType.STRING;
        case "b":
        case "byte":
            return DataType.BYTE;
        case "short":
            return DataType.SHORT;
        case "i":
        case "int":
            return DataType.INT;
        case "f":
        case "float":
            return DataType.FLOAT;
        case "d":
        case "double":
            return DataType.DOUBLE;
        default:
            return DataType.OBJECT;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:33,代码来源:ArrayUtil.java

示例7: getDataType

/**
 * Get data type
 *
 * @param o Object
 * @return Data type
 */
public static DataType getDataType(Object o) {
    if (o instanceof Integer) {
        return DataType.INT;
    } else if (o instanceof Float) {
        return DataType.FLOAT;
    } else if (o instanceof Double) {
        return DataType.DOUBLE;
    } else {
        return DataType.OBJECT;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:17,代码来源:ArrayMath.java

示例8: read

/**
 * 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) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0) {
        return null;
    }

    DataType dt = DataType.FLOAT;
    switch (varName) {
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this.stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;
    List<String> dataList;
    //List<List<String>> allDataList = this.readData();

    for (i = 0; i < this.stNum; i++) {
        dataList = this._dataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                r.setFloat(i, v);
                break;
        }
    }

    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:52,代码来源:MICAPS2DataInfo.java

示例9: read

/**
 * 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) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0)
        return null;
    
    DataType dt = DataType.FLOAT;
    switch (varName){
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this.stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;       
    List<String> dataList;

    for (i = 0; i < _dataList.size(); i++) {
        dataList = _dataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                r.setFloat(i, v);
                break;
        }
    }
    
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:50,代码来源:MICAPS120DataInfo.java

示例10: read

/**
 * 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) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0) {
        return null;
    }

    DataType dt = DataType.FLOAT;
    switch (varName) {
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
        case "CloudCover":
        case "WeatherPast1":
        case "WeatherPast2":
        case "WeatherNow":
        case "MiddleCloudShape":
        case "HighCloudShape":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this._stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;
    List<String> dataList;
    List<List<String>> allDataList = this.readData();

    for (i = 0; i < allDataList.size(); i++) {
        dataList = allDataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                if (varIdx == 8) //Pressure
                {
                    if (!MIMath.doubleEquals(v, this.getMissingValue())) {
                        if (v > 800) {
                            v = v / 10 + 900;
                        } else {
                            v = v / 10 + 1000;
                        }
                    }
                }
                r.setFloat(i, v);
                break;
        }
    }
    try {
        r = r.section(origin, shape, stride);
    } catch (InvalidRangeException ex) {
        Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
    }

    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:73,代码来源:MICAPS1DataInfo.java


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