Пример #1
0
 def compute_max_block_size(self):
     """
     Compute the required memory
     """
     total_memory = psutil.virtual_memory().total
     max_memory_usage = self.params.integration.block.max_memory_usage
     assert max_memory_usage > 0.0, "maximum memory usage must be > 0"
     assert max_memory_usage <= 1.0, "maximum memory usage must be <= 1"
     limit_memory = int(floor(total_memory * max_memory_usage))
     return MultiThreadedReferenceProfiler.compute_max_block_size(
         self.experiments[0].imageset, max_memory_usage=limit_memory)
Пример #2
0
    def compute_reference_profiles(self, imageset):
        """
        Integrate the reflections
        """
        from dials.algorithms.integration.integrator import frame_hist

        # Compute the partiality
        self.reflections.compute_partiality(self.experiments)

        # Get some info
        EPS = 1e-7
        full_value = 0.997300203937 - EPS
        fully_recorded = self.reflections["partiality"] > full_value
        npart = fully_recorded.count(False)
        nfull = fully_recorded.count(True)
        select_ice = self.reflections.get_flags(
            self.reflections.flags.in_powder_ring)
        select_int = ~self.reflections.get_flags(
            self.reflections.flags.dont_integrate)
        nice = select_ice.count(True)
        nint = select_int.count(True)
        ntot = len(self.reflections)
        frame0, frame1 = imageset.get_scan().get_array_range()

        # Write some output
        logger.info(" Beginning integration job %d" % self.index)
        logger.info("")
        logger.info(" Frames: %d -> %d" % (frame0, frame1))
        logger.info("")
        logger.info(" Number of reflections")
        logger.info("  Partial:     %d" % npart)
        logger.info("  Full:        %d" % nfull)
        logger.info("  In ice ring: %d" % nice)
        logger.info("  Integrate:   %d" % nint)
        logger.info("  Total:       %d" % ntot)
        logger.info("")

        # Print a histogram of reflections on frames
        if frame1 - frame0 > 1:
            logger.info(
                " The following histogram shows the number of reflections predicted"
            )
            logger.info(
                " to have all or part of their intensity on each frame.")
            logger.info("")
            logger.info(
                frame_hist(self.reflections["bbox"].select(select_int),
                           prefix=" ",
                           symbol="*"))
            logger.info("")

        # Construct the mask algorithm
        compute_mask = MaskCalculatorFactory.create(self.experiments,
                                                    self.params)

        # Construct the background algorithm
        compute_background = BackgroundCalculatorFactory.create(
            self.experiments, self.params)

        # Construct the intensity algorithm
        compute_reference = ReferenceCalculatorFactory.create(
            self.experiments, self.params)

        # Call the multi threaded integrator
        reference_calculator = MultiThreadedReferenceProfiler(
            reflections=self.reflections,
            imageset=imageset,
            compute_mask=compute_mask,
            compute_background=compute_background,
            compute_reference=compute_reference,
            logger=Logger(logger),
            nthreads=self.params.integration.mp.nproc,
            buffer_size=self.params.integration.block.size,
            use_dynamic_mask=self.params.integration.use_dynamic_mask,
            debug=self.params.integration.debug.output,
        )

        # Assign the reflections
        self.reflections = reference_calculator.reflections()

        # Assign the reference profiles
        self.reference = compute_reference

        # Write some log output
        fmt = "Used %d / %d reflections to create reference profiles"
        dont_integrate = self.reflections.get_flags(
            self.reflections.flags.dont_integrate)
        used_in_modelling = self.reflections.get_flags(
            self.reflections.flags.used_in_modelling)
        n_tot = dont_integrate.count(False)
        n_mod = (used_in_modelling & ~dont_integrate).count(True)
        logger.info("")
        logger.info(fmt % (n_mod, n_tot))