[Numpy-discussion] "Advanced indexing" question - subset of data cube as a 2D array.
Ravi
lists_ravi at lavabit.com
Wed Oct 29 12:26:21 EDT 2008
On Wednesday 29 October 2008 01:44:06 Adam wrote:
> In [62]: temp2d = reshape(array3d,[23*337,107])
>
> In [63]: temp2d2 = zeros([23*337,144])
>
> In [64]: temp2d2[:,f.bolo_indices] = temp2d
>
> In [65]: array2d[whscan,:] = temp2d2
>
>
> This works, but it feels wrong to me: I think there should be a way to do
> this by directly indexing array2d with two numpy arrays....
Does numpy.ix_ not fit your use case?
In [2]: y = arange(15).reshape((3,5))
In [3]: y
Out[3]:
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
In [4]: y[ ix_( array([1,2]), array([1,3,4]) ) ]
Out[4]:
array([[ 6, 8, 9],
[11, 13, 14]])
Regards,
Ravi
More information about the NumPy-Discussion
mailing list