Esempio n. 1
0
    def __init__(self, index, job, experiments, reflections, params=None):
        """
        Initialise the task.

        :param index: The index of the processing job
        :param experiments: The list of experiments
        :param reflections: The list of reflections
        :param params: The processing parameters
        :param job: The frames to integrate
        :param flatten: Flatten the shoeboxes
        :param save_shoeboxes: Save the shoeboxes to file
        :param executor: The executor class
        """

        # Get the parameters
        if params is None:
            from dials.command_line.integrate import phil_scope

            params = phil_scope.extract()

        assert len(reflections) > 0, "Zero reflections given"
        assert (params.integration.block.max_memory_usage >
                0.0), "Max memory % must be > 0"
        assert (params.integration.block.max_memory_usage <=
                1.0), "Max memory % must be < 1"
        self.index = index
        self.job = job
        self.experiments = experiments
        self.reflections = reflections
        self.params = params
Esempio n. 2
0
    def create(cls, experiments, params=None):
        """
        Select the reference calculator
        """
        from dials.algorithms.profile_model.gaussian_rs.algorithm import (
            GaussianRSReferenceCalculatorFactory, )

        # Get the parameters
        if params is None:
            from dials.command_line.integrate import phil_scope

            params = phil_scope.extract()

        # Select the factory function
        selection = params.profile.algorithm
        if selection == "gaussian_rs":

            # Get the parameters
            params = params.profile.gaussian_rs.fitting

            # Create the algorithm
            algorithm = GaussianRSReferenceCalculatorFactory.create(
                experiments,
                grid_size=params.grid_size,
                scan_step=params.scan_step,
                grid_method=params.grid_method,
            )

        else:
            raise RuntimeError("Unknown profile model algorithm")

        # Return the algorithm
        return algorithm
Esempio n. 3
0
    def create(cls, experiments, reference_profiles, params=None):
        """
        Select the intensity calculator

        """
        from dials.algorithms.profile_model.gaussian_rs.algorithm import (
            GaussianRSIntensityCalculatorFactory,
        )

        # Get the parameters
        if params is None:
            from dials.command_line.integrate import phil_scope

            params = phil_scope.extract()

        # Select the factory function
        selection = params.profile.algorithm
        if selection == "gaussian_rs":

            # Get the parameters
            params = params.profile.gaussian_rs.fitting

            # Check for detector space
            if params.fit_method == "reciprocal_space":
                detector_space = False
            elif params.fit_method == "detector_space":
                detector_space = True
            else:
                raise RuntimeError("Unknown fit method: %s" % params.fit_method)

            # Create the algorithm
            algorithm = GaussianRSIntensityCalculatorFactory.create(
                reference_profiles,
                detector_space=detector_space,
                deconvolution=params.detector_space.deconvolution,
            )

        else:
            raise RuntimeError("Unknown profile model algorithm")

        # Return the algorithm
        return algorithm
Esempio n. 4
0
  def create(Class, experiments, params=None):
    '''
    Select the mask calculator

    '''
    from dials.algorithms.profile_model.gaussian_rs.algorithm import GaussianRSMaskCalculatorFactory

    # Get the parameters
    if params is None:
      from dials.command_line.integrate import phil_scope
      params = phil_scope.extract()

    # Select the factory function
    selection = params.profile.algorithm
    if selection == "gaussian_rs":
      algorithm = GaussianRSMaskCalculatorFactory.create(experiments)
    else:
      raise RuntimeError("Unknown profile model algorithm")

    # Create the mask algorithm
    return algorithm
Esempio n. 5
0
    def create(cls, experiments, params=None):
        """
        Select the background calculator
        """
        from dials.algorithms.background.simple.algorithm import (
            SimpleBackgroundCalculatorFactory, )
        from dials.algorithms.background.glm.algorithm import (
            GLMBackgroundCalculatorFactory, )
        from dials.algorithms.background.gmodel.algorithm import (
            GModelBackgroundCalculatorFactory, )

        # Get the parameters
        if params is None:
            from dials.command_line.integrate import phil_scope

            params = phil_scope.extract()

        # Select the factory function
        selection = params.integration.background.algorithm
        if selection == "simple":

            # Get parameters
            params = params.integration.background.simple

            # Create some keyword parameters
            kwargs = {
                "model": params.model.algorithm,
                "outlier": params.outlier.algorithm,
                "min_pixels": params.min_pixels,
            }

            # Create all the keyword parameters
            if params.outlier.algorithm == "null":
                pass
            elif params.outlier.algorithm == "truncated":
                kwargs["lower"] = params.outlier.truncated.lower
                kwargs["upper"] = params.outlier.truncated.upper
            elif params.outlier.algorithm == "nsigma":
                kwargs["lower"] = params.outlier.nsigma.lower
                kwargs["upper"] = params.outlier.nsigma.upper
            elif params.outlier.algorithm == "normal":
                kwargs["min_pixels"] = params.outlier.normal.min_pixels
            elif params.outlier.algorithm == "plane":
                kwargs["fraction"] = params.outlier.plane.fraction
                kwargs["n_sigma"] = params.outlier.plane.n_sigma
            elif params.outlier.algorithm == "tukey":
                kwargs["lower"] = params.outlier.tukey.lower
                kwargs["upper"] = params.outlier.tukey.upper

            # Create the algorithm
            algorithm = SimpleBackgroundCalculatorFactory.create(
                experiments, **kwargs)

        elif selection == "glm":

            # Get the parameters
            params = params.integration.background.glm

            # Create the algorithm
            algorithm = GLMBackgroundCalculatorFactory.create(
                experiments,
                model=params.model.algorithm,
                tuning_constant=params.robust.tuning_constant,
                min_pixels=params.min_pixels,
            )

        elif selection == "gmodel":

            # Get the parameters
            params = params.integration.background.gmodel

            # Create the algorithm
            algorithm = GModelBackgroundCalculatorFactory.create(
                experiments,
                model=params.model,
                robust=params.robust.algorithm,
                tuning_constant=params.robust.tuning_constant,
                min_pixels=params.min_pixels,
            )

        else:
            raise RuntimeError("Unknown background algorithm")

        # Return the background calculator
        return algorithm
