def pointToGridIndex(x, y, z, sx=1.0, sy=1.0, sz=1.0, ox=0.0, oy=0.0, oz=0.0):
    """
    Convert real point coordinates to index grid:

    :param x, y, z:     (float) coordinates of a point
    :param nx, ny, nz:  (int) number of grid cells in each direction
    :param sx, sy, sz:  (float) cell size in each direction
    :param ox, oy, oz:  (float) origin of the grid (bottom-lower-left corner)

    :return: ix, iy, iz:
                        (3-tuple) grid node index
                            in x-, y-, z-axis direction respectively
                            Warning: no check if the node is within the grid
    """

    jx = (x-ox)/sx
    jy = (y-oy)/sy
    jz = (z-oz)/sz

    ix = int(jx)
    iy = int(jy)
    iz = int(jz)

    # round to lower index if between two grid node
    if ix == jx and ix > 0:
        ix = ix -1
    if iy == jy and iy > 0:
        iy = iy -1
    if iz == jz and iz > 0:
        iz = iz -1

    return ix, iy, iz