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)
def test_constant3d_modeller(self): from dials.algorithms.background.simple import Constant3dModeller modeller = Constant3dModeller() eps = 1e-7 for i in range(10): c, data, mask = self.generate_constant_background_3d(self.size, 0, 100) model = modeller.create(data, mask) assert(len(model.params()) == 1) for j in range(1): assert(abs(model.params()[j] - c) < eps)
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}")
def run(self): from dials.algorithms.background.simple import Creator from dials.algorithms.background.simple import Constant3dModeller from dials.algorithms.background.simple import TruncatedOutlierRejector from dials.algorithms.background.simple import NSigmaOutlierRejector from dials.algorithms.background.simple import NormalOutlierRejector modeller = Constant3dModeller() 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))
def test_constant3d_modeller(self): from dials.algorithms.background.simple import Constant3dModeller from dials.array_family import flex modeller = Constant3dModeller() ma = 10 sboxes, masks = self.generate_background(self.size, 1000, ma, 0, 0, 0) a = [] v = [] for i in range(1000): model = modeller.create(sboxes[i], masks[i]) assert(len(model.params()) == 1) assert(len(model.variances()) == 1) a.append(model.params()[0]) v.append(model.variances()[0]) # Compute Z for each parameter z = (flex.double(a) - ma) / flex.sqrt(flex.double(v)) # Check it looks standard normal self.assert_std_norm(z)