0

我在 MATLAB 中使用相当大的 netcdf 文件,其中包含以下变量:

    tg              
       Size:       272x214x23011
       Dimensions: longitude,latitude,time
       Datatype:   int16
       Attributes:
                   long_name     = 'mean temperature'
                   units         = 'Celsius'
                   standard_name = 'air_temperature'
                   _FillValue    = -1e+004
                   scale_factor  = 0.01

我正在使用 ncread 函数来读取矩阵的块,例如:

data = ncread(netcdfFile,'tg',[1 1 1],[Inf Inf 10]);

前 10 个时间步。如果有足够的内存并且“块”足够小,MATLAB 将以双精度写入“数据”,否则将写入 int16。如果“数据”是双精度,则等于“_FillValue”值的值将转换为 NaN,而如果“数据”在 int16 中,则相同的单元格现在将包含值 -9999。为什么是这样?-1e+004在int16的范围内,那为什么MATLAB写成-9999,而不是-10000呢?

是因为 int16(NaN) = 0,然后落在数据范围内,然后 MATLAB 将默认填充值 -9999 应用于单元格?

有人可以解释发生了什么吗?

4

1 回答 1

0

我相信填充值实际上是-9999。这是一个不幸的显示问题。

>> nccreate('/tmp/t.nc','p','FillValue',-9999)
>> ncdisp /tmp/t.nc
Source:
           /tmp/t.nc
Format:
           netcdf4_classic
Variables:
    p
           Size:       1x1
           Dimensions: 
           Datatype:   double
           Attributes:
                       _FillValue = -1e+04
于 2013-07-02T12:27:09.653 回答