gpt4 book ai didi

python - Scipy - netcdf - 数据类型不写入并获取奇怪的数字

转载 作者:行者123 更新时间:2023-11-30 23:36:30 25 4
gpt4 key购买 nike

我正在尝试使用 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 ;
}

最佳答案

这是Scipy 0.11.0中的一个错误,在0.12.0中已修复 https://github.com/scipy/scipy/commit/d2b5014

关于python - Scipy - netcdf - 数据类型不写入并获取奇怪的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16451744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com