Esempio n. 6
0
  def create(Class, experiments, params=None):
    '''
    Select the background calculator

    '''
    from dials.algorithms.background.simple.algorithm import SimpleBackgroundCalculatorFactory
    from dials.algorithms.background.glm.algorithm import GLMBackgroundCalculatorFactory
    from dials.algorithms.background.gmodel.algorithm import GModelBackgroundCalculatorFactory

    # Get the parameters
    if params is None:
      from dials.command_line.integrate import phil_scope
      params = phil_scope.extract()

    # Select the factory function
    selection = params.integration.background.algorithm
    if selection == "simple":

      # Get parameters
      params = params.integration.background.simple

      # Create some keyword parameters
      kwargs = {
        'model'      : params.model.algorithm,
        'outlier'    : params.outlier.algorithm,
        'min_pixels' : params.min_pixels
      }

      # Create all the keyword parameters
      if params.outlier.algorithm == 'null':
        pass
      elif params.outlier.algorithm == 'truncated':
        kwargs['lower'] = params.outlier.truncated.lower
        kwargs['upper'] = params.outlier.truncated.upper
      elif params.outlier.algorithm == 'nsigma':
        kwargs['lower'] = params.outlier.nsigma.lower
        kwargs['upper'] = params.outlier.nsigma.upper
      elif params.outlier.algorithm == 'normal':
        kwargs['min_pixels'] = params.outlier.normal.min_pixels
      elif params.outlier.algorithm == 'plane':
        kwargs['fraction'] = params.outlier.plane.fraction
        kwargs['n_sigma'] = params.outlier.plane.n_sigma
      elif params.outlier.algorithm == 'tukey':
        kwargs['lower'] = params.outlier.tukey.lower
        kwargs['upper'] = params.outlier.tukey.upper

      # Create the algorithm
      algorithm = SimpleBackgroundCalculatorFactory.create(experiments, **kwargs)

    elif selection == "glm":

      # Get the parameters
      params = params.integration.background.glm

      # Create the algorithm
      algorithm = GLMBackgroundCalculatorFactory.create(
        experiments,
        model           = params.model.algorithm,
        tuning_constant = params.robust.tuning_constant,
        min_pixels      = params.min_pixels)

    elif selection == "gmodel":

      # Get the parameters
      params = params.integration.background.gmodel

      # Create the algorithm
      algorithm = GModelBackgroundCalculatorFactory.create(
        experiments,
        model           = params.model,
        robust          = params.robust.algorithm,
        tuning_constant = params.robust.tuning_constant,
        min_pixels      = params.min_pixels)

    else:
      raise RuntimeError("Unknown background algorithm")

    # Return the background calculator
    return algorithm
Esempio n. 7
0
    experiments = read_experiments(experiments_filename)
    reflections = read_reflections(reflections_filename)
    reference = read_reference(reference_filename)

    reference = construct_reference(experiments, reference[0])

    print("Dynamic Mask: ", experiments[0].imageset.has_dynamic_mask())

    print("Read %d reflections" % len(reflections))

    detector_space = True
    deconvolution = False

    from dials.command_line.integrate import phil_scope

    params = phil_scope.extract()

    params.integration.mp.nproc = 8

    from time import time

    st = time()

    from dials.array_family import flex

    reflections["intensity.prf_old.value"] = reflections["intensity.prf.value"]
    reflections["intensity.prf_old.variance"] = reflections[
        "intensity.prf.variance"]
    reflections["intensity.prf.value"] = flex.double(len(reflections))
    reflections["intensity.prf.variance"] = flex.double(len(reflections))