Пример #1
0
 def select_modeller():
   if model == 'constant2d':
     return Constant2dModeller()
   elif model == 'constant3d':
     return Constant3dModeller()
   elif model == 'linear2d':
     return Linear2dModeller()
   elif model == 'linear3d':
     return Linear3dModeller()
   raise RuntimeError("Unexpected background model: %s" % model)
Пример #2
0
 def select_modeller():
     if model == "constant2d":
         return Constant2dModeller()
     elif model == "constant3d":
         return Constant3dModeller()
     elif model == "linear2d":
         return Linear2dModeller()
     elif model == "linear3d":
         return Linear3dModeller()
     raise RuntimeError(f"Unexpected background model: {model}")
Пример #3
0
 def test_linear3d_modeller(self):
   from dials.algorithms.background.simple import Linear3dModeller
   modeller = Linear3dModeller()
   eps = 1e-7
   for i in range(10):
     p, data, mask = self.generate_linear_background_3d(self.size, 0, 100)
     model = modeller.create(data, mask)
     assert(len(model.params()) == 4)
     for j in range(4):
       assert(abs(model.params()[j] - p[j]) < eps)
Пример #4
0
    def run(self):
        from dials.algorithms.background.simple import Creator
        from dials.algorithms.background.simple import Linear3dModeller
        from dials.algorithms.background.simple import TruncatedOutlierRejector
        from dials.algorithms.background.simple import NSigmaOutlierRejector
        from dials.algorithms.background.simple import NormalOutlierRejector

        modeller = Linear3dModeller()

        outlier_rejector = [
            None,
            TruncatedOutlierRejector(0.01, 0.01),
            NSigmaOutlierRejector(3.0, 3.0),
            NormalOutlierRejector(10),
        ]

        for rejector in outlier_rejector:
            self.tst(Creator(modeller, rejector))
Пример #5
0
    def tst_linear3d_modeller(self):
        from dials.algorithms.background.simple import Linear3dModeller
        from dials.array_family import flex
        modeller = Linear3dModeller()

        # Generate shoeboxes
        ma = 100
        mb = 1
        mc = 2
        md = 3
        sboxes, masks = self.generate_background(self.size, 1000, ma, mb, mc,
                                                 md)

        # Compute model
        a, b, c, d = [], [], [], []
        va, vb, vc, vd = [], [], [], []
        pa = []
        pv = []
        for i in range(1000):
            model = modeller.create(sboxes[i], masks[i])
            assert (len(model.params()) == 4)
            assert (len(model.variances()) == 4)
            p = model.params()
            v = model.variances()
            pa.append(tuple(p))
            pv.append(tuple(v))
        a, b, c, d = zip(*pa)
        va, vb, vc, vd = zip(*pv)

        # Compute Z for each parameter
        za = (flex.double(a) - ma) / flex.sqrt(flex.double(va))
        zb = (flex.double(b) - mb) / flex.sqrt(flex.double(vb))
        zc = (flex.double(c) - mc) / flex.sqrt(flex.double(vc))
        zd = (flex.double(d) - md) / flex.sqrt(flex.double(vd))

        # Check it looks standard normal
        self.assert_std_norm(za)
        self.assert_std_norm(zb)
        self.assert_std_norm(zc)
        self.assert_std_norm(zd)
        print 'OK'