我想写一个netcdf文件使用scipy。 我已经从scipy网站上复制了这个例子 - 但是当我看着输出时,我得到了奇怪的数字。scipy --netcdf - 数据类型不写和得到奇怪的数字
我一直在尝试其他的东西,甚至为另一个我声明为'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 ;
}
什么操作系统和你使用的是什么版本的scipy?我无法在Ubuntu上重现此问题,scipy版本为0.9.0或0.12.0。 – unutbu 2013-05-08 23:43:54
看来如果我使用'导入Scientific.IO.NetCDF作为NetCDF'而不是'scipy.io import netcdf' - 我可以使用双精度值并且得到合理的值。不知道它是否会在以后给我更多的数据类型问题。 – dianei 2013-05-09 13:51:04