Skip to content
thespacedoctor edited this page Nov 10, 2015 · 2 revisions

Instantiate the Mesh

> from HMpTy import htm
> mesh16 = htm.HTM(16)

Query the HTM level of the Mesh

> mesh16.get_depth()
16

Generate single HTM ID

> mesh16.lookup_id(34.67583, -45.83729)
array([38212953442])

Note this returns a numpy array

Generate multiple HTM IDs

> mesh16.lookup_id([34.67583,56.3434234,345.3434533], [-45.83729,65.234345,70.343224])
array([38212953442, 66553803098, 53494138281])

Get HTM ids of triangles within a circle of a given radius - radius is in degrees

> mesh16.intersect(34.67583, -45.83729, 2.0/3600., inclusive=True)
array([38212953440, 38212953442, 38212953443, 38212953568, 38212953569, 38212953571])

Get mean area of triangle pixels within mesh

> mesh16.area()
1.200619190041304e-06

The output is in degrees.

Match 2 Lists of coordinates against one another

# match within two arcseconds
two = 2.0/3600.

> ra1 = [200.0, 200.0, 200.0, 175.23, 21.36]
> dec1 = [24.3,  24.3,  24.3,  -28.25, -15.32]
> ra2 = [200.0, 200.0, 200.0, 175.23, 55.25]
> dec2 = [24.3+0.75*two, 24.3 + 0.25*two, 24.3 - 0.33*two, -28.25 + 0.58*two, 75.22]


> indexList1,indexList2,separation = mesh16.match(ra1,dec1,ra2,dec2,two,maxmatch=0)
> for i in xrange(indexList1.size):
        print indexList1[i],indexList2[i],separation[i]

The output is the index of first list, with the matched index of the second list and the distance between the two points.

0 1 0.00013888984367
0 2 0.00018333285694
0 0 0.000416666032158
1 1 0.00013888984367
1 2 0.00018333285694
1 0 0.000416666032158
2 1 0.00013888984367
2 2 0.00018333285694
2 0 0.000416666032158
3 3 0.000322221232243