我正在尝试创建一个 numpy 坐标数组。到目前为止,我一直在使用x_coords, y_coords = numpy.indices((shape)). 但是,现在我想将x_coordsand组合y_coords成一个数组,这样x_coords = thisArray[:,:,0]andy_coords = thisArray[:,:,1]在这种情况下,thisArray 是一个二维数组。有没有一种简单或pythonic的方法来做到这一点?
我最初考虑使用numpy.outer,但这并不能完全满足我的需求。一个可能的想法是沿(第二个?)轴使用索引数组的串联,但这似乎不是一个非常优雅的解决方案。(虽然它可能是这里最干净的一个)。
谢谢!