标签: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" << Varf.getDim(0).getSize() << endl; cout << "YSizef" << Varf.getDim(1).getSize() << endl; cout << "ZSizef" << Varf.getDim(2).getSize() << endl; cout << "WSizef" << Varf.getDim(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" << fScale << endl; cout << "add_offset" << fOffset << 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