ValueError: object too deep for desired array (netcdf)

ValueError: object too deep for desired array (netcdf)

我正在尝试将 SIFT 功能传递给 netcdf 文件,但是当我尝试这样做时它显示了以下错误(我正在使用 Ubuntu 15.10 并在 python 中编码) .

File "/home/Research/netcdf_helpers.py", line 15, in createNcVar nc_var.assignValue(data) ValueError: object too deep for desired array

我搜索了各种解决方案,但仍然找到了正确的解决方案。

目前我的数据结构格式如下:

[[(file1feature1,file1feature2,file1feature3,file1feature4,file1feature5),(file2feature1,file2feature2,file2feature3,file2feature4,file2feature5)(file3feature1,file3feature2,file3feature3,file3feature4,file3feature5)]]

我希望实现的期望输出如下:

[file1feature1,file1feature2,file1feature3,file1feature4,file2feature5,file2feature1,file2feature2,file2feature3,file2feature4.......]

我花了半天的时间来纠正这个错误,但仍在挣扎。任何帮助将不胜感激。

示例:

为了模仿您的数据结构,我使用了以下数据:

raw_data = [[(1, 2, 3), (9, 8, 7), (5, 6, 0)]]]  # this is the raw data

以下操作实现您想要的结构:

data = () # place holder for your filtered data

for entry in raw_data[0]:  # operation
    data += entry

输出:

print(list(data)) # [1, 2, 3, 9, 8, 7, 5, 6, 0]