def _apply_distmat(self, group): """Selection that computes all distances.""" sys_indices = numpy.array([a.number for a in self._group_atoms_list]) sys_coor = Selection.coord[sys_indices] ref_coor = self.ref[numpy.newaxis, ...] # Fix: Arrarys need to be converted to dtype=float32 to work with distance_array sys_coor = numpy.asarray(sys_coor, dtype=numpy.float32) ref_coor = numpy.asarray(ref_coor, dtype=numpy.float32) if self.periodic: box = group.dimensions[:3] else: box = None import distances dist = distances.distance_array(sys_coor, ref_coor, box) res_atoms = [self._group_atoms_list[i] for i in numpy.any(dist <= self.cutoff, axis=1).nonzero()[0]] # make list numpy array and use fancy indexing? return set(res_atoms)
def _apply_distmat(self, group): sel_atoms = self.sel._apply(group) # group is wrong, should be universe (?!) sys_atoms_list = [a for a in (self._group_atoms - sel_atoms)] # list needed for back-indexing sel_indices = numpy.array([a.number for a in sel_atoms], dtype=int) sys_indices = numpy.array([a.number for a in sys_atoms_list], dtype=int) sel_coor = Selection.coord[sel_indices] sys_coor = Selection.coord[sys_indices] if self.periodic: box = group.dimensions[:3] # ignored with KDTree else: box = None import distances dist = distances.distance_array(sys_coor, sel_coor, box) res_atoms = [ sys_atoms_list[i] for i in numpy.any(dist <= self.cutoff, axis=1).nonzero()[0]] # make list numpy array and use fancy indexing? return set(res_atoms)
def _apply_distmat(self, group): """Selection that computes all distances.""" sys_indices = numpy.array([a.number for a in self._group_atoms_list]) sys_coor = Selection.coord[sys_indices] ref_coor = self.ref[numpy.newaxis, ...] # Fix: Arrarys need to be converted to dtype=float32 to work with distance_array sys_coor = numpy.asarray(sys_coor, dtype=numpy.float32) ref_coor = numpy.asarray(ref_coor, dtype=numpy.float32) if self.periodic: box = group.dimensions[:3] else: box = None import distances dist = distances.distance_array(sys_coor, ref_coor, box) res_atoms = [ self._group_atoms_list[i] for i in numpy.any(dist <= self.cutoff, axis=1).nonzero()[0] ] # make list numpy array and use fancy indexing? return set(res_atoms)
def _apply_distmat(self, group): sel_atoms = self.sel._apply( group) # group is wrong, should be universe (?!) sys_atoms_list = [a for a in (self._group_atoms - sel_atoms) ] # list needed for back-indexing sel_indices = numpy.array([a.number for a in sel_atoms], dtype=int) sys_indices = numpy.array([a.number for a in sys_atoms_list], dtype=int) sel_coor = Selection.coord[sel_indices] sys_coor = Selection.coord[sys_indices] if self.periodic: box = group.dimensions[:3] # ignored with KDTree else: box = None import distances dist = distances.distance_array(sys_coor, sel_coor, box) res_atoms = [ sys_atoms_list[i] for i in numpy.any(dist <= self.cutoff, axis=1).nonzero()[0] ] # make list numpy array and use fancy indexing? return set(res_atoms)