If I understand correctly, you have the coordinates (x [i], y [i], z [i]), i = 0, ..., N-1, and you want to calculate how many of them end in the given cell grids in a 3D cube?
This can be done using numpy.histogramdd :
import numpy as np
If you want to know which mesh cell is at each point, this can be done using searchsorted :
ix = np.searchsorted(xgrid, x) - 1 iy = np.searchsorted(ygrid, y) - 1 iz = np.searchsorted(zgrid, z) - 1
source share