def _get_index_from_direction(direction):
    """Returns numerical index from direction
    """
    directions = ['x', 'y', 'z']
    try:
        if direction in 'lr':
            index = 0
        else:
            index = directions.index(direction)
    except ValueError:
        message = (
            "{0} is not a valid direction. Allowed values are 'l', 'r', 'x', 'y' and 'z'"
            .format(direction))
        raise ValueError(message)
    return index
