def get_calibration_from_position(position):
    """Compute the size, scale and offset of a linear axis from coordinates.

    This function assumes rastering on a regular grid for the full size of
    each dimension before rastering over another one. Fox example: a11, a12,
    a13, a21, a22, a23 for a 2x3 grid.

    Parameters
    ----------
    position: numpy array.
        Position coordinates of the axis. Normally as in PositionX/Y of the
        ser file.

    Returns
    -------
    axis_attr: dictionary with `size`, `scale`, `offeset` keys.

    """
    offset = position[0]
    for i, x in enumerate(position):
        if x != position[0]:
            break
    if i == len(position) - 1:
        scale = 0
        size = 0
    else:
        scale = x - position[0]
        if i == 1:
            for j, x in enumerate(position[1:]):
                if x == position[0]:
                    break
            size = j + 1
        else:
            size = len(position) / i
    axis_attr = {'size': size, 'scale': scale, 'offset': offset}
    return axis_attr
