Re: Using where() on slices of data cubes [message #68335 is a reply to message #68327] |
Tue, 20 October 2009 07:20   |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
On 20 Okt., 14:22, Conor <cmanc...@gmail.com> wrote:
> I feel like this should be an easy one, but I've never quite figured
> it out. Let's say I got a data cube and I want to do something on
> just a slice of it, say I want to turn certain values in a column into
> something else:
>
> w = where( cube[1,*,*] lt 0 )
>
> It seems like you should be able to do something like this:
>
> cube[1,w] = 1e24
>
> But that doesn't work... Somehow I can't quite figure out the right
> way to do this.
This method avoids the need for any duplication:
w=where(cube[1,*,*] lt 0)
sz=size(cube,/dim)
cube=reform(cube,[sz[0],sz[1]*sz[2]],/overwrite)
cube[1,w]=1e24
cube=reform(cube,sz,/overwrite)
regards,
Greg
|
|
|