예제 #1
0
    def from_parameters(reflections,
                        experiments,
                        known_crystal_models=None,
                        params=None):

        if known_crystal_models is not None:
            from dials.algorithms.indexing.known_orientation import (
                IndexerKnownOrientation, )

            if params.indexing.known_symmetry.space_group is None:
                params.indexing.known_symmetry.space_group = (
                    known_crystal_models[0].get_space_group().info())
            idxr = IndexerKnownOrientation(reflections, experiments, params,
                                           known_crystal_models)
        else:
            has_stills = False
            has_sequences = False
            for expt in experiments:
                if isinstance(expt.imageset, ImageSequence):
                    has_sequences = True
                else:
                    has_stills = True

            if has_stills and has_sequences:
                raise ValueError(
                    "Please provide only stills or only sequences, not both")

            use_stills_indexer = has_stills

            if not (params.indexing.stills.indexer is libtbx.Auto
                    or params.indexing.stills.indexer.lower() == "auto"):
                if params.indexing.stills.indexer == "stills":
                    use_stills_indexer = True
                elif params.indexing.stills.indexer == "sequences":
                    use_stills_indexer = False
                else:
                    assert False

            if params.indexing.basis_vector_combinations.max_refine is libtbx.Auto:
                if use_stills_indexer:
                    params.indexing.basis_vector_combinations.max_refine = 5
                else:
                    params.indexing.basis_vector_combinations.max_refine = 50

            if use_stills_indexer:
                # Ensure the indexer and downstream applications treat this as set of stills
                from dxtbx.imageset import ImageSet  # , MemImageSet

                for experiment in experiments:
                    experiment.imageset = ImageSet(
                        experiment.imageset.data(),
                        experiment.imageset.indices())
                    # if isinstance(imageset, MemImageSet):
                    #   imageset = MemImageSet(imagesequence._images, imagesequence.indices())
                    # else:
                    #   imageset = ImageSet(imagesequence.reader(), imagesequence.indices())
                    #   imageset._models = imagesequence._models
                    experiment.imageset.set_scan(None)
                    experiment.imageset.set_goniometer(None)
                    experiment.scan = None
                    experiment.goniometer = None

            IndexerType = None
            for entry_point in pkg_resources.iter_entry_points(
                    "dials.index.basis_vector_search"):
                if params.indexing.method == entry_point.name:
                    if use_stills_indexer:
                        # do something
                        from dials.algorithms.indexing.stills_indexer import (
                            StillsIndexerBasisVectorSearch as IndexerType, )
                    else:
                        from dials.algorithms.indexing.lattice_search import (
                            BasisVectorSearch as IndexerType, )

            if IndexerType is None:
                for entry_point in pkg_resources.iter_entry_points(
                        "dials.index.lattice_search"):
                    if params.indexing.method == entry_point.name:
                        if use_stills_indexer:
                            from dials.algorithms.indexing.stills_indexer import (
                                StillsIndexerLatticeSearch as IndexerType, )
                        else:
                            from dials.algorithms.indexing.lattice_search import (
                                LatticeSearch as IndexerType, )

            assert IndexerType is not None

            idxr = IndexerType(reflections, experiments, params=params)

        return idxr
예제 #2
0
    def from_parameters(reflections,
                        experiments,
                        known_crystal_models=None,
                        params=None):

        if known_crystal_models is not None:
            from dials.algorithms.indexing.known_orientation import (
                IndexerKnownOrientation, )

            if params.indexing.known_symmetry.space_group is None:
                params.indexing.known_symmetry.space_group = (
                    known_crystal_models[0].get_space_group().info())
            idxr = IndexerKnownOrientation(reflections, experiments, params,
                                           known_crystal_models)
        else:
            has_stills = False
            has_sweeps = False
            for expt in experiments:
                if (expt.goniometer is None or expt.scan is None
                        or expt.scan.get_oscillation()[1] == 0):
                    if has_sweeps:
                        raise Sorry(
                            "Please provide only stills or only sweeps, not both"
                        )
                    has_stills = True
                else:
                    if has_stills:
                        raise Sorry(
                            "Please provide only stills or only sweeps, not both"
                        )
                    has_sweeps = True
            assert not (has_stills and has_sweeps)
            use_stills_indexer = has_stills

            if not (params.indexing.stills.indexer is libtbx.Auto
                    or params.indexing.stills.indexer.lower() == "auto"):
                if params.indexing.stills.indexer == "stills":
                    use_stills_indexer = True
                elif params.indexing.stills.indexer == "sweeps":
                    use_stills_indexer = False
                else:
                    assert False

            if params.indexing.basis_vector_combinations.max_refine is libtbx.Auto:
                if use_stills_indexer:
                    params.indexing.basis_vector_combinations.max_refine = 5
                else:
                    params.indexing.basis_vector_combinations.max_refine = 50

            if use_stills_indexer:
                # Ensure the indexer and downstream applications treat this as set of stills
                from dxtbx.imageset import ImageSet  # , MemImageSet

                for experiment in experiments:
                    experiment.imageset = ImageSet(
                        experiment.imageset.data(),
                        experiment.imageset.indices())
                    # if isinstance(imageset, MemImageSet):
                    #   imageset = MemImageSet(imagesweep._images, imagesweep.indices())
                    # else:
                    #   imageset = ImageSet(imagesweep.reader(), imagesweep.indices())
                    #   imageset._models = imagesweep._models
                    experiment.imageset.set_scan(None)
                    experiment.imageset.set_goniometer(None)
                    experiment.scan = None
                    experiment.goniometer = None

            if params.indexing.method in ("fft1d", "fft3d",
                                          "real_space_grid_search"):
                if use_stills_indexer:
                    # do something
                    from dials.algorithms.indexing.stills_indexer import (
                        StillsIndexerBasisVectorSearch as BasisVectorSearch, )
                else:
                    from dials.algorithms.indexing.lattice_search import (
                        BasisVectorSearch, )

                idxr = BasisVectorSearch(reflections,
                                         experiments,
                                         params=params)

        return idxr