HTM (class)

class HTM(depth=16, log=False)[source]

Bases: HMpTy.htm._htmcCode.HTMC

A Hierarchical Triangular Mesh object

Key Arguments

  • depth – the depth of the mesh you wish to create. Default 16

Usage

To generate a mesh object:

from HMpTy import HTM
mesh16 = HTM(
    depth=16
)

Methods

cbincount(*args)

cmatch(*args)

init([depth])

intersect(ra, dec, radius[, inclusive, …])

return IDs of all triangles contained within and/or intersecting a circle centered on a given ra and dec

lookup_id(ra, dec)

Lookup the ID of HTM trixel that a coordinate or lists of coordinates lie on

match(ra1, dec1, ra2, dec2, radius[, …])

Crossmatch two lists of ra/dec points

Properties

area

The mean area of triangles in this mesh in units of square degrees.

depth

the depth of the HTM tree

intersect(ra, dec, radius, inclusive=True, convertCoordinates=True)[source]

return IDs of all triangles contained within and/or intersecting a circle centered on a given ra and dec

Key Arguments

  • ra – RA of central point in decimal degrees or sexagesimal

  • dec – DEC of central point in decimal degrees or sexagesimal

  • radius – radius of circle in degrees

  • inclusive – include IDs of triangles that intersect the circle as well as those completely inclosed by the circle. Default True

Return

  • trixelArray – a numpy array of the match trixel IDs

Usage

To return the trixels overlapping a circle with a 10 arcsec radius centred at 23:25:53.56, +26:54:23.9

overlappingTrixels = mesh16.intersect(
    ra="23:25:53.56",
    dec="+26:54:23.9",
    radius=10 / (60 * 60),
    inclusive=True
)

Or to return the trixels completing enclosed by a circle with a 1 degree radius centred at 23:25:53.56, +26:54:23.9

overlappingTrixels = mesh16.intersect(
    ra="23:25:53.56",
    dec="+26:54:23.9",
    radius=1,
    inclusive=False
)
lookup_id(ra, dec)[source]

Lookup the ID of HTM trixel that a coordinate or lists of coordinates lie on

Key Arguments

  • ra – list, numpy array or single ra value (first coordinate set)

  • dec – list, numpy array or single dec value (first coordinate set - must match ra1 array length)

Return

  • htmIds – a list of HTM trixel ids the coordinates lie on

Usage

To find the trixel IDs that a set of coordinate lie on:

raList1 = ["13:20:00.00", 200.0, "13:20:00.00", 175.23, 21.36]
decList1 = ["+24:18:00.00",  24.3,  "+24:18:00.00",  -28.25, -15.32]

htmids = mesh.lookup_id(raList1, decList1)
for h, r, d in zip(htmids, raList1, decList1):
    print(r, d, " --> ", h)
match(ra1, dec1, ra2, dec2, radius, maxmatch=1, convertToArray=True)[source]

Crossmatch two lists of ra/dec points

This is very efficient for large search angles and large lists. Note, if you need to match against the same points many times, you should use a Matcher object

Key Arguments

  • ra1 – list, numpy array or single ra value (first coordinate set)

  • dec1 – list, numpy array or single dec value (first coordinate set - must match ra1 array length)

  • ra2 – list, numpy array or single ra value (second coordinate set)

  • dec2 – list, numpy array or single dec value (second coordinate set - must match ra2 array length)

  • radius – search radius in degrees. Can be list, numpy array or single value. If list or numpy array must be same length as ra1 array length)

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

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

Return

  • matchIndices1 – match indices for list1 (ra1, dec1)

  • matchIndices2 – match indices for list2 (ra2, dec2)

  • sepDeg – separations between matched corrdinates in degrees. All returned arrays are the same size

Usage

To match 2 lists of corrdinates try something like this:

twoArcsec = 2.0 / 3600.
raList1 = [200.0, 200.0, 200.0, 175.23, 21.36]
decList1 = [24.3,  24.3,  24.3,  -28.25, -15.32]
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 = mesh.match(
    ra1=raList1,
    dec1=decList1,
    ra2=raList2,
    dec2=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])

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 area[source]

The mean area of triangles in this mesh in units of square degrees.

Usage

mesh.area
property depth[source]

the depth of the HTM tree

Usage

mesh.depth