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)
 def test_ul_vertex(self):
     for rdggs in [WGS84_123, WGS84_123_RADIANS]:
         # Should work for resolution 0 cells.
         for X in rdggs.grid(0):
             get = X.ul_vertex()
             expect = rdggs.ul_vertex[X.suid[0]]
             self.assertEqual(get, expect)
     
         for X in rdggs.grid(0):
             get = X.ul_vertex(plane=False)
             p = rdggs.ul_vertex[X.suid[0]]
             expect = rdggs.rhealpix(*p, inverse=True)
             self.assertEqual(get, expect)
         
         # Should work on children cells.
         a = Cell(rdggs, (S, 2, 3))
         l = a.resolution
         x, y = a.ul_vertex()        
         w = rdggs.cell_width(l + 1)
         error = 1e-10 # Error tolerance.
         for (i, j) in product(list(range(3)), repeat=2):
             b = Cell(rdggs, list(a.suid) + [i + 3*j])
             xx, yy = b.ul_vertex()
             xp, yp = (x + i*w, y - j*w) 
             self.assertTrue(rel_err([xx, yy], [xp, yp]) < error)
     
         a = Cell(rdggs, (S, 2, 3))
         l = a.resolution
         x, y = a.ul_vertex()        
         w = rdggs.cell_width(l + 1)
         error = rdggs.ellipsoid.R_A*1e-15 # Error tolerance.
         for (i, j) in product(list(range(3)), repeat=2):
             b = Cell(rdggs, list(a.suid) + [i + 3*j])
             xx, yy = b.ul_vertex(plane=False)
             xp, yp = rdggs.rhealpix(x + i*w, y - j*w, inverse=True)
             self.assertTrue(rel_err([xx, yy], [xp, yp]) < error)
    def test_ul_vertex(self):
        for rdggs in [WGS84_123, WGS84_123_RADIANS]:
            # Should work for resolution 0 cells.
            for X in rdggs.grid(0):
                get = X.ul_vertex()
                expect = rdggs.ul_vertex[X.suid[0]]
                self.assertEqual(get, expect)

            for X in rdggs.grid(0):
                get = X.ul_vertex(plane=False)
                p = rdggs.ul_vertex[X.suid[0]]
                expect = rdggs.rhealpix(*p, inverse=True)
                self.assertEqual(get, expect)

            # Should work on children cells.
            a = Cell(rdggs, (S, 2, 3))
            l = a.resolution
            x, y = a.ul_vertex()
            w = rdggs.cell_width(l + 1)
            error = 1e-10  # Error tolerance.
            for (i, j) in product(list(range(3)), repeat=2):
                b = Cell(rdggs, list(a.suid) + [i + 3 * j])
                xx, yy = b.ul_vertex()
                xp, yp = (x + i * w, y - j * w)
                self.assertTrue(rel_err([xx, yy], [xp, yp]) < error)

            a = Cell(rdggs, (S, 2, 3))
            l = a.resolution
            x, y = a.ul_vertex()
            w = rdggs.cell_width(l + 1)
            error = rdggs.ellipsoid.R_A * 1e-15  # Error tolerance.
            for (i, j) in product(list(range(3)), repeat=2):
                b = Cell(rdggs, list(a.suid) + [i + 3 * j])
                xx, yy = b.ul_vertex(plane=False)
                xp, yp = rdggs.rhealpix(x + i * w, y - j * w, inverse=True)
                self.assertTrue(rel_err([xx, yy], [xp, yp]) < error)