NetCDF中scale_factor和add_offset的使用

来源:互联网 发布:云计算大数据什么意思 编辑:程序博客网 时间:2024/06/15 16:22

参考连接: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,数据文件的大小会不同,数据由于压缩会损失精度。

0 0
原创粉丝点击