matching coordinates [message #55077] |
Sun, 29 July 2007 02:01 |
jradavenport
Messages: 6 Registered: July 2007
|
Junior Member |
|
|
Hello, I'm a long time lurker of this group, and finally have a
problem I can't solve efficiently enough! I have coordinates for stars
(RA and DEC for us astronomers out there), from two sources. i.e.
(x1,y1) and (x2,y2). These lists are huge, like 150k for one and
5million in the other (a lot of stars!). I need to find the matches
from these catalogs within a tolerance. I've tried a few programs
I've found online (close_match_radec for instance) and they have not
given me results I believe (multiple matches and such). Here is some
horrible code I wrote just now which solves the problem VERY slowly:
sep=0.0008
m1=[-1]
m2=[-1]
for i=0L,n_elements(ra1)-1 do begin
dra=ra2-ra1[i]
ddec=dec2-dec1[i]
m=where(abs(dra) le sep and abs(ddec) le sep) ;find the star
within the separation, sep
if m[0] ne -1 then begin
m1=[m1,i]
m2=[m2,m[0]]
end
dra=0
ddec=0
endfor
if n_elements(m1) gt 1 then begin
m1=m1[1:*]
m2=m2[1:*]
print,n_elements(m1),' matches found.'
endif
if n_elements(m1) eq 1 then print,'No matches found!'
I have the idea of concatenating the arrays, sorting them, then
subtracting the n+1 element from the n element, and finding where the
result is less than the separation tolerance, but this only works well
for me in 1-D... Any thoughts or help would be very welcomed.
|
|
|