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

Home » Public Forums » archive » compare 2-d array with vector
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
compare 2-d array with vector [message #81550] Mon, 24 September 2012 00:32 Go to next message
Danxia is currently offline  Danxia
Messages: 10
Registered: September 2012
Junior Member
Hi all, I'm having problem when comparing a 2-d array with a given vector. For example, if giving a 2-d array
a=[[1,1,1],
[2,2,2],
[3,3,3],
[4,4,4]]
and a vector b=[1,2],
how can I get all the subscripts of array a that's equal to any element in vector b, which in this example is [0,1,2,3,4,5]. Please let me know if I failed to make this clear. Looking forward to any reply. Thank you very much!
Re: compare 2-d array with vector [message #82527 is a reply to message #81550] Mon, 17 December 2012 17:45 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Monday, December 17, 2012 2:25:30 PM UTC-5, Chris Torrence wrote:
> On Monday, September 24, 2012 9:30:25 AM UTC-6, Mark Piper wrote:
>
>> On Monday, September 24, 2012 9:19:38 AM UTC-6, Craig Markwardt wrote:
>
>>
>
>>>
>
>>
>
>>> Yeah, I filed a support request on this several years ago, but no action so far.
>
>>
>
>>>
>
>>
>
>>
>
>>
>
>> Heinz & Craig,
>
>>
>
>>
>
>>
>
>> This looks eminently reasonable. I'll look at getting it into the backlog today.
>
>>
>
>>
>
>>
>
>> mp
>
>
>
> This is now fixed and will be in IDL 8.8.2. You can now pass a 1-element array or a scalar into value_locate.

Like. Thanks.
Re: compare 2-d array with vector [message #82694 is a reply to message #81550] Tue, 08 January 2013 04:53 Go to previous message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
On 01/07/2013 11:30 PM, Jeremy Bailin wrote:
>
> What do you expect him to do? Our conclusion was that it's inherently
> undefined, so there's not much point in asking for consistency.
>
> -Jeremy.

You're right it's a detail but I would expect value_locate to return -1
and no warning message.

let's say I want to attribute rank -1 to missing data, 0 to data below
my first level bound and so on.

Solution 1 (throwing a warning):

data = FINDGEN(10) & data[1] = !VALUES.F_NAN
levels = [1L,3,6,9]
pnovalid = where(~ FINITE(data), n_novalid)
rank = VALUE_LOCATE(levels, data) + 1
if n_novalid ne 0 then rank[pnovalid] = -1
print, rank

Solution 2 (no warning):

data = FINDGEN(10) & data[1] = !VALUES.F_NAN
levels = [1L,3,6,9]
pvalid = where(FINITE(data), n_valid)
rank = LONARR(N_ELEMENTS(data)) - 1
rank[pvalid] = VALUE_LOCATE(levels, data[pvalid]) + 1
print, rank

I agree, they are quite similar but I would expect value_locate to be at
least consistent and maybe be clearer in the documentation. Nothing
critical, of course.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: interpolation of two different model
Next Topic: Re: IDL Astronomy Library: Some procedures doesn't work?

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

Current Time: Wed Oct 08 15:56:32 PDT 2025

Total time taken to generate the page: 0.00445 seconds