NetCDF中scale_factor和add_offset的使用

参考连接:http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html

  • 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. (see further discussion under the add_offset attribute)
  • 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.
    The NOAA cooperative standard is more restrictive than the netCDF Users Guide with respect to the use of the scale_factor and add_offset attributes; ambiguities and precision problems related to data type conversions are resolved by these restrictions. If the scale_factor and add_offset attributes are of the same data type as the associated variable no restrictions apply; the unpacked data is assumed to be of the same data type as the packed data. However, if the scale_factor and add_offset attributes are of a different data type than the associated variable (containing the packed data) then in files adhering to this standard the associated variable may only be of type byte, short, or long. The attributes scale_factor and add_offset (which must match in data type) must be of type float or double. The data type of the attributes should match the intended type of the unpacked data. (It is not advised to unpack a long into a float as there is a potential precision loss.)
scale_factor 和 add_offset可以对保存的数据进行压缩。

将对应开关打开后,这两个属性就会生效。(开关默认是打开的,python中对开开关的语法是:***.set_auto_maskandscale(True

千万注意:写入的值跟读取的值完全一致。不用自己计算。

实验中发现调整不同的scale_fator和add_offset,数据文件的大小会不同,数据由于压缩会损失精度。

  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值