- 积分
- 35048
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-5-13
- 最后登录
- 1970-1-1
|
发表于 2021-11-3 18:02:28
|
显示全部楼层
回帖奖励 +10 金钱
本帖最后由 一大碗年糕 于 2021-11-3 18:04 编辑
看到这么多金币激发了我学习的兴趣(不是
short2flt在NCL中描述如下:
Description
This function converts short data to float using the "scale" and "offset" attributes (if present), and preserves metadata.
Other attributes similar to "scale" and "offset" will be recognized:
offset:
"add_offset", "OFFSET", "Offset", "_offset", "Intercept", "intercept"
scale:
"SCALE", "Scale", "_scale", "scale_factor", "Scale_factor", "Slope" , "slope"
Note: this function is slightly different than the built-in set of conversion functions (like floattointeger and shorttobyte), because it requires loading the "contributed.ncl" script and it preserves metadata. It has a slightly different naming style than the built-in functions, just to set it apart from these other functions.
即short2float受scale和offset这两个attributes影响
显然当短型short型解压到float型时需要用的y = x * scale_factor + add_offset
所以问题目测是在合并原始数据时改变了变量的scale和add_offset这两个属性
比如ncl压缩转换函数pack_values中就有设置
the scale_factor (opt@scale_factor) and add_offset (opt@add_offset) values to be used by the function.
解决办法:分别看下两个变量属性,把合并之后的变量的scale和offset属性改成原变量的再用short2float即可。
当然考虑或许这个If the names given do not match any attributes, the scale factor will be assigned a value of 1.0 and the offset will be assigned a value of 0.0. 这种情况也不是没有可能
参考关于scale和offset属性在netcdf中的描述:
scale_factor
If present for a variable, the data are to be multiplied by this factor after the data are read by the application that accesses the data.
add_offset
If present for a variable, this number is to be added to the data after it is read by the application that accesses the data. If both scale_factor and add_offset attributes are present, the data are first scaled before the offset is added. The attributes scale_factor and add_offset can be used together to provide simple data compression to store low-resolution floating-point data as small integers in a netCDF file. When scaled data are written, the application should first subtract the offset and then divide by the scale factor.
When scale_factor and add_offset are used for packing, the associated variable (containing the packed data) is typically of type byte or short, whereas the unpacked values are intended to be of type float or double. The attributes scale_factor and add_offset should both be of the type intended for the unpacked data, e.g. float or double. |
|