Beispiel #1
0
    def __init__(self,
                 map_data,
                 unit_cell,
                 map_indices=None,
                 map_size=None,
                 map_origin=(0.0, 0.0, 0.0),
                 sparse=False,
                 meta=None,
                 parent=None,
                 children=None):

        assert isinstance(map_data, flex.double)
        assert isinstance(unit_cell, cctbx.uctbx.unit_cell) or isinstance(
            unit_cell, cctbx_uctbx_ext.unit_cell)

        if sparse:
            assert map_data.nd(
            ) == 1, 'Map data must be 1-dimensional when sparse=True'
            assert [map_indices, map_size].count(
                None
            ) == 0, 'Must provide map_indices and map_size when sparse=True'
            assert len(map_data) == len(
                map_indices
            ), 'map_data and map_indices must be the same length when sparse=True ({} != {})'.format(
                len(map_data), len(map_indices))
            assert max(map_indices) < numpy.prod(
                map_size
            ), 'indices are not compatible with map_size ({} > {})'.format(
                max(map_indices), numpy.prod(map_size))
            if not isinstance(map_indices, flex.size_t):
                map_indices = flex.size_t(map_indices)
        else:
            if map_size is None:
                assert map_data.nd(
                ) == 3, 'map_data must be 3-dimension if map_size is not given'
                map_size = map_data.all()
            assert len(map_size) == 3, 'map_size must be three dimensional'
            assert map_indices is None, 'Do not provide map_indices for non-sparse matrices'
            assert numpy.prod(map_size) == map_data.size()
            # Reshape the map data if necessary
            if map_data.nd() == 1:
                map_data = map_data.deep_copy()
                map_data.reshape(flex.grid(map_size))
            assert map_data.all(
            ) == map_size, 'map_data is not the same shape as map_size ({} != {})'.format(
                map_data.all(), map_size)

        self.data = map_data
        self._map_size = map_size
        self._map_indices = map_indices
        self._map_origin = map_origin
        self.unit_cell = unit_cell
        self.meta = meta if meta else Meta()
        self.parent = parent
        self.children = children if children else []

        assert len(self._map_size) == 3, 'map_size must be tuple of length 3'
        assert sparse == self.is_sparse()
Beispiel #2
0
 def __init__(self, model, data):
     """Convenience object to hold model-data pairs"""
     self.model = model
     self.data = data
     self.num = self.tag = None
     self.file_manager = None
     self.meta = Meta()
     self.parent = None
     self.child = None
     self.children = []