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

Home » Public Forums » archive » IDL Way to Remove Rows of 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
IDL Way to Remove Rows of an Array [message #75986] Tue, 10 May 2011 05:27 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I have other things demanding my attention this morning,
so I thought I would offer an IDL challenge. What is
the IDL Way to remove arbitrary rows of an array?

For example, suppose I have this array:

array = Indgen(3,6)
print, array

0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16 17

What is the IDL Way to remove rows 2 and 5?

subarray = ???
print, subarray

0 1 2
6 7 8
9 10 11
15 16 17

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL Way to Remove Rows of an Array [message #76120 is a reply to message #75986] Tue, 17 May 2011 10:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gray writes:

> Since David's example converts the reject list to a keep list, then he
> could use your method and skip the steps of constructing the keep
> list.

The thought occurred to me, too. :-)

I'll write it up.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL Way to Remove Rows of an Array [message #76121 is a reply to message #75986] Tue, 17 May 2011 10:12 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On May 17, 12:59 pm, JDS <jdtsmith.nos...@yahoo.com> wrote:
>> JD Smith would probably say that it's faster to construct your own
>> index arrays, right?  Maybe like this?
>
> Probably not in this case.  Typically it's faster to roll your own index lists when the list you are constructing is smaller than the list IDL has to construct, for example if you are further sub-indexing it. The rule of thumb is to try not to make IDL do lots of work you will then promptly throw away.
>
> In this case, your list over columns, and the list IDL would create using "*" are identical.  So I'd probably simply go with '*'.  If you have a 'reject' list instead of 'keep' (as in David's example) a closely related but somewhat simpler/faster method is:
>
>   d=size(array,/DIMENSIONS)
>   array=array[*,where(~histogram(reject,MIN=0,MAX=d[1]-1),/NUL L)]

Since David's example converts the reject list to a keep list, then he
could use your method and skip the steps of constructing the keep
list.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL Way to Remove Rows of an Array
Next Topic: IDL fitting of piecewise continuous function

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

Current Time: Thu Oct 09 06:40:33 PDT 2025

Total time taken to generate the page: 0.32225 seconds