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)
Пример #2
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
    }
Пример #3
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)