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_constant2d_modeller(self): from dials.algorithms.background.simple import Constant2dModeller modeller = Constant2dModeller() eps = 1e-7 for i in range(10): c, data, mask = self.generate_constant_background_2d(self.size, 0, 100) model = modeller.create(data, mask) assert(len(model.params()) == 9) for j in range(9): assert(abs(model.params()[j] - c[j]) < 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 Constant2dModeller from dials.algorithms.background.simple import TruncatedOutlierRejector from dials.algorithms.background.simple import NSigmaOutlierRejector from dials.algorithms.background.simple import NormalOutlierRejector modeller = Constant2dModeller() 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_constant2d_modeller(self): from dials.algorithms.background.simple import Constant2dModeller from dials.array_family import flex modeller = Constant2dModeller() 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()) == 9) assert(len(model.variances()) == 9) a.extend(list(model.params())) v.extend(list(model.variances())) # 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)