def tst_with_flat_background(self): from dials.algorithms.integration.fit import fit_profile from scitbx.array_family import flex from tst_profile_helpers import gaussian # Create profile p = gaussian((9, 9, 9), 1, (4, 4, 4), (2, 2, 2)) s = flex.sum(p) p = p / s # Copy profile c0 = gaussian((9, 9, 9), 1, (4, 4, 4), (2, 2, 2)) b = flex.double(flex.grid(9, 9, 9), 5) m = flex.bool(flex.grid(9,9,9), True) c = c0 + b # Fit fit = fit_profile(p, m, c, b) I = fit.intensity() V = fit.variance() # Test intensity is the same eps = 1e-7 assert(abs(I - flex.sum(c0)) < eps) assert(abs(V - (flex.sum(c0) + flex.sum(b))) < eps) print 'OK'
def tst_with_flat_background_partial(self): from dials.algorithms.integration.fit import fit_profile from scitbx.array_family import flex from tst_profile_helpers import gaussian # Create profile p = gaussian((9, 9, 9), 1, (4, 4, 4), (2, 2, 2)) s = flex.sum(p) p = p / s # Copy profile c0 = gaussian((9, 9, 9), 1, (4, 4, 4), (2, 2, 2)) b = flex.double(flex.grid(9, 9, 9), 5) m = flex.bool(flex.grid(9,9,9), True) c = c0 + b # Get the partial profiles pp = p[0:5,:,:] mp = m[0:5,:,:] cp = c[0:5,:,:] bp = b[0:5,:,:] c0p = c0[0:5,:,:] # Fit fit = fit_profile(pp, mp, cp, bp) I = fit.intensity() V = fit.variance() # Test intensity is the same eps = 1e-7 assert(abs(I - flex.sum(c0)) < eps) assert(abs(V - (flex.sum(c0p) + flex.sum(bp))) < eps) print 'OK'
def tst_identical(self): from dials.algorithms.integration.fit import fit_profile from scitbx.array_family import flex from tst_profile_helpers import gaussian # Create profile p = gaussian((9, 9, 9), 1, (4, 4, 4), (2, 2, 2)) s = flex.sum(p) p = p / s # Copy profile c = p.deep_copy() b = flex.double(flex.grid(9, 9, 9), 0) m = flex.bool(flex.grid(9,9,9), True) # Fit fit = fit_profile(p, m, c, b) I = fit.intensity() V = fit.variance() # Test intensity is the same eps = 1e-7 assert(abs(I - flex.sum(p)) < eps) assert(abs(V - I) < eps) print 'OK'
def generate_single_central_non_negative_profiles(self): from dials.array_family import flex from tst_profile_helpers import gaussian rlist = flex.reflection_table(1) profile = gaussian(self.grid_size, 1000, (4, 4, 4), (1.5, 1.5, 1.5)) x = 500 y = 500 z = 5 xyz = flex.vec3_double(1) xyz[0] = (x, y, z) profiles = [ profile.deep_copy() ] rlist['xyzcal.px'] = xyz return rlist, profiles, profile
def generate_single_central_non_negative_profiles(self): from dials.array_family import flex from tst_profile_helpers import gaussian rlist = flex.reflection_table(1) profile = gaussian(self.grid_size, 1000, (4, 4, 4), (1.5, 1.5, 1.5)) x = 500 y = 500 z = 5 xyz = flex.vec3_double(1) xyz[0] = (x, y, z) profiles = [profile.deep_copy()] rlist["xyzcal.px"] = xyz return rlist, profiles, profile
def generate_identical_non_negative_profiles(self): from dials.array_family import flex from random import uniform from tst_profile_helpers import gaussian rlist = flex.reflection_table(1000) profile = gaussian(self.grid_size, 1000, (4, 4, 4), (1.5, 1.5, 1.5)) xyz = flex.vec3_double(1000) profiles = [] for i in range(1000): x = uniform(0, 1000) y = uniform(0, 1000) z = uniform(0, 10) xyz[i] = (x, y, z) profiles.append(profile.deep_copy()) rlist['xyzcal.px'] = xyz return rlist, profiles, profile
def generate_identical_non_negative_profiles(self): from dials.array_family import flex from random import uniform from tst_profile_helpers import gaussian rlist = flex.reflection_table(1000) profile = gaussian(self.grid_size, 1000, (4, 4, 4), (1.5, 1.5, 1.5)) xyz = flex.vec3_double(1000) profiles = [] for i in range(1000): x = uniform(0, 1000) y = uniform(0, 1000) z = uniform(0, 10) xyz[i] = (x, y, z) profiles.append(profile.deep_copy()) rlist["xyzcal.px"] = xyz return rlist, profiles, profile
def generate_systematically_offset_profiles(self): from dials.array_family import flex from random import uniform from tst_profile_helpers import gaussian rlist = flex.reflection_table(1000) xyz = flex.vec3_double(1000) profiles = [] for i in range(1000): x = uniform(0, 1000) y = uniform(0, 1000) z = uniform(0, 10) offset = -4.5 + 9 * x / 1000.0 profile = gaussian(self.grid_size, 1000, (4 + offset, 4, 4), (1.5, 1.5, 1.5)) xyz[i] = (x, y, z) profiles.append(profile) rlist["xyzcal.px"] = xyz return rlist, profiles
def generate_systematically_offset_profiles(self): from dials.array_family import flex from random import uniform from tst_profile_helpers import gaussian rlist = flex.reflection_table(1000) xyz = flex.vec3_double(1000) profiles = [] for i in range(1000): x = uniform(0, 1000) y = uniform(0, 1000) z = uniform(0, 10) offset = -4.5 + 9 * x / 1000.0 profile = gaussian(self.grid_size, 1000, (4 + offset, 4, 4), (1.5, 1.5, 1.5)) xyz[i] = (x, y, z) profiles.append(profile) rlist['xyzcal.px'] = xyz return rlist, profiles