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

Home » Public Forums » archive » Re: Creating a sub array from an array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Creating a sub array from an array [message #71268] Thu, 10 June 2010 10:28
greg.addr is currently offline  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 #71269 is a reply to message #71268] Thu, 10 June 2010 09:42 Go to previous message
jeanh is currently offline  jeanh
Messages: 79
Registered: November 2009
Member
> xindices = Where(x ge 1 and x le 5, xcount)

> xcount eq 0 and ycount eq 0: subOLR = olr

> David


I suggest having subOLR = -1 in this case, as there is no match

Jean
Re: Creating a sub array from an array [message #71273 is a reply to message #71269] Thu, 10 June 2010 07:38 Go to previous message
David Fanning is currently offline  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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Problem with creating executable files for scripts using envi functions
Next Topic: Object within an Object's Structure

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

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

Total time taken to generate the page: 0.00675 seconds