Re: Creating a sub array from an array [message #71268] |
Thu, 10 June 2010 10:28 |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
On 10 Jun., 16:27, Fster <francis.colle...@live.co.uk> wrote:
> I have an array in this format
>
> OLR FLOAT = Array[720, 144, 144]
> where 720 = t
> 144 = x and y
>
> I need to create an array for particular extracted values of this
> array where say x has values from 1 to 5 and y has values from 1 to 5.
>
> I'm just not sure on how to perform this, a do loop perhaps? sorry I
> am a complete beginner!
Is this what you're looking for:
subset=olr[*,1:5,1:5]
regards,
Greg
|
|
|
|
Re: Creating a sub array from an array [message #71273 is a reply to message #71269] |
Thu, 10 June 2010 07:38  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Fster writes:
> I have an array in this format
>
> OLR FLOAT = Array[720, 144, 144]
> where 720 = t
> 144 = x and y
>
> I need to create an array for particular extracted values of this
> array where say x has values from 1 to 5 and y has values from 1 to 5.
>
> I'm just not sure on how to perform this, a do loop perhaps? sorry I
> am a complete beginner!
I would do something like this:
xindices = Where(x ge 1 and x le 5, xcount)
yindices = Where(y ge 1 and y le 5, ycount)
CASE 1 OF
xcount gt 0 and ycount eq 0: subOLR = olr[*,xindices,*]
xcount eq 0 and ycount gt 0: subOLR = olr[*,*,yindices]
xcount eq 0 and ycount eq 0: subOLR = olr
xcount gt 0 and ycount gt 0: subOLR = olr[*,xindices,yindices]
ENDCASE
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|