def get_indexing_offset_correlation_coefficients( reflections, crystal, grid, d_min=None, d_max=None, map_to_asu=False, grid_h=0, grid_k=0, grid_l=0, reference=None, ): if grid: if grid_h == 0: grid_h = grid if grid_k == 0: grid_k = grid if grid_l == 0: grid_l = grid return origin.get_hkl_offset_correlation_coefficients( reflections, crystal, map_to_asu=map_to_asu, grid_h=grid_h, grid_k=grid_k, grid_l=grid_l, reference=reference, )
def get_indexing_offset_correlation_coefficients(reflections, crystal, grid, d_min=None, d_max=None, map_to_asu=False, grid_h=0, grid_k=0, grid_l=0, reference=None): from dials.algorithms.symmetry import origin if grid: if grid_h == 0: grid_h = grid if grid_k == 0: grid_k = grid if grid_l == 0: grid_l = grid if True: return origin.get_hkl_offset_correlation_coefficients( reflections, crystal, map_to_asu=map_to_asu, grid_h=grid_h, grid_k=grid_k, grid_l=grid_l, reference=reference) from copy import deepcopy from dials.array_family import flex space_group = crystal.get_space_group() unit_cell = crystal.get_unit_cell() from cctbx.crystal import symmetry as crystal_symmetry cs = crystal_symmetry(unit_cell, space_group.type().lookup_symbol()) from cctbx.miller import set as miller_set data = reflections['intensity.sum.value'] / \ flex.sqrt(reflections['intensity.sum.variance']) if reference: reference = reference.select(reference['intensity.sum.variance'] > 0) reference_data = reference['intensity.sum.value'] / \ flex.sqrt(reference['intensity.sum.variance']) reference_ms = miller_set( cs, reference['miller_index']).array(reference_data) else: reference_ms = None ccs = flex.double() offsets = flex.vec3_int() nref = flex.size_t() original_miller_indices = reflections['miller_index'] ms = miller_set(cs, original_miller_indices).array(data) if d_min is not None or d_max is not None: ms = ms.resolution_filter(d_min=d_min, d_max=d_max) gh = gk = gl = grid if grid_h: gh = grid_h if grid_k: gk = grid_k if grid_l: gl = grid_l # essentially just inversion operation - this *should* have good CC - unless # we are working on a reference set where we don't reindex if reference: cb_op = sgtbx.change_of_basis_op('x,y,z') else: cb_op = sgtbx.change_of_basis_op('-x,-y,-z') for h in range(-gh, gh + 1): for k in range(-gk, gk + 1): for l in range(-gl, gl + 1): miller_indices = offset_miller_indices(ms.indices(), (h, k, l)) reindexed_miller_indices = cb_op.apply(miller_indices) rms = miller_set(cs, reindexed_miller_indices).array(data) if reference_ms: _ms = reference_ms else: _ms = miller_set(cs, miller_indices).array(data) if map_to_asu: rms = rms.map_to_asu() _ms = _ms.map_to_asu() intensity, intensity_rdx = rms.common_sets(_ms) cc = intensity.correlation(intensity_rdx).coefficient() ccs.append(cc) offsets.append((h, k, l)) nref.append(intensity.size()) return offsets, ccs, nref
def get_indexing_offset_correlation_coefficients( reflections, crystal, grid, d_min=None, d_max=None, map_to_asu=False, grid_h=0, grid_k=0, grid_l=0, reference=None): from dials.algorithms.symmetry import origin if grid: if grid_h == 0: grid_h = grid if grid_k == 0: grid_k = grid if grid_l == 0: grid_l = grid if True: return origin.get_hkl_offset_correlation_coefficients( reflections, crystal, map_to_asu=map_to_asu, grid_h=grid_h, grid_k=grid_k, grid_l=grid_l, reference=reference) from copy import deepcopy from dials.array_family import flex space_group = crystal.get_space_group() unit_cell = crystal.get_unit_cell() from cctbx.crystal import symmetry as crystal_symmetry cs = crystal_symmetry(unit_cell, space_group.type().lookup_symbol()) from cctbx.miller import set as miller_set data = reflections['intensity.sum.value'] / \ flex.sqrt(reflections['intensity.sum.variance']) if reference: reference = reference.select(reference['intensity.sum.variance'] > 0) reference_data = reference['intensity.sum.value'] / \ flex.sqrt(reference['intensity.sum.variance']) reference_ms = miller_set(cs, reference['miller_index']).array( reference_data) else: reference_ms = None ccs = flex.double() offsets = flex.vec3_int() nref = flex.size_t() original_miller_indices = reflections['miller_index'] ms = miller_set(cs, original_miller_indices).array(data) if d_min is not None or d_max is not None: ms = ms.resolution_filter(d_min=d_min, d_max=d_max) gh = gk = gl = grid if grid_h: gh = grid_h if grid_k: gk = grid_k if grid_l: gl = grid_l # essentially just inversion operation - this *should* have good CC - unless # we are working on a reference set where we don't reindex if reference: cb_op = sgtbx.change_of_basis_op('x,y,z') else: cb_op = sgtbx.change_of_basis_op('-x,-y,-z') for h in range(-gh, gh + 1): for k in range(-gk, gk + 1): for l in range(-gl, gl + 1): miller_indices = offset_miller_indices(ms.indices(), (h, k, l)) reindexed_miller_indices = cb_op.apply(miller_indices) rms = miller_set(cs, reindexed_miller_indices).array(data) if reference_ms: _ms = reference_ms else: _ms = miller_set(cs, miller_indices).array(data) if map_to_asu: rms = rms.map_to_asu() _ms = _ms.map_to_asu() intensity, intensity_rdx = rms.common_sets(_ms) cc = intensity.correlation(intensity_rdx).coefficient() ccs.append(cc) offsets.append((h, k, l)) nref.append(intensity.size()) return offsets, ccs, nref