coords.Coords.fuse#
- Coords.fuse(ppb=1, shift=0.5, rtol=1e-05, atol=1e-08, repeat=True)#
Find (almost) coinciding points and return a compressed set.
This method finds the points that are very close to each other and replaces them with a single point. See Notes below for explanation about the method being used and the parameters being used. In most cases, atol and rtol are probably the only ones you want to change from the defaults. Two points are considered the same if all their coordinates differ less than the maximum of atol and rtol * self.max_size().
Parameters#
- ppb: int, optional
Average number of points per box. The box sizes and number of boxes will be determined to approximate this number.
- shift: float (0.0 .. 1.0), optional
Relative shift value for the box grid. Applying a shift of 0.5 will make the lowest coordinate values fall at the center of the outer boxes.
- rtol: float, optional
Relative tolerance used when considering two points for fusing.
- atol: float, optional
Absolute tolerance used when considering two points for fusing.
- repeat: bool, optional
If True, repeat the procedure with a second shift value.
Returns#
- coords: Coords object (npts,3)
The unique points obtained from merging the very close points of a Coords.
- index: int array
An index in the unique coordinates array coords for each of the original points. The shape of the index array is equal to the point shape of the input Coords (
self.points_shape()). All the values are in the range 0..npts.
Examples#
>>> X = Coords([[1.,1.,0.],[1.001,1.,0.],[1.1,1.,0.]]) >>> x,e = X.fuse(atol=0.01) >>> print(x) [[1. 1. 0. ] [1.1 1. 0. ]] >>> print(e) [0 0 1] >>> np.allclose(X,x[e],atol=0.01) True