Matcher (class)

class Matcher(ra, dec, depth=16, log=False, convertToArray=True)[source]

Bases: HMpTy.htm._htmcCode.Matcher

A matcher-array object to match other arrays of ra,dec against

The Matcher object is initialized with a set of ra,dec coordinates and can then be used and reused to match against other sets of coordinates

Key Arguments

  • log – logger

  • depth – the depth of the mesh generate the Matcher object at. Default 16

  • ra – list, numpy array or single ra value

  • dec – –list, numpy array or single dec value (must match ra array length)

  • convertToArray – convert the coordinates into an array. Default True. Can bypass the conversion check if you are sure coordinates in numpy array

Return

  • None

Usage

If we have a set of coordinates such that:

raList1 = [200.0, 200.0, 200.0, 175.23, 21.36]
decList1 = [24.3,  24.3,  24.3,  -28.25, -15.32]

We can initialise a matcher object like so:

from HMpTy import Matcher
coordinateSet = Matcher(
    log=log,
    ra=raList1,
    dec=decList1,
    depth=16
)

Methods

get_depth()

match(ra, dec, radius[, maxmatch])

match a corrdinate set against this Matcher object’s coordinate set

Properties

depth

the depth of the Matcher object

match(ra, dec, radius, maxmatch=1)[source]

match a corrdinate set against this Matcher object’s coordinate set

Key Arguments

  • ra – list, numpy array or single ra value

  • dec – –list, numpy array or single dec value (must match ra array length)

  • radius – radius of circle in degrees

  • maxmatch – maximum number of matches to return. Set to 0 to match all points. Default 1 (i.e. closest match)

Return

  • None

Usage

Once we have initialised a Matcher coordinateSet object we can match other coordinate sets against it:

twoArcsec = 2.0 / 3600.
raList2 = [200.0, 200.0, 200.0, 175.23, 55.25]
decList2 = [24.3 + 0.75 * twoArcsec, 24.3 + 0.25 * twoArcsec,
    24.3 - 0.33 * twoArcsec, -28.25 + 0.58 * twoArcsec, 75.22]

matchIndices1, matchIndices2, seps = coordinateSet.match(
    ra=raList2,
    dec=decList2,
    radius=twoArcsec,
    maxmatch=0
)

for m1, m2, s in zip(matchIndices1, matchIndices2, seps):
    print(raList1[m1], decList1[m1], " -> ", s * 3600., " arcsec -> ", raList2[m2], decList2[m2])

Or to return just the nearest matches:

matchIndices1, matchIndices2, seps = coordinateSet.match(
    ra=raList2,
    dec=decList2,
    radius=twoArcsec,
    maxmatch=1
)

Note from the print statement, you can index the arrays raList1, decList1 with the matchIndices1 array values and raList2, decList2 with the matchIndices2 values.

property depth[source]

the depth of the Matcher object

Usage

coordinateSet.depth