【发布时间】:2017-07-09 11:35:06
【问题描述】:
我使用 netCDF Python 库读取具有 list(variable) 的 netCDF 变量返回正确的十进制精度,如图像中所示(使用 PyCharm IDE)。但是,当我尝试按索引获取元素时,例如:变量 [0],它会返回舍入值(例如:5449865.55794),而我需要 5449865.55793999997。
如何以正确的小数精度迭代此列表?
一些基本代码
from netCDF4 import Dataset
nc_dataset = Dataset(self.get_file().get_filepath(), "r")
variable_name = "E"
// netCDF file contains few variables (axis dimensions)
variable = nc_dataset.variables[variable_name]
variable is not a list but a netCDF object, however when using list() or variable[index] will return element value of the axis dimension.
【问题讨论】:
-
我更新了代码 Jean,不过我不确定这个 netCDF 库。
-
你能提供更多细节吗,克里斯?
标签: python python-2.7 numpy pycharm