Re: All twisted up over reverse indices! [message #93998] |
Fri, 16 December 2016 05:37  |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Friday, December 16, 2016 at 5:51:42 AM UTC-5, Stephen Williams wrote:
> Greetings all,
>
> I'm slowly working my way through enlightenment with the wonderful "matchall_sph.pro" from Jeremy Bailin.
>
> However, I think I've made a terrible misinterpretation with the indices, and I'm hoping for clarification.
>
> My problem: I have two catalogs of positions for stars that I'm trying to match. I'm also interested in multiple matches and distances between said matches, all of which can be extracted from the reverse indices and other output of "matchall_sph.pro". However, I'm a bit confused as to how to do the proper notation for recovery. An idea of my code thus far:
>
> --------------------
>
> match1 = matchall_sph(r_bv,d_bv,ra_i,de_i,search_rad,nwithin,distance =d)
>
> part_one = where(nwithin gt 0) ; Indices of matched BV sources
> part_two = where(nwithin eq 1) ; same, but only singly matched sources
> part_thr = where(nwithin gt 1) ; same, but only multiply matched sources
>
> ;
> ; This should extract the RA and Dec of singly matched sources.
> ;
>
> ra_i_m = dblarr(n_elements(part_two))
> de_i_m = dblarr(n_elements(part_two))
>
> for i=0L,n_elements(part_two)-2 do begin
>
> ra_i_m(i) = ra_i(match1[match1[part_two(i)]:match1[part_two(i+1)]-1])
> de_i_m(i) = de_i(match1[match1[part_two(i)]:match1[part_two(i+1)]-1])
>
> endfor
>
> ----------------------------
>
> Now, I'm pretty sure this worked like a charm, as a later output file contains the positions from the BV catalog and I catalog, and they make sense, given my inputs. (I also had to write a one-line command to get the final value from that loop, because the "i+1" wrecked the loop!! Yes, I'm that new!)
>
> Not for want of trying, but I can't wrap my mind around extracting the multiple sources, nor the distances from those sources. For example, I've tried the following: (just to see the multiple matches from this particular index)
>
> -----------------------
>
> r_tmp = ra_i(match1[match1[part_thr(0)]:match1[part_thr(1)]-1])
>
> print,n_elements(r_tmp)
>
> -----------------------
>
> This results in 250 elements, when I know that the number of matched I-band sources to this one BV source is only 2. What subscripting pitfall have I stumbled upon? Or is referencing "match1" with the array "part_thr" not appropriate here?
>
> And how would I extract distances given the following in the help file:
>
> -----------------
>
> ; DISTANCE: Optional output containing the distances between each ;pair.
> ; The distances are stored in the same order as the Result
> ; array but starting at 0, i.e. if j is match number k to
> ; element i then
> ; j = Result[Result[i]+k]
> ; and the distance between points i and j is
> ; DISTANCE[Result[i]+k-Result[0]]
>
> -----------------
>
> Thanks tons to anyone who can help, with any part of this mystery! My brain hurts at this point!
>
> Stephen
I found this helped (scroll down to the section on reverse indices):
http://www.idlcoyote.com/tips/histogram_tutorial.html
|
|
|