Example #1
0
def test_dps_single_panel_labelit_input_optimal_origin(process_dictionary,
                                                       data, phil_set):
    from rstbx.indexing_api.lattice import DPS_primitive_lattice
    from scitbx.matrix import col

    sample_to_beamspot = col((0., 0., float(process_dictionary['distance'])))
    detector_d1 = col((1., 0., 0.))
    detector_d2 = col((0., 1., 0.))
    detector_origin = sample_to_beamspot - \
      detector_d1 * float(process_dictionary['xbeam']) - \
      detector_d2 * float(process_dictionary['ybeam'])
    assert detector_d1.length() == 1.0
    assert detector_d2.length() == 1.0
    assert detector_d1.dot(detector_d2) == 0.0

    from dxtbx.model.detector import detector_factory
    detector = detector_factory.make_detector(
        stype="indexing",
        fast_axis=detector_d1,
        slow_axis=detector_d2,
        origin=detector_origin,
        pixel_size=(float(process_dictionary['pixel_size']),
                    float(process_dictionary['pixel_size'])),
        image_size=(int(process_dictionary['size1']),
                    int(process_dictionary['size2'])))

    beam_vector = sample_to_beamspot.normalize() * (
        1. / float(process_dictionary['wavelength']))
    rot_axis = col(process_dictionary["endstation"].rot_axi) - col(
        (0.0, 0.0, 0.0))  # coerce to float type

    DPS = DPS_primitive_lattice(
        max_cell=float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad=process_dictionary[
            'recommended_grid_sampling'],
        horizon_phil=phil_set)
    DPS.set_beam_vector(beam=-beam_vector)
    DPS.set_rotation_axis(axis=rot_axis)
    DPS.set_detector(detector)

    DPS.index(raw_spot_input=data)
    #L = DPS.get_basis_general() # can skip this first time around
    new_detector = DPS.optimize_origin_offset_local_scope()

    DPS2 = DPS_primitive_lattice(
        max_cell=float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad=process_dictionary[
            'recommended_grid_sampling'],
        horizon_phil=phil_set)
    DPS2.set_beam_vector(beam=-beam_vector)
    DPS2.set_rotation_axis(axis=rot_axis)
    DPS2.set_detector(new_detector)
    DPS2.index(raw_spot_input=data)
    L = DPS2.get_basis_general()
def run_dps(args):
  imageset, spots_mm, max_cell, params = args

  detector = imageset.get_detector()
  beam = imageset.get_beam()
  goniometer = imageset.get_goniometer()
  scan = imageset.get_scan()

  from rstbx.indexing_api.lattice import DPS_primitive_lattice
  # max_cell: max possible cell in Angstroms; set to None, determine from data
  # recommended_grid_sampling_rad: grid sampling in radians; guess for now

  DPS = DPS_primitive_lattice(max_cell=max_cell,
                              recommended_grid_sampling_rad=None,
                              horizon_phil=params)

  from scitbx import matrix
  DPS.S0_vector = matrix.col(beam.get_s0())
  DPS.inv_wave = 1./beam.get_wavelength()
  if goniometer is None:
    DPS.axis = matrix.col((1,0,0))
  else:
    DPS.axis = matrix.col(goniometer.get_rotation_axis())
  DPS.set_detector(detector)

  # transform input into what Nick needs
  # i.e., construct a flex.vec3 double consisting of mm spots, phi in degrees

  data = flex.vec3_double()
  for spot in spots_mm:
    data.append((spot['xyzobs.mm.value'][0],
                 spot['xyzobs.mm.value'][1],
                 spot['xyzobs.mm.value'][2]*180./math.pi))

  #from matplotlib import pyplot as plt
  #plt.plot([spot.centroid_position[0] for spot in spots_mm] , [spot.centroid_position[1] for spot in spots_mm], 'ro')
  #plt.show()

  logger.info("Running DPS using %i reflections" %len(data))

  DPS.index(raw_spot_input=data,
            panel_addresses=flex.int([s['panel'] for s in spots_mm]))
  solutions = DPS.getSolutions()
  from libtbx.utils import plural_s
  logger.info("Found %i solution%s with max unit cell %.2f Angstroms." %(
    len(solutions), plural_s(len(solutions))[1], DPS.amax))
  if len(solutions) < 3:
    from libtbx.utils import Sorry
    raise Sorry("Not enough solutions: found %i, need at least 3" %(
      len(solutions)))
  return dict(solutions=flex.vec3_double(
    [s.dvec for s in solutions]), amax=DPS.amax)
