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

Home » Public Forums » archive » rebinning two arrays? or re: finding exclusive elements between 2 not-quite identical arrays?
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: rebinning two arrays? or re: finding exclusive elements between 2 not-quite identical arrays? [message #89751 is a reply to message #89750] Fri, 28 November 2014 10:49 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
Hi Brian.

On Fri, 28 Nov 2014 08:54:10 -0800 (PST), Brian Cherinka wrote:

>
> So this post is related to my original post here, but it's not quite working out.
> https://groups.google.com/forum/#!topic/comp.lang.idl-pvwave /CtiGTuNqD10
>
> ...
>
> So I have two arrays where I need to extract the elements in one array not in the other, but the elements are not quite exact to one another.
>
> A = [309, 313, 318, 322, 327, 331, 336, 340]
> B = [305, 309, 314, 318, 323, 327, 332, 336, 341, 345]
>
> B is the true array, and A is the "found" array that is missing some elements. I want to find all elements missing from A that exist in B.
>
> The solution I adopted, from the previous post, is something like
>
> diff = 2 ; offset between integers
> temp = value_locate(A,B)
> missloc = where(B-A[temp] gt diff and A[temp+1]-B gt diff, misscount)
>
> This mostly works, however it does not work when the elements that are missing are the edges, i.e. the first or last element.
>
> [...]

The missing elements on the left edge were recognized by the
additional two lines in my draft. But not the missing elements on the
right edge. This is true.

However I would not use the histogram function to overcome this. I
would go a more easy way, which I expect to be both, faster and less
memory consuming. It is only a little change to the code above:

A = [309, 313, 318, 322, 327, 331, 336, 340]
B = [305, 309, 314, 318, 323, 327, 332, 336, 341, 345]
diff = 2 ; offset between integers
temp = value_locate(A,B)
missloc = where((B-A[temp] gt diff and A[temp+1]-B gt diff) or $
a[0]-b gt diff or $ ; elements on the left edge
b-a[n_elements(a)-1] gt diff, $ ; right edge
misscount)
if misscount ge 1 then print,b[missloc]

Good luck again, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: cgimage/overlaid grid
Next Topic: Confusion about nthread and ncore

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

Current Time: Wed Oct 08 17:05:56 PDT 2025

Total time taken to generate the page: 0.00467 seconds