def __init__(self, symm, rot=None):

        uc = symm.unit_cell()
        spgrp = symm.space_group()

        #The U matrix to calculate A^*
        if rot is None:
            rot = flex.random_double_r3_rotation_matrix()
            self.rot = rot
            #print rot

        # add gassian random noise "error" to unit cell, sigma = 0.3
        # change a and c axis using symmetry constraints
        a = uc.parameters()[0]  # b will take this same value
        c = uc.parameters()[2]
        v_params = [a, c]

        new_uc_params = [
            random.gauss(v_params[i], 1.0) for i in range(len(v_params))
        ]
        new_uc = (new_uc_params[0], new_uc_params[0], new_uc_params[1],
                  uc.parameters()[3], uc.parameters()[4], uc.parameters()[5])

        print new_uc

        new_sym = crystal.symmetry(new_uc, space_group=spgrp)
        new_uc = new_sym.unit_cell()
        A = sqr(rot) * sqr(new_uc.reciprocal().orthogonalization_matrix())
        self.A = A

        #set of hkls including bijvoet pairs
        hkl_list = cctbx.miller.build_set(symm, True, d_min=3).expand_to_p1()
        self.hkl_list = hkl_list
 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")
 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")
Esempio n. 4
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)
Esempio n. 5
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)