Ejemplo n.º 1
0
 def generate_shoebox(self, bbox, centre, intensity, mask=False):
     from dials.model.data import Shoebox
     from dials.algorithms.shoebox import MaskCode
     shoebox = Shoebox()
     shoebox.bbox = bbox
     shoebox.allocate()
     for i in range(len(shoebox.mask)):
         shoebox.mask[i] = MaskCode.Valid | MaskCode.Foreground
     shoebox.data = self.gaussian(
         shoebox.size(), 1.0,
         [c - o for c, o in zip(centre[::-1], shoebox.offset())],
         [s / 8.0 for s in shoebox.size()])
     if mask:
         shoebox.mask = self.create_mask(
             shoebox.size(),
             [c - o for c, o in zip(centre[::-1], shoebox.offset())],
             MaskCode.Valid | MaskCode.Foreground)
     tot = 0
     mask_code = MaskCode.Valid | MaskCode.Foreground
     for i in range(len(shoebox.data)):
         if shoebox.mask[i] & mask_code == mask_code:
             tot += shoebox.data[i]
     if tot > 0:
         shoebox.data *= intensity / tot
     return shoebox
Ejemplo n.º 2
0
def test_size():
    for i in range(10):
        x0 = random.randint(0, 1000)
        y0 = random.randint(0, 1000)
        z0 = random.randint(0, 1000)
        x1 = random.randint(1, 10) + x0
        y1 = random.randint(1, 10) + y0
        z1 = random.randint(1, 10) + z0

        shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
        assert shoebox.xsize() == x1 - x0
        assert shoebox.ysize() == y1 - y0
        assert shoebox.zsize() == z1 - z0
        assert shoebox.size() == (z1 - z0, y1 - y0, x1 - x0)
Ejemplo n.º 3
0
    def tst_size(self):
        from random import randint
        from dials.model.data import Shoebox

        for i in range(10):

            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

            shoebox = Shoebox((x0, x1, y0, y1, z0, z1))
            assert (shoebox.xsize() == x1 - x0)
            assert (shoebox.ysize() == y1 - y0)
            assert (shoebox.zsize() == z1 - z0)
            assert (shoebox.size() == (z1 - z0, y1 - y0, x1 - x0))

        # Test passed
        print 'OK'