Example #3
0
def test_out(process_dictionary, data, phil_set):
    from rstbx.indexing_api.lattice import DPS_primitive_lattice
    from scitbx.matrix import col

    sample_to_beamspot = col((0., 0., float(process_dictionary['distance'])))
    detector_d1 = col((1., 0., 0.))
    detector_d2 = col((0., 1., 0.))
    detector_origin = sample_to_beamspot - \
      detector_d1 * float(process_dictionary['xbeam']) - \
      detector_d2 * float(process_dictionary['ybeam'])
    assert detector_d1.length() == 1.0
    assert detector_d2.length() == 1.0
    assert detector_d1.dot(detector_d2) == 0.0

    beam_vector = sample_to_beamspot.normalize() * (
        1. / float(process_dictionary['wavelength']))
    rot_axis = col(process_dictionary["endstation"].rot_axi) - col(
        (0.0, 0.0, 0.0))  # coerce to float type

    DPS = DPS_primitive_lattice(
        max_cell=float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad=process_dictionary[
            'recommended_grid_sampling'],
        horizon_phil=phil_set)
    DPS.set_beam_vector(beam=-beam_vector)
    DPS.set_rotation_axis(axis=rot_axis)
    DPS.set_detector_position(origin=detector_origin,
                              d1=detector_d1,
                              d2=detector_d2)

    DPS.index(raw_spot_input=data)
    L = DPS.get_basis_general()

    new_detector = DPS.optimize_origin_offset_local_scope()

    DPS2 = DPS_primitive_lattice(
        max_cell=float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad=process_dictionary[
            'recommended_grid_sampling'],
        horizon_phil=phil_set)
    DPS2.set_beam_vector(beam=-beam_vector)
    DPS2.set_rotation_axis(axis=rot_axis)
    DPS2.set_detector(new_detector)
    DPS2.index(raw_spot_input=data)
    L = DPS2.get_basis_general()

    from rstbx.indexing_api.outlier_procedure import main_go
    main_go(index_engine=DPS2, phil_set=phil_set)

    print "Finishing"
    exit()
Example #4
0
def test_dps_single_panel_labelit_input_optimal_origin(process_dictionary,data,phil_set):
    from rstbx.indexing_api.lattice import DPS_primitive_lattice
    from scitbx.matrix import col

    sample_to_beamspot = col((0.,0.,float(process_dictionary['distance'])))
    detector_d1 = col((1., 0., 0.))
    detector_d2 = col((0., 1., 0.))
    detector_origin = sample_to_beamspot - \
      detector_d1 * float(process_dictionary['xbeam']) - \
      detector_d2 * float(process_dictionary['ybeam'])
    assert detector_d1.length() == 1.0
    assert detector_d2.length() == 1.0
    assert detector_d1.dot(detector_d2) == 0.0

    from dxtbx.model.detector import detector_factory
    detector = detector_factory.make_detector(
      stype = "indexing",
      fast_axis = detector_d1,
      slow_axis = detector_d2,
      origin = detector_origin,
      pixel_size = (float(process_dictionary['pixel_size']),
                    float(process_dictionary['pixel_size'])),
      image_size = (int(process_dictionary['size1']),
                    int(process_dictionary['size2']))
      )

    beam_vector = sample_to_beamspot.normalize() * (
                  1./float(process_dictionary['wavelength']))
    rot_axis = col(process_dictionary["endstation"].rot_axi) - col((0.0,0.0,0.0)) # coerce to float type

    DPS = DPS_primitive_lattice(max_cell = float(process_dictionary['ref_maxcel']),
          recommended_grid_sampling_rad = process_dictionary['recommended_grid_sampling'],
          horizon_phil = phil_set)
    DPS.set_beam_vector(beam = -beam_vector)
    DPS.set_rotation_axis(axis = rot_axis)
    DPS.set_detector(detector)

    DPS.index(raw_spot_input = data)
    #L = DPS.get_basis_general() # can skip this first time around
    new_detector = DPS.optimize_origin_offset_local_scope()

    DPS2= DPS_primitive_lattice(max_cell = float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad = process_dictionary['recommended_grid_sampling'],
        horizon_phil = phil_set)
    DPS2.set_beam_vector(beam = -beam_vector)
    DPS2.set_rotation_axis(axis = rot_axis)
    DPS2.set_detector(new_detector)
    DPS2.index(raw_spot_input = data)
    L = DPS2.get_basis_general()
