コード例 #1
0
    def _compute_mask_from_sigma_d(self):
        """
        Compute the spot mask

        """
        logger.info("Creating the foreground mask for %d reflections" %
                    len(self.reflections))

        # Initialise the mask calculator
        mask_foreground = MaskCalculator(
            self.experiments[0].crystal,
            self.experiments[0].beam,
            self.experiments[0].detector,
            self.experiments[0].goniometer,
            self.experiments[0].scan,
            self.sigma_d * 3,
            0,
        )

        # Compute the reflection mask
        mask_foreground(
            self.reflections["shoebox"],
            self.reflections["s1"],
            self.reflections["xyzcal.px"].parts()[2],
            self.reflections["panel"],
        )
コード例 #2
0
ファイル: model.py プロジェクト: kmdalton/dials
    def compute_mask(
        self,
        reflections,
        crystal,
        beam,
        detector,
        goniometer=None,
        scan=None,
        image_volume=None,
        **kwargs,
    ):
        """
        Given an experiment and list of reflections, compute the
        foreground/background mask of the reflections.

        :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 MaskCalculator

        # 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
        delta_m = self._n_sigma * self._sigma_m

        # Create the mask calculator
        mask_foreground = MaskCalculator(
            crystal, beam, detector, goniometer, scan, delta_b, delta_m
        )

        # Mask the foreground region
        if image_volume is None:
            return mask_foreground(
                reflections["shoebox"],
                reflections["s1"],
                reflections["xyzcal.px"].parts()[2],
                reflections["panel"],
            )
        else:
            return mask_foreground(
                image_volume,
                reflections["bbox"],
                reflections["s1"],
                reflections["xyzcal.px"].parts()[2],
                reflections["panel"],
            )
コード例 #3
0
def _compute_mask(experiment,
                  reflection_table,
                  sigma_d,
                  s1="s1_obs",
                  strong_shoeboxes=None):
    """Compute the spot mask"""

    # Initialise the mask calculator
    mask_foreground = MaskCalculator(
        experiment.crystal,
        experiment.beam,
        experiment.detector,
        experiment.goniometer,
        experiment.scan,
        sigma_d * 3,
        0,
    )

    # Compute the reflection mask
    mask_foreground(
        reflection_table["shoebox"],
        reflection_table[s1],
        reflection_table["xyzcal.px"].parts()[2],
        reflection_table["panel"],
    )

    # if strong_shoeboxes given, apply the mask from this
    if strong_shoeboxes:
        # Apply strong spot mask
        assert len(reflection_table) == len(strong_shoeboxes)
        new_shoeboxes = reflection_table["shoebox"]
        for s in range(len(new_shoeboxes)):
            bbox_old = strong_shoeboxes[s].bbox
            mask_old = strong_shoeboxes[s].mask
            bbox_new = new_shoeboxes[s].bbox
            mask_new = new_shoeboxes[s].mask
            for j in range(mask_old.all()[1]):
                for i in range(mask_old.all()[2]):
                    ii = bbox_old[0] + i - bbox_new[0]
                    jj = bbox_old[2] + j - bbox_new[2]
                    if mask_old[0, j, i] == 5:
                        if (ii >= 0 and jj >= 0 and jj < mask_new.all()[1]
                                and ii < mask_new.all()[2]):
                            assert mask_new[0, jj, ii] & (1 << 0)
                            mask_new[0, jj, ii] |= (1 << 2) | (1 << 3)
コード例 #4
0
    def _compute_mask(self):
        """
        Compute the spot mask

        """
        logger.info("Creating the foreground mask for %d reflections" %
                    len(self.reflections))

        # Initialise the mask calculator
        mask_foreground = MaskCalculator(
            self.experiments[0].crystal,
            self.experiments[0].beam,
            self.experiments[0].detector,
            self.experiments[0].goniometer,
            self.experiments[0].scan,
            self.sigma_d * 3,
            0,
        )

        # Compute the reflection mask
        mask_foreground(
            self.reflections["shoebox"],
            self.reflections["s1_obs"],
            self.reflections["xyzcal.px"].parts()[2],
            self.reflections["panel"],
        )

        # Apply strong spot mask
        assert len(self.reflections) == len(self.shoeboxes)
        new_shoeboxes = self.reflections["shoebox"]
        old_shoeboxes = self.shoeboxes
        for s in range(len(new_shoeboxes)):
            bbox_old = old_shoeboxes[s].bbox
            mask_old = old_shoeboxes[s].mask
            bbox_new = new_shoeboxes[s].bbox
            mask_new = new_shoeboxes[s].mask
            for j in range(mask_old.all()[1]):
                for i in range(mask_old.all()[2]):
                    ii = bbox_old[0] + i - bbox_new[0]
                    jj = bbox_old[2] + j - bbox_new[2]
                    if mask_old[0, j, i] == 5:
                        if (ii >= 0 and jj >= 0 and jj < mask_new.all()[1]
                                and ii < mask_new.all()[2]):
                            assert mask_new[0, jj, ii] & (1 << 0)
                            mask_new[0, jj, ii] |= (1 << 2) | (1 << 3)
コード例 #5
0
    def _compute_mask(self):
        """
        Compute the spot mask

        """
        print("Creating the foreground mask for %d reflections" %
              len(self.reflections))
        mask_foreground = MaskCalculator(
            self.experiments[0].crystal,
            self.experiments[0].beam,
            self.experiments[0].detector,
            self.experiments[0].goniometer,
            self.experiments[0].scan,
            self.sigma_d * 3,
            0,
        )
        mask_foreground(
            self.reflections["shoebox"],
            self.reflections["s1"],
            self.reflections["xyzcal.px"].parts()[2],
            self.reflections["panel"],
        )