Example #1
0
    def tst_consistent(self):
        from random import randint
        from dials.model.data import Shoebox
        from dials.array_family import flex

        for i in range(1000):

            x0 = randint(0, 1000)
            y0 = randint(0, 1000)
            z0 = randint(0, 1000)
            x1 = randint(1, 10) + x0
            y1 = randint(1, 10) + y0
            z1 = randint(1, 10) + z0
            try:
                shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
                assert (not shoebox.is_consistent())
                shoebox.allocate()
                assert (shoebox.is_consistent())
                shoebox.data = flex.real(flex.grid(20, 20, 20))
                assert (not shoebox.is_consistent())
                shoebox.deallocate()
                assert (not shoebox.is_consistent())
            except Exception, e:
                print x0, y0, z0, x1, y1, z1
                raise
Example #2
0
 def tst_flatten(self):
     from dials.array_family import flex
     from dials.algorithms.shoebox import MaskCode
     for shoebox, (XC, I) in self.random_shoeboxes(10, mask=True):
         assert (not shoebox.flat)
         zs = shoebox.zsize()
         ys = shoebox.ysize()
         xs = shoebox.xsize()
         expected_data = flex.real(flex.grid(1, ys, xs), 0)
         expected_mask = flex.int(flex.grid(1, ys, xs), 0)
         for k in range(zs):
             for j in range(ys):
                 for i in range(xs):
                     expected_data[0, j, i] += shoebox.data[k, j, i]
                     expected_mask[0, j, i] |= shoebox.mask[k, j, i]
                     if (not (expected_mask[0, j, i] & MaskCode.Valid) or
                             not (shoebox.mask[k, j, i] & MaskCode.Valid)):
                         expected_mask[0, j, i] &= ~MaskCode.Valid
         shoebox.flatten()
         diff = expected_data.as_double() - shoebox.data.as_double()
         max_diff = flex.max(flex.abs(diff))
         assert (max_diff < 1e-7)
         assert (expected_mask.all_eq(shoebox.mask))
         assert (shoebox.flat)
         assert (shoebox.is_consistent())
     print 'OK'
Example #3
0
def gaussian(size, a, x0, sx):
    result = flex.real(flex.grid(size))
    index = [0 for i in range(len(size))]
    while True:
        result[index[::-1]] = evaluate_gaussian(index[::-1], a, x0, sx)
        for j in range(len(size)):
            index[j] += 1
            if index[j] < size[::-1][j]:
                break
            index[j] = 0
            if j == len(size) - 1:
                return result
Example #4
0
def gaussian(size, a, x0, sx):

    from dials.array_family import flex

    result = flex.real(flex.grid(size))
    index = [0 for i in range(len(size))]
    while True:
        result[index[::-1]] = evaluate_gaussian(index[::-1], a, x0, sx)
        for j in range(len(size)):
            index[j] += 1
            if index[j] < size[::-1][j]:
                break
            index[j] = 0
            if j == len(size) - 1:
                return result
Example #5
0
    def gaussian(self, size, a, x0, sx):

        from dials.array_family import flex

        result = flex.real(flex.grid(size))

        index = [0] * len(size)
        while True:
            result[index] = self.evaluate_gaussian(index, a, x0, sx)
            for j in range(len(size)):
                index[j] += 1
                if index[j] < size[j]:
                    break
                index[j] = 0
                if j == len(size) - 1:
                    return result