Ejemplo n.º 1
0
  def build_beam(self):

    if self._params.beam.wavelength.random:
      wavelength = random.uniform(
                              *self._params.beam.wavelength.range)
    else: wavelength = self._params.beam.wavelength.value

    assert self._params.beam.direction.method in ['inclination',
                                                  'close_to',
                                                  'exactly']

    if self._params.beam.direction.method == 'inclination':

      if self._params.beam.direction.inclination.random:
        inclination = random.gauss(0.,
                self._params.beam.direction.inclination.angle)
      else: inclination = \
                  self._params.beam.direction.inclination.angle

      beam_dir = matrix.col((0, 0, 1)).rotate(
                  matrix.col((0, 1, 0)), inclination, deg=True)

    elif self._params.beam.direction.method == 'close_to':

      temp = self._params.beam.direction.close_to.direction
      beam_dir = random_vector_close_to(temp,
                  sd = self._params.beam.direction.close_to.sd)

    elif self._params.beam.direction.method == 'exactly':

      beam_dir = matrix.col(self._params.beam.direction.exactly)

    self.beam = beam_factory.make_beam(unit_s0 = beam_dir,
                                       wavelength = wavelength)
Ejemplo n.º 2
0
  def __init__(self, test_nave_model = False):

    # Set up experimental models with regular geometry
    from dxtbx.model.experiment import beam_factory
    from dxtbx.model.experiment import goniometer_factory
    from dxtbx.model.experiment import detector_factory

    from dxtbx.model.crystal import crystal_model

    # Beam along the Z axis
    self.beam = beam_factory.make_beam(unit_s0 = matrix.col((0, 0, 1)),
                                       wavelength = 1.0)

    # Goniometer (used only for index generation) along X axis
    self.goniometer = goniometer_factory.known_axis(matrix.col((1, 0, 0)))

    # Detector fast, slow along X, -Y; beam in the centre, 200 mm distance
    dir1 = matrix.col((1, 0, 0))
    dir2 = matrix.col((0, -1, 0))
    n = matrix.col((0, 0, 1))
    centre = matrix.col((0, 0, 200))
    npx_fast = npx_slow = 1000
    pix_size = 0.2
    origin = centre - (0.5 * npx_fast * pix_size * dir1 +
                       0.5 * npx_slow * pix_size * dir2)
    self.detector = detector_factory.make_detector("PAD",
                        dir1, dir2, origin,
                        (pix_size, pix_size),
                        (npx_fast, npx_slow),
                        (0, 1.e6))

    # Cubic 100 A^3 crystal
    a = matrix.col((100, 0, 0))
    b = matrix.col((0, 100, 0))
    c = matrix.col((0, 0, 100))
    self.crystal = crystal_model(a, b, c, space_group_symbol = "P 1")

    if test_nave_model:
      self.crystal._ML_half_mosaicity_deg = 500
      self.crystal._ML_domain_size_ang = 0.2

    # Collect these models in an Experiment (ignoring the goniometer)
    from dxtbx.model.experiment.experiment_list import Experiment
    self.experiment = Experiment(beam=self.beam, detector=self.detector,
      goniometer=None, scan=None, crystal=self.crystal, imageset=None)

    # Generate some reflections
    self.reflections = self.generate_reflections()

    return
Ejemplo n.º 3
0
from dxtbx.model.experiment import beam_factory, goniometer_factory

### local functions
def random_direction_close_to(vector):
    return vector.rotate_around_origin(
        matrix.col((random.random(), random.random(), random.random())).normalize(),
        random.gauss(0, 1.0),
        deg=True,
    )


### Create models

# make a beam vector close to the Z axis
direction = random_direction_close_to(matrix.col((0, 0, 1)))
mybeam = beam_factory.make_beam(direction, 1.5)

# make a random P1 crystal
a = random.uniform(10, 20) * random_direction_close_to(matrix.col((1, 0, 0)))
b = random.uniform(10, 20) * random_direction_close_to(matrix.col((0, 1, 0)))
c = random.uniform(10, 20) * random_direction_close_to(matrix.col((0, 0, 1)))
crystal_model(a, b, c, space_group_symbol="P 1")

# make a dumb goniometer that rotates around X
mygonio = goniometer_factory.known_axis((1, 0, 0))

# generate some indices
resolution = 2.0
indices = full_sphere_indices(
    unit_cell=mycrystal.get_unit_cell(),
    resolution_limit=resolution,
Ejemplo n.º 4
0
from dxtbx.model.crystal import crystal_model
from dxtbx.model.experiment import beam_factory, goniometer_factory

### local functions
def random_direction_close_to(vector):
  return vector.rotate_around_origin(matrix.col(
              (random.random(),
               random.random(),
               random.random())).normalize(),
               random.gauss(0, 1.0),  deg = True)

### Create models

# make a beam vector close to the Z axis
direction = random_direction_close_to(matrix.col((0, 0, 1)))
mybeam = beam_factory.make_beam(direction, 1.5)

# make a random P1 crystal
a = random.uniform(10,20) * random_direction_close_to(matrix.col((1, 0, 0)))
b = random.uniform(10,20) * random_direction_close_to(matrix.col((0, 1, 0)))
c = random.uniform(10,20) * random_direction_close_to(matrix.col((0, 0, 1)))
crystal_model(a, b, c, space_group_symbol="P 1")

# make a dumb goniometer that rotates around X
mygonio = goniometer_factory.known_axis((1, 0, 0))

# generate some indices
resolution = 2.0
indices = full_sphere_indices(
    unit_cell = mycrystal.get_unit_cell(),
    resolution_limit = resolution,