我正在尝试使用 scipy 编写 netcdf 文件。我已经从 scipy 网站复制了这个例子——但是当我查看输出时,我得到了奇怪的数字。
我也一直在尝试其他事情,甚至为我声明为“float32”的另一个变量指定 .astype(np.float32)。
Python代码:
import numpy as np
from pylab import *
from scipy.io import netcdf
f = netcdf.netcdf_file('simple.nc', 'w')
f.history = 'Created for a test'
f.createDimension('time', 10)
time = f.createVariable('time', 'i', ('time',))
time[:] = np.arange(10)
time.units = 'days since 2008-01-01'
f.close()
输出:
ncdump -v time simple.nc
netcdf simple {
dimensions:
time = 10 ;
variables:
int time(time) ;
time:units = "days since 2008-01-01" ;
// global attributes:
:history = "Created for a test" ;
data:
time = 0, 16777216, 33554432, 50331648, 67108864, 83886080, 100663296,
117440512, 134217728, 150994944 ;
}