Python NetCDF:将“填充”读作“填充”

时间:2016-08-23 15:20:39

标签: python netcdf4

我似乎有一个用“填充”创建的netcdf文件。如何阅读“填写”?

也就是说,我真正想要的是自动找出变量丢失的库,因为它似乎与“填充”有关。有没有办法做到这一点?

ipython的输出:

In [1]: import netCDF4 as netcdf

In [2]: nc = netcdf.Dataset("/tmp/somefile.nc")

In [3]: nc.variables["time"]

Out[3]:
<type 'netCDF4._netCDF4.Variable'>
int32 time(event, altitude)
long_name: Msec Since Midnight
units: msec
unlimited dimensions: 
current shape = (43627, 372)
filling off

In [4]: nc.variables["time"][:]

Out[4]: 
array([[   86441314,    86441359,    86441404, ...,    86457871,
       86457915, -2147483647],
   [   86502423,    86502378,    86502332, ...,    86485825,
       86485737, -2147483647],
   [   86557293,    86557337,    86557383, ...,    86573857,
       86573906, -2147483647],
   ..., 
   [   86355650,    86355607,    86355560, ...,    86338941,
       86338895,    86338848]], dtype=int32)

In [5]: netcdf.default_fillvals["i4"]

Out[5]: -2147483647

-2147483647中的Out[4]应该是缺失值(--)。

ncdump似乎想通了,我希望(_):

ncdump /tmp/somefile.nc

ncdump的输出:

....
time =
....
86457636, 86457685, 86457733, 86457779, 86457824, 86457871, 86457915, _,
....

0 个答案:

没有答案