Example #5
0
def run_dps(experiment, spots_mm, max_cell):
    # max_cell: max possible cell in Angstroms; set to None, determine from data
    # recommended_grid_sampling_rad: grid sampling in radians; guess for now

    horizon_phil = iotbx.phil.parse(input_string=indexing_api_defs).extract()
    DPS = DPS_primitive_lattice(max_cell=max_cell,
                                recommended_grid_sampling_rad=None,
                                horizon_phil=horizon_phil)

    DPS.S0_vector = matrix.col(experiment.beam.get_s0())
    DPS.inv_wave = 1.0 / experiment.beam.get_wavelength()
    if experiment.goniometer is None:
        DPS.axis = matrix.col((1, 0, 0))
    else:
        DPS.axis = matrix.col(experiment.goniometer.get_rotation_axis())
    DPS.set_detector(experiment.detector)

    # transform input into what DPS needs
    # i.e., construct a flex.vec3 double consisting of mm spots, phi in degrees
    data = flex.vec3_double()
    for spot in spots_mm.rows():
        data.append((
            spot["xyzobs.mm.value"][0],
            spot["xyzobs.mm.value"][1],
            spot["xyzobs.mm.value"][2] * 180.0 / math.pi,
        ))

    logger.info("Running DPS using %i reflections", len(data))

    DPS.index(
        raw_spot_input=data,
        panel_addresses=flex.int(s["panel"] for s in spots_mm.rows()),
    )
    solutions = DPS.getSolutions()

    logger.info(
        "Found %i solution%s with max unit cell %.2f Angstroms.",
        len(solutions),
        plural_s(len(solutions))[1],
        DPS.amax,
    )

    # There must be at least 3 solutions to make a set, otherwise return empty result
    if len(solutions) < 3:
        return {}
    return {
        "solutions": flex.vec3_double(s.dvec for s in solutions),
        "amax": DPS.amax
    }
Example #6
0
def run_dps(args):
    imageset, spots_mm, max_cell, params = args

    detector = imageset.get_detector()
    beam = imageset.get_beam()
    goniometer = imageset.get_goniometer()

    # max_cell: max possible cell in Angstroms; set to None, determine from data
    # recommended_grid_sampling_rad: grid sampling in radians; guess for now

    DPS = DPS_primitive_lattice(max_cell=max_cell,
                                recommended_grid_sampling_rad=None,
                                horizon_phil=params)

    DPS.S0_vector = matrix.col(beam.get_s0())
    DPS.inv_wave = 1.0 / beam.get_wavelength()
    if goniometer is None:
        DPS.axis = matrix.col((1, 0, 0))
    else:
        DPS.axis = matrix.col(goniometer.get_rotation_axis())
    DPS.set_detector(detector)

    # transform input into what Nick needs
    # i.e., construct a flex.vec3 double consisting of mm spots, phi in degrees

    data = flex.vec3_double()
    for spot in spots_mm.rows():
        data.append((
            spot["xyzobs.mm.value"][0],
            spot["xyzobs.mm.value"][1],
            spot["xyzobs.mm.value"][2] * 180.0 / math.pi,
        ))

    logger.info("Running DPS using %i reflections" % len(data))

    DPS.index(
        raw_spot_input=data,
        panel_addresses=flex.int(s["panel"] for s in spots_mm.rows()),
    )
    solutions = DPS.getSolutions()

    logger.info("Found %i solution%s with max unit cell %.2f Angstroms." %
                (len(solutions), plural_s(len(solutions))[1], DPS.amax))
    if len(solutions) < 3:

        raise Sorry("Not enough solutions: found %i, need at least 3" %
                    (len(solutions)))
    return dict(solutions=flex.vec3_double([s.dvec for s in solutions]),
                amax=DPS.amax)
