Fast coordinate
matching with k3match
Pim Schellart
M. v.d. Akker, A. Corstanje, E. Enriquez, H. Falcke, J.
R. Hörandel, A. Nelles, S. Thoudam, S. ter Veen
Cosmic Rays Key Science Project
Radboud University Nijmegen
Slide 2
Slide 2 text
The problem
• Which of the objects in catalog A are within 1” of the objects in catalog B?
• What object from catalog A is closest to my search coordinates?
• How do we answer these questions fast?
Slide 3
Slide 3 text
K3Match
• Stand alone library written in C
• Python bindings
• idx_a, idx_b, d = k3match.celestial(ra_a, dec_a, ra_b, dec_b, r)
• input and output using numpy arrays
• Source code available under open source GPL license
Slide 4
Slide 4 text
KD-Trees
J.L. Bentley, “Multidimensional binary search trees used for associative
searching,” Communications of the ACM, 1975.
Image credit: wikipedia
Slide 5
Slide 5 text
Range search
Slide 6
Slide 6 text
Range search
Slide 7
Slide 7 text
Range search
Slide 8
Slide 8 text
Range search
Slide 9
Slide 9 text
Range search
Slide 10
Slide 10 text
Range search
Slide 11
Slide 11 text
Range search
Slide 12
Slide 12 text
Range search
Slide 13
Slide 13 text
Optimized KD-Trees
• J.H. Friedman. J.L. Bentley R.A. Finkel, “An algorithm for finding best
matches in logarithmic expected time,” ACM Transactions on Mathematical
Software.
• Tree needs to be balanced, e.g. choose median as discriminator value at each
partition.
• With O(N) median, tree building takes O(k N log N) time.
• Single query takes O(log N) time on average, total running time is O(N log N)
when Ns ~ N.
Slide 14
Slide 14 text
Scaling
Slide 15
Slide 15 text
Wrong scaling due to unexpected behavior of
quickselect median algorithm (solved)
before after
Slide 16
Slide 16 text
RPM
DEB
Source
Simple installation from source or binary package
http://pschella.github.com/k3match
Slide 17
Slide 17 text
Conclusion
• Easy to install
• Easy to use
• Fast
• Get it now at http://pschella.github.com/k3match