rebin#

diffsims.utils.discretise_utils.rebin(x, loc, r, k, mem)[source]#

Bins each location into a grid subject to memory constraints.

Parameters:
xlist [np.ndarray [float]], of shape [(nx,), (ny,), …]

Dictates the range of the box over which to bin atoms.

locnp.ndarray, (n, 3)

Atoms to bin.

rfloat or [float, float, float]

Mesh size (in each direction).

kint

Integer such that the radius of the atom is <= k*r. Consequently, each atom will appear in approximately 8k^3 bins.

memint

Upper limit of number of bytes permitted for mesh. If not possible then raises a MemoryError.

Returns:
subListnp.ndarray [int]

subList[i0,i1,i2] is a list of indices [j0, j1, …, jn, -1,…] such that the only atoms which are contained in the box: [x[0].min()+i0*r,x[0].min(),+(i0+1)*r] x [x[1].min()+i1*r,x[1].min(),+(i1+1)*r]… are the atoms with locations loc[j0], …, loc[jn].