Re: Using where() on slices of data cubes [message #68464 is a reply to message #68324] |
Wed, 21 October 2009 14:52  |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Oct 20, 4:32 pm, David Fanning <n...@dfanning.com> wrote:
> JD Smith writes:
>> you should easily be able to generalize the above arguments to access
>> these elements
>
> I think in this case the word "easily" might be
> too subtly sarcastic to be easily appreciated by
> the vast majority of this newsgroup. :-)
(Almost) no sarcasm was intended.
Suppose you have this:
w=where(cube[1,5:*,10:1024] lt 0)
The "slice" is no longer as large as the cube in the yz dimensions,
and is offset by [5,10] too. So
y_full_cube = slice_column + 5
z_full_cube = slice_row + 10
and since the slice is smaller than the cube by 5 columns, to convert
our WHERE index vector w into col,row in the slice, we use
slice_column = w mod (sz[1]-5)
slice_row = w/(sz[1]-5)
Putting it all together we have:
ind = 1 + sz[0] * (5 + w mod (sz[1]-5) + (10 + w/(sz[1]-5)) * sz[1])
JD
|
|
|