def test_contains(self): for rdggs in [WGS84_003, WGS84_003_RADIANS]: # A cell should contain its nucleus, but not my test point p. # Assume that nucleus() and vertices() work. for suid in [[N, 3, 1], [P, 5, 7, 5, 1, 3], [S, 0]]: c = Cell(rdggs, suid) w = c.width() for plane in [True, False]: nucleus = c.nucleus(plane=plane) vertices = c.vertices(plane=plane) p = (max([v[0] for v in vertices]) + 1, vertices[3][1]) self.assertTrue(c.contains(nucleus, plane=plane)) self.assertFalse(c.contains(p, plane=plane))
def test_nucleus(self): for rdggs in [WGS84_123, WGS84_123_RADIANS]: # Nuclei of children should be in correct position # relative to parent cell in rHEALPix projection. a = Cell(rdggs, (S, 7, 4, 1, 2, 1)) # Arbitrary cell. w = a.width() (x, y) = a.ul_vertex() error = 1e-10 for (row, col) in product(list(range(3)), repeat=2): s = str(row*3 + col) # Child cell in (row, column) position relative to a: b = Cell(rdggs, list(a.suid) + [3*row + col]) get = b.nucleus() expect = (x + w/6 + (w/3)*col, y - w/6 - (w/3)*row) self.assertTrue(rel_err(get, expect) < error)
def test_nucleus(self): for rdggs in [WGS84_123, WGS84_123_RADIANS]: # Nuclei of children should be in correct position # relative to parent cell in rHEALPix projection. a = Cell(rdggs, (S, 7, 4, 1, 2, 1)) # Arbitrary cell. w = a.width() (x, y) = a.ul_vertex() error = 1e-10 for (row, col) in product(list(range(3)), repeat=2): s = str(row * 3 + col) # Child cell in (row, column) position relative to a: b = Cell(rdggs, list(a.suid) + [3 * row + col]) get = b.nucleus() expect = (x + w / 6 + (w / 3) * col, y - w / 6 - (w / 3) * row) self.assertTrue(rel_err(get, expect) < error)