def test_getters(): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) image_size = sampler.image_size() scan_range = sampler.scan_range() grid_size = sampler.grid_size() step_size = sampler.step_size() size = len(sampler) assert width == image_size[0] assert height == image_size[1] assert scan_range[0] == scan_range[0] assert scan_range[1] == scan_range[1] assert nx == grid_size[0] assert ny == grid_size[1] assert nz == grid_size[2] assert step_size[0] == width / nx assert step_size[1] == height / ny assert step_size[2] == depth / nz assert nx * ny * nz == size
def tst_indexing(self): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) xstep, ystep, zstep = sampler.step_size() xind = [[i for i in range(nx)]] * ny * nz yind = [[j] * nx for j in range(ny)] * nz zind = [[k] * nx * ny for k in range(nz)] xind = [i for j in xind for i in j] yind = [i for j in yind for i in j] zind = [i for j in zind for i in j] xp = [(x + 0.5) * xstep for x in xind] yp = [(y + 0.5) * ystep for y in yind] zp = [(z + 0.5) * zstep + scan_range[0] for z in zind] eps = 1e-10 for x0, y0, z0, i in zip(xp, yp, zp, range(len(sampler))): x1, y1, z1 = sampler.coord(i) assert(abs(x0 - x1) <= eps) assert(abs(y0 - y1) <= eps) assert(abs(z0 - z1) <= eps) print 'OK'
def test_indexing(): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) xstep, ystep, zstep = sampler.step_size() xind = [[i for i in range(nx)]] * ny * nz yind = [[j] * nx for j in range(ny)] * nz zind = [[k] * nx * ny for k in range(nz)] xind = [i for j in xind for i in j] yind = [i for j in yind for i in j] zind = [i for j in zind for i in j] xp = [(x + 0.5) * xstep for x in xind] yp = [(y + 0.5) * ystep for y in yind] zp = [(z + 0.5) * zstep + scan_range[0] for z in zind] eps = 1e-10 for x0, y0, z0, i in zip(xp, yp, zp, range(len(sampler))): x1, y1, z1 = sampler.coord(i) assert abs(x0 - x1) <= eps assert abs(y0 - y1) <= eps assert abs(z0 - z1) <= eps
def tst_getters(self): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) image_size = sampler.image_size() scan_range = sampler.scan_range() grid_size = sampler.grid_size() step_size = sampler.step_size() size = len(sampler) assert(width == image_size[0]) assert(height == image_size[1]) assert(scan_range[0] == scan_range[0]) assert(scan_range[1] == scan_range[1]) assert(nx == grid_size[0]) assert(ny == grid_size[1]) assert(nz == grid_size[2]) assert(step_size[0] == width / nx) assert(step_size[1] == height / ny) assert(step_size[2] == depth / nz) assert(nx * ny * nz == size) print 'OK'