def run_dps(args):
  imageset, spots_mm, max_cell, params = args

  detector = imageset.get_detector()
  beam = imageset.get_beam()
  goniometer = imageset.get_goniometer()
  scan = imageset.get_scan()

  from rstbx.indexing_api.lattice import DPS_primitive_lattice
  # max_cell: max possible cell in Angstroms; set to None, determine from data
  # recommended_grid_sampling_rad: grid sampling in radians; guess for now

  DPS = DPS_primitive_lattice(max_cell=max_cell,
                              recommended_grid_sampling_rad=None,
                              horizon_phil=params)

  from scitbx import matrix
  DPS.S0_vector = matrix.col(beam.get_s0())
  DPS.inv_wave = 1./beam.get_wavelength()
  if goniometer is None:
    DPS.axis = matrix.col((1,0,0))
  else:
    DPS.axis = matrix.col(goniometer.get_rotation_axis())
  DPS.set_detector(detector)

  # transform input into what Nick needs
  # i.e., construct a flex.vec3 double consisting of mm spots, phi in degrees

  data = flex.vec3_double()
  for spot in spots_mm:
    data.append((spot['xyzobs.mm.value'][0],
                 spot['xyzobs.mm.value'][1],
                 spot['xyzobs.mm.value'][2]*180./math.pi))

  #from matplotlib import pyplot as plt
  #plt.plot([spot.centroid_position[0] for spot in spots_mm] , [spot.centroid_position[1] for spot in spots_mm], 'ro')
  #plt.show()

  logger.info("Running DPS using %i reflections" %len(data))

  DPS.index(raw_spot_input=data,
            panel_addresses=flex.int([s['panel'] for s in spots_mm]))
  logger.info("Found %i solutions with max unit cell %.2f Angstroms." %(
    len(DPS.getSolutions()), DPS.amax))
  return dict(solutions=flex.vec3_double(
    [s.dvec for s in DPS.getSolutions()]), amax=DPS.amax)
Example #8
0
def test_out(process_dictionary,data,phil_set):
    from rstbx.indexing_api.lattice import DPS_primitive_lattice
    from scitbx.matrix import col

    sample_to_beamspot = col((0.,0.,float(process_dictionary['distance'])))
    detector_d1 = col((1., 0., 0.))
    detector_d2 = col((0., 1., 0.))
    detector_origin = sample_to_beamspot - \
      detector_d1 * float(process_dictionary['xbeam']) - \
      detector_d2 * float(process_dictionary['ybeam'])
    assert detector_d1.length() == 1.0
    assert detector_d2.length() == 1.0
    assert detector_d1.dot(detector_d2) == 0.0

    beam_vector = sample_to_beamspot.normalize() * (
                  1./float(process_dictionary['wavelength']))
    rot_axis = col(process_dictionary["endstation"].rot_axi) - col((0.0,0.0,0.0)) # coerce to float type

    DPS = DPS_primitive_lattice(max_cell = float(process_dictionary['ref_maxcel']),
          recommended_grid_sampling_rad = process_dictionary['recommended_grid_sampling'],
          horizon_phil = phil_set)
    DPS.set_beam_vector(beam = -beam_vector)
    DPS.set_rotation_axis(axis = rot_axis)
    DPS.set_detector_position(origin = detector_origin, d1 = detector_d1, d2 = detector_d2)

    DPS.index(raw_spot_input = data)
    L = DPS.get_basis_general()


    new_detector = DPS.optimize_origin_offset_local_scope()

    DPS2= DPS_primitive_lattice(max_cell = float(process_dictionary['ref_maxcel']),
        recommended_grid_sampling_rad = process_dictionary['recommended_grid_sampling'],
        horizon_phil = phil_set)
    DPS2.set_beam_vector(beam = -beam_vector)
    DPS2.set_rotation_axis(axis = rot_axis)
    DPS2.set_detector(new_detector)
    DPS2.index(raw_spot_input = data)
    L = DPS2.get_basis_general()

    from rstbx.indexing_api.outlier_procedure import main_go
    main_go(index_engine=DPS2, phil_set=phil_set)

    print "Finishing"
    exit()