Beispiel #1
0
  def create(params, experiments, reflections):
    ''' Create the integrator from the input configuration. '''
    from dials.interfaces import IntensityIface
    from dials.interfaces import BackgroundIface
    from dials.interfaces import CentroidIface
    from dials.array_family import flex

    # Initialise the strategy classes
    BackgroundAlgorithm = BackgroundIface.extension(
      params.integration.background.algorithm)
    IntensityAlgorithm = IntensityIface.extension(
      params.integration.intensity.algorithm)
    CentroidAlgorithm = CentroidIface.extension(
      params.integration.centroid.algorithm)

    # Set the algorithms in the reflection table
    flex.reflection_table._background_algorithm = \
      flex.strategy(BackgroundAlgorithm, params)
    flex.reflection_table._intensity_algorithm = \
      flex.strategy(IntensityAlgorithm, params)
    flex.reflection_table._centroid_algorithm = \
      flex.strategy(CentroidAlgorithm, params)

    # Get the integrator class
    IntegratorClass = IntegratorFactory.select_integrator(IntensityAlgorithm)

    # Return an instantiation of the class
    return IntegratorClass(
      experiments=experiments,
      reflections=reflections,
      block_size=params.integration.block.size,
      max_procs=params.integration.mp.max_procs,
      mp_method=params.integration.mp.method)
Beispiel #2
0
    def create(params, experiments, reflections):
        """Create the integrator from the input configuration."""
        from dials.interfaces import IntensityIface
        from dials.interfaces import BackgroundIface
        from dials.interfaces import CentroidIface
        from dials.array_family import flex

        # Initialise the strategy classes
        BackgroundAlgorithm = BackgroundIface.extension(
            params.integration.background.algorithm
        )
        IntensityAlgorithm = IntensityIface.extension(
            params.integration.intensity.algorithm
        )
        CentroidAlgorithm = CentroidIface.extension(
            params.integration.centroid.algorithm
        )

        # Set the algorithms in the reflection table
        flex.reflection_table._background_algorithm = flex.strategy(
            BackgroundAlgorithm, params
        )
        flex.reflection_table._intensity_algorithm = flex.strategy(
            IntensityAlgorithm, params
        )
        flex.reflection_table._centroid_algorithm = flex.strategy(
            CentroidAlgorithm, params
        )

        # Get the integrator class
        IntegratorClass = IntegratorFactory.select_integrator(IntensityAlgorithm)

        # Return an instantiation of the class
        return IntegratorClass(
            experiments=experiments,
            reflections=reflections,
            block_size=params.integration.block.size,
            max_procs=params.integration.mp.max_procs,
            mp_method=params.integration.mp.method,
        )
Beispiel #3
0
  def create(params, experiments, reflections):
    '''
    Create the integrator from the input configuration.

    :param params: The input phil parameters
    :param experiments: The list of experiments
    :param reflections: The reflections to integrate
    :return: The integrator class

    '''
    from dials.algorithms.integration.filtering import MultiPowderRingFilter
    from dials.interfaces import BackgroundIface
    from dials.interfaces import CentroidIface
    from dials.array_family import flex
    from libtbx.utils import Sorry
    import cPickle as pickle

    # Check each experiment has an imageset
    for exp in experiments:
      if exp.imageset is None:
        raise Sorry('''
          One or more experiment does not contain an imageset. Access to the
          image data is crucial for integration.
        ''')

    # Read the mask in if necessary
    if params.integration.lookup.mask is not None:
      if type(params.integration.lookup.mask) == str:
        with open(params.integration.lookup.mask) as infile:
          params.integration.lookup.mask = pickle.load(infile)

    # Initialise the strategy classes
    BackgroundAlgorithm = BackgroundIface.extension(
      params.integration.background.algorithm)
    CentroidAlgorithm = CentroidIface.extension(
      params.integration.centroid.algorithm)

    # Set the algorithms in the reflection table
    flex.reflection_table._background_algorithm = \
      flex.strategy(BackgroundAlgorithm, params)
    flex.reflection_table._centroid_algorithm = \
      flex.strategy(CentroidAlgorithm, params)

    # Get the classes we need
    if params.integration.integrator == 'auto':
      if experiments.all_stills():
        params.integration.integrator = 'stills'
      else:
        params.integration.integrator = '3d'
    if params.integration.integrator == '3d':
      IntegratorClass = Integrator3D
    elif params.integration.integrator == 'flat3d':
      IntegratorClass = IntegratorFlat3D
    elif params.integration.integrator == '2d':
      IntegratorClass = Integrator2D
    elif params.integration.integrator == 'single2d':
      IntegratorClass = IntegratorSingle2D
    elif params.integration.integrator == 'stills':
      IntegratorClass = IntegratorStills
    elif params.integration.integrator == 'volume':
      IntegratorClass = IntegratorVolume
    else:
      raise RuntimeError("Unknown integration type")

    # Remove scan if stills
    if experiments.all_stills():
      for experiment in experiments:
        experiment.scan = None

    # Return an instantiation of the class
    return IntegratorClass(
      experiments,
      reflections,
      Parameters.from_phil(params.integration))
Beispiel #4
0
    def create(params, experiments, reflections):
        '''
    Create the integrator from the input configuration.

    :param params: The input phil parameters
    :param experiments: The list of experiments
    :param reflections: The reflections to integrate
    :return: The integrator class

    '''
        from dials.algorithms.integration.filtering import MultiPowderRingFilter
        from dials.interfaces import BackgroundIface
        from dials.interfaces import CentroidIface
        from dials.array_family import flex
        from libtbx.utils import Sorry
        import cPickle as pickle

        # Check each experiment has an imageset
        for exp in experiments:
            if exp.imageset is None:
                raise Sorry('''
          One or more experiment does not contain an imageset. Access to the
          image data is crucial for integration.
        ''')

        # Read the mask in if necessary
        if params.integration.lookup.mask is not None:
            if type(params.integration.lookup.mask) == str:
                with open(params.integration.lookup.mask) as infile:
                    params.integration.lookup.mask = pickle.load(infile)

        # Initialise the strategy classes
        BackgroundAlgorithm = BackgroundIface.extension(
            params.integration.background.algorithm)
        CentroidAlgorithm = CentroidIface.extension(
            params.integration.centroid.algorithm)

        # Set the algorithms in the reflection table
        flex.reflection_table._background_algorithm = \
          flex.strategy(BackgroundAlgorithm, params)
        flex.reflection_table._centroid_algorithm = \
          flex.strategy(CentroidAlgorithm, params)

        # Get the classes we need
        if params.integration.integrator == 'auto':
            if experiments.all_stills():
                params.integration.integrator = 'stills'
            else:
                params.integration.integrator = '3d'
        if params.integration.integrator == '3d':
            IntegratorClass = Integrator3D
        elif params.integration.integrator == 'flat3d':
            IntegratorClass = IntegratorFlat3D
        elif params.integration.integrator == '2d':
            IntegratorClass = Integrator2D
        elif params.integration.integrator == 'single2d':
            IntegratorClass = IntegratorSingle2D
        elif params.integration.integrator == 'stills':
            IntegratorClass = IntegratorStills
        elif params.integration.integrator == 'volume':
            IntegratorClass = IntegratorVolume
        else:
            raise RuntimeError("Unknown integration type")

        # Remove scan if stills
        if experiments.all_stills():
            for experiment in experiments:
                experiment.scan = None

        # Return an instantiation of the class
        return IntegratorClass(experiments, reflections,
                               Parameters.from_phil(params.integration))