def convert_indices(direction, x, y):
    """
    Converts indices between Python and Fortran indexing, assuming that
    Python indexing begins at 0 and Fortran (for x and y) begins at 1.
    In Tracmass, the vertical indexing does begin at zero so this script
    does nothing to vertical indexing.

    Examples:
        For before a call to tracmass:

        >>> xstart,ystart = convert_indices('py2f',xstart,ystart)

        For after a call to tracmass:

        >>> xend,yend = convert_indices('f2py',xend,yend)
    """

    if direction == 'py2f':
        x = x+1
        y = y+1
    elif direction == 'f2py':
        x = x-1
        y = y-1

    return x, y