[原][c++][netcdf]通过c\c++读取字段的scale_factor与add_offset

2021-01-16 10:12

阅读:522

标签:off   c++   varname   offset   lan   tty   reads   amp   编译   

函数:c++

void readScaleAndOffset(const char* FileName,const char* VarName)
{
    NcFile dataFile(FileName, NcFile::read);
    NcVar Varf = dataFile.getVar(VarName);
    //查看维度
    cout "XSizef" 0).getSize()  endl;
    cout "YSizef" 1).getSize()  endl;
    cout "ZSizef" 2).getSize()  endl;
    cout "WSizef" 3).getSize()  endl;

    //查看压缩值
    NcVarAtt AttT = Varf.getAtt("scale_factor");
    NcType TypeT = AttT.getType();
    int TypeId = TypeT.getId();  //float,长度是1
    float fScale = 0.0f;
    AttT.getValues(&fScale);
    AttT = Varf.getAtt("add_offset");
    float fOffset = 0.0f;
    AttT.getValues(&fOffset);
    cout "scale_factor"  endl;
    cout "add_offset"  endl;
}

 

结果:

XSizef1
YSizef30
ZSizef501
WSizef751
scale_factor0.00189809
add_offset-7.62598

 

怎么编译 netcdf-c++?看这里!

[原][c++][netcdf]通过c\c++读取字段的scale_factor与add_offset

标签:off   c++   varname   offset   lan   tty   reads   amp   编译   

原文地址:https://www.cnblogs.com/lyggqm/p/12927292.html


评论


亲,登录后才可以留言!