astro/
matchall_nd.pro
Routines
result = matchallmap(ngrid, aind, usemap=usemap)result = matchall_nd(p1, p2, maxdistance [, nwithin], distance=distance)Determines which of a set of coordinates of arbitratry dimension are a given distance from each of a vector of points.
Routine details
top source matchallmap
result = matchallmap(ngrid, aind, usemap=usemap)
Parameters
- ngrid
- aind
Keywords
- usemap
top source matchall_nd
Astro
result = matchall_nd(p1, p2, maxdistance [, nwithin], distance=distance)
Determines which of a set of coordinates of arbitratry dimension are a given distance from each of a vector of points. Based on JD's MATCH_2D and my MATCHALL_SPH.
Return value
The function returns the list of indices of P2 that lie within Distance of each point in P1. The format of the returned array is similar to the REVERSE_INDICES array from HISTOGRAM: the indices into P2 that are close enough to element i of P1 are contained in Result[Result[i]:Result[i+1]-1] (note, however, that these indices are not guaranteed to be sorted). If there are no matches, then Result[i] eq Result[i+1].
Parameters
- p1 in
N1xD array of D-dimensional coordinates.
- p2 in
N2xD array of D-dimensional coordinates.
- maxdistance in
Maximum D-dimensional distance.
- nwithin optional
A vector containing the number of matches for each entry in P1.
Keywords
- distance in
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]]
Examples
Generates Gaussian 3D clouds around each of several locations and colours
the points in the cloud that lie within the Gaussian dispersion of any
location.
na = 10
nbpera = 1000
a = randomn(seed, na, 3)
b = 0.1*randomn(seed, na*nbpera, 3)
b += rebin(a, na*nbpera, 3, /sample)
result = matchall_nd(a, b, 0.1)
matches = result[na+1:*]
iplot, /scatter, /iso, b[*,0], b[*,1], b[*,2]
iplot, /overplot, /scatter, sym_color=[255,0,0], b[matches,0], $
b[matches,1], b[matches,2]
iplot, /overplot, sym_index=1, sym_color=[0,0,255], linestyle=6, a[*,0], $
a[*,1], a[*,2]
Author information
- History:
Written by: Jeremy Bailin 10 June 2008 Public release in JBIU as WITHINSPHRAD 24 April 2009 Vectorized as WITHINSPHRAD_VEC 25 April 2009 Polished to improve memory use 9 May 2009 Radical efficiency re-write as WITHINSPHRAD_VEC3D borrowing heavily from JD Smith's MATCH_2D 13 May 2009 Removed * from LHS index in final remapping for speed 6 May 2010 Changed to MATCHALL_2D and just using Euclidean 2D coordinates (add a bunch of stuff back in from MATCH_2D and take out a bunch of angle stuff) 25 May 2010 Bug fix to allow X2 and Y2 to have any dimension. 23 August 2010 Generalized to an arbitrary number of dimensions and to use the manifold-mapping technique from WITHINSPHRAD_VEC3D if the space is sparse enough as MATCHALL_ND. 9 Feb 2010 Added DISTANCE output keyword.
File attributes
| Modification date: | Thu Feb 10 10:38:59 2011 |
| Lines: | 212 |
![[attach.png]](../idldoc-resources/attach.png)