Ejemplo n.º 1
0
def test(dials_regression, tmpdir):
  tmpdir.chdir()

  from dxtbx.serialize import load
  from dials.algorithms import shoebox
  from dials.array_family import flex

  # Load the sweep and crystal
  sweep_filename = os.path.join(dials_regression, 'centroid_test_data', 'sweep.json')
  crystal_filename = os.path.join(dials_regression, 'centroid_test_data', 'crystal.json')

  sweep = load.imageset(sweep_filename)
  crystal = load.crystal(crystal_filename)

  # Get models from the sweep
  beam = sweep.get_beam()
  detector = sweep.get_detector()
  gonio = sweep.get_goniometer()
  scan = sweep.get_scan()

  # Get the reflections and overlaps
  reflections, adjacency_list = predict_reflections(sweep, crystal)
  reflections['shoebox'] = flex.shoebox(
    reflections['panel'],
    reflections['bbox'])
  reflections['shoebox'].allocate_with_value(shoebox.MaskCode.Valid)

  # If the adjacency list is given, then create the reflection mask
  assert(len(detector) == 1)
  image_size = detector[0].get_image_size()
  shoeboxes = reflections['shoebox']
  coords = reflections['xyzcal.px']
  shoebox_masker = shoebox.MaskOverlapping()
  shoebox_masker(shoeboxes, coords, adjacency_list)

  # Loop through all edges
  overlapping = []
  for e in adjacency_list.edges():
    v1, v2 = adjacency_list.source(e), adjacency_list.target(e)
    overlapping.append(v1)
    overlapping.append(v2)

  # Ensure elements are unique
  overlapping = set(overlapping)

  # Ensure we have some overlaps
  assert len(overlapping) > 0

  # Get all non-overlapping reflections
  all_r = set(range(len(reflections)))
  non_overlapping = all_r.difference(overlapping)

  # Run the tests
  tst_non_overlapping(reflections, non_overlapping,
      detector[0].get_image_size())
  tst_overlapping(reflections, overlapping, adjacency_list,
      image_size)
Ejemplo n.º 2
0
def test(dials_data):
    from dxtbx.serialize import load

    from dials.algorithms import shoebox
    from dials.array_family import flex

    # Load the sequence and crystal
    sequence = load.imageset(
        dials_data("centroid_test_data").join("sweep.json").strpath
    )
    crystal = load.crystal(
        dials_data("centroid_test_data").join("crystal.json").strpath
    )

    # Get models from the sequence
    detector = sequence.get_detector()

    # Get the reflections and overlaps
    reflections, adjacency_list = predict_reflections(sequence, crystal)
    reflections["shoebox"] = flex.shoebox(reflections["panel"], reflections["bbox"])
    reflections["shoebox"].allocate_with_value(shoebox.MaskCode.Valid)

    # If the adjacency list is given, then create the reflection mask
    assert len(detector) == 1
    image_size = detector[0].get_image_size()
    shoeboxes = reflections["shoebox"]
    coords = reflections["xyzcal.px"]
    shoebox_masker = shoebox.MaskOverlapping()
    shoebox_masker(shoeboxes, coords, adjacency_list)

    # Loop through all edges
    overlapping = []
    for e in adjacency_list.edges():
        v1, v2 = adjacency_list.source(e), adjacency_list.target(e)
        overlapping.append(v1)
        overlapping.append(v2)

    # Ensure elements are unique
    overlapping = set(overlapping)

    # Ensure we have some overlaps
    assert len(overlapping) > 0

    # Get all non-overlapping reflections
    all_r = set(range(len(reflections)))
    non_overlapping = all_r.difference(overlapping)

    # Run the tests
    tst_non_overlapping(reflections, non_overlapping, detector[0].get_image_size())
    tst_overlapping(reflections, overlapping, adjacency_list, image_size)
Ejemplo n.º 3
0
    def run(self):
        from dials.model.serialize import load
        from dials.algorithms import shoebox
        from dxtbx.serialize.load import crystal as load_crystal
        from dials.array_family import flex

        # Load the sweep and crystal
        self.sweep = load.sweep(self.sweep_filename)
        self.crystal = load_crystal(self.crystal_filename)

        # Get the reflections and overlaps
        reflections, adjacency_list = self.predict_reflections()
        reflections['shoebox'] = flex.shoebox(reflections['panel'],
                                              reflections['bbox'])
        reflections['shoebox'].allocate_with_value(shoebox.MaskCode.Valid)

        # If the adjacency list is given, then create the reflection mask
        assert (len(self.detector) == 1)
        image_size = self.detector[0].get_image_size()
        shoeboxes = reflections['shoebox']
        coords = reflections['xyzcal.px']
        shoebox_masker = shoebox.MaskOverlapping()
        shoebox_masker(shoeboxes, coords, adjacency_list)

        # Loop through all edges
        overlapping = []
        for e in adjacency_list.edges():
            v1, v2 = adjacency_list.source(e), adjacency_list.target(e)
            overlapping.append(v1)
            overlapping.append(v2)

        # Ensure elements are unique
        overlapping = set(overlapping)

        # Ensure we have some overlaps
        assert (len(overlapping) > 0)

        # Get all non-overlapping reflections
        all_r = set(range(len(reflections)))
        non_overlapping = all_r.difference(overlapping)

        # Run the tests
        self.tst_non_overlapping(reflections, non_overlapping,
                                 self.detector[0].get_image_size())
        self.tst_overlapping(reflections, overlapping, adjacency_list,
                             image_size)