我有一个900x6502dnumpy数组,我想把它分成10x10块,检查非零元素。有没有一种Python式的方法可以让我用纽比来达到这个目的?在
我正在寻找类似以下功能:
blocks_that_have_stuff = []
my_array = getArray()
my_array.cut_into_blocks((10, 10))
for block_no, block in enumerate(my_array):
if numpy.count_nonzero(block) > 5:
blocks_that_have_stuff.append(block_no)
我写了一个程序把你的矩阵切成块。这个例子很容易理解。我把它写在一个简单的形式,以显示结果(仅用于检查目的)。如果您对它感兴趣,可以在输出中包含块的数量或任何内容。在
输出为:
问候
注意:我想你可以用np.meshgrid公司而是用xextent和yextent添加了很多附录。在
相关问题 更多 >
编程相关推荐