def __init__(self, sweep, params):
   self.params = params
   flex.set_random_seed(params.random_seed)
   unit_cell = params.unit_cell
   assert unit_cell is not None
   sgi = params.space_group
   if sgi is None:
     sgi = sgtbx.space_group_info(symbol="P 1")
   B = scitbx.matrix.sqr(unit_cell.fractionalization_matrix()).transpose()
   U = scitbx.matrix.sqr(flex.random_double_r3_rotation_matrix())
   direct_matrix = (U * B).inverse()
   crystal_model = Crystal(direct_matrix[0:3],
                           direct_matrix[3:6],
                           direct_matrix[6:9],
                           space_group=sgi.group())
   scan = sweep.get_scan()
   angle = self.params.rotation_angle
   scan.set_image_range((1, iceil(angle/scan.get_oscillation()[1])))
   predicted = predict_reflections(sweep, crystal_model)
   beam_vectors = predicted.beam_vector()
   S = beam_vectors - sweep.get_beam().get_s0()
   centroids = S.rotate_around_origin(sweep.get_goniometer().get_rotation_axis(),
                                      -predicted.rotation_angle())
   self.d_min = self.params.reciprocal_space_grid.d_min
   self.gridding = tuple([self.params.reciprocal_space_grid.n_points]*3)
   centroids = centroids.select((1/centroids.norms())>=self.d_min)
   assert len(centroids) > 0
   self.map_to_grid(sweep, centroids)
   self.fft()
   debug_write_reciprocal_lattice_points_as_pdb(centroids)
   self.debug_write_ccp4_map(self.grid_real, "fft.map")
Ejemplo n.º 2
0
def get_random_predictions():
    """ Return a DIALS reflection table representing predictions using the given models.
  Assumes a Ewald proximity model for mosaicity """
    # The U matrix to calculate A*
    rot = flex.random_double_r3_rotation_matrix()
    A = sqr(rot) * sqr(uc.reciprocal().orthogonalization_matrix())
    A_inv = A.inverse()

    # Use the matrix to create a crystal model
    a = col(A_inv[:3])
    b = col(A_inv[3:6])
    c = col(A_inv[6:])
    cm = crystal_model(a, b, c, space_group=spgrp)

    # This DIALS object has no gonio or scan which will identify it as a still
    expt = Experiment(beam=beam, detector=detector, goniometer=None, scan=None, crystal=cm)

    # Predict the reflections
    return flex.reflection_table.from_predictions(expt)