Esempio n. 1
0
    def compute_bbox(
        self,
        reflections,
        crystal,
        beam,
        detector,
        goniometer=None,
        scan=None,
        sigma_b_multiplier=2.0,
        **kwargs,
    ):
        """Given an experiment and list of reflections, compute the
        bounding box of the reflections on the detector (and image frames).

        :param reflections: The reflection table
        :param crystal: The crystal model
        :param beam: The beam model
        :param detector: The detector model
        :param goniometer: The goniometer model
        :param scan: The scan model
        """
        from dials.algorithms.profile_model.gaussian_rs import BBoxCalculator

        # Check the input
        assert sigma_b_multiplier >= 1.0

        # Compute the size in reciprocal space. Add a sigma_b multiplier to enlarge
        # the region of background in the shoebox
        delta_b = self._n_sigma * self._sigma_b * sigma_b_multiplier
        delta_m = self._n_sigma * self._sigma_m

        # Create the bbox calculator
        calculate = BBoxCalculator(
            crystal, beam, detector, goniometer, scan, delta_b, delta_m
        )

        # Calculate the bounding boxes of all the reflections
        bbox = calculate(
            reflections["s1"], reflections["xyzcal.px"].parts()[2], reflections["panel"]
        )

        # Return the bounding boxes
        return bbox
Esempio n. 2
0
def _compute_bbox(experiment, reflection_table, sigma_d, s1="s1_obs"):
    """Compute the bounding box"""

    # Initialise the bounding box calculator
    compute_bbox = BBoxCalculator(
        experiment.crystal,
        experiment.beam,
        experiment.detector,
        experiment.goniometer,
        experiment.scan,
        sigma_d * 6,
        0,
    )

    # Compute the bounding box
    bbox = compute_bbox(
        reflection_table[s1],
        reflection_table["xyzcal.px"].parts()[2],
        reflection_table["panel"],
    )

    return bbox
Esempio n. 3
0
    def _compute_bbox_from_sigma_d(self):
        """
        Compute the bounding box

        """

        logger.info("Computing the bounding box for %d reflections" %
                    len(self.reflections))

        # Initialise the bounding box calculator
        compute_bbox = BBoxCalculator(
            self.experiments[0].crystal,
            self.experiments[0].beam,
            self.experiments[0].detector,
            self.experiments[0].goniometer,
            self.experiments[0].scan,
            self.sigma_d * 6,
            0,
        )

        # Compute the bounding box
        bbox = compute_bbox(
            self.reflections["s1"],
            self.reflections["xyzcal.px"].parts()[2],
            self.reflections["panel"],
        )

        # Set in the reflection table
        self.reflections["bbox"] = bbox

        # Select reflections within detector
        x0, x1, y0, y1, _, _ = self.reflections["bbox"].parts()
        xsize, ysize = self.experiments[0].detector[0].get_image_size()
        selection = (x1 > 0) & (y1 > 0) & (x0 < xsize) & (y0 < ysize)
        self.reflections = self.reflections.select(selection)
        logger.info("Filtered reflections with bbox outside image range")
        logger.info("Kept %d reflections" % len(self.reflections))