comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: For loop avoidance - getting indices of real space
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: For loop avoidance - getting indices of real space [message #81151] Mon, 27 August 2012 03:37 Go to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Thursday, 23 August 2012 22:58:48 UTC+2, simu...@gmail.com wrote:
> I have read and re-read until cross-eyed this post: http://www.idlcoyote.com/tips/forloops.html
>
>
>
> And yet, I still can't quite grasp at how I can solve my for loop problem. I think it might involve the use of modulo (MOD), but I'm not sure how. My question is, how can you grab the indices (i,j,k) of a 3D array in real space, and throw them into basically 3 1D arrays that is just a list of all the cells in the "proper" order (column-major).

There is a perfectly good builtin function in IDL to do this: ARRAY_INDICES.

IDL> nx = 15L
IDL> ny = 10L
IDL> nz = 20L
IDL> data = randomn(seed, nx,ny,nz)
IDL> ai = array_indices(data, lindgen(nx*ny*nz))
IDL>
IDL> help, ai
AI LONG = Array[3, 3000]


If you really need dimensions [3000,3], you can add
IDL> ai = transpose(temporary(ai))

--
Yngvar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How would you measure the range of density on a graph using IDL?
Next Topic: Re: image interplate and overlay lat/lon?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:31:55 PDT 2025

Total time taken to generate the page: 0.00434 seconds