def get_axis_limits(ax, scale=0.85, position='upper-right'):
    """Used to position the identifier labels in the corner of images.
    e.g. '(a)' etc. 
    
    An example use with this definition is as follows:
    
        ax1.annotate("("+d[i+1-10]+")", xy=get_axis_limits(ax1))
    
    This will place an annotation in the top right corner of our subplot,
    ax1. Specifically this is used for labelling multiple plots using 
    letters. The function d[i] is a dictionary function which converts
    numbers to letters.
    
    Parameters
    ----------
    ax : plot/subplot function
        The plot or subplot that you want to scale accordingly
    scale : float, optional
        A scale function that determines as a fractional percentage the
        position from the edge of the plot (e.g. scale = 1 is at the
        edge and scale = 0.5 is centred).
    position : string, optional
        Determines the prefered location of interest releative to the
        four corners of the plot. string selections are ('upper-right',
        'upper-left', 'lower-right', 'lower-left')
        
    Returns
    -------
    x : float
        coordinate reference relative to the input plot ax in the x axis
    y: float
        coordinate reference relative to the input plot ax in the y axis
    
    """
    if position == 'upper-right':
        try:
            return ax.get_xlim()[1] * 0.95 * scale, ax.get_ylim()[1] * 0.9
        except AttributeError:
            return ax.xlim()[1] * 0.95 * scale, ax.ylim()[1] * 0.9
    elif position == 'upper-left':
        try:
            return ax.get_xlim()[1] * 0.95 * (1 - scale), ax.get_ylim()[1
                ] * 0.9
        except AttributeError:
            return ax.xlim()[1] * 0.95 * (1 - scale), ax.ylim()[1] * 0.9
    elif position == 'lower-right':
        try:
            return ax.get_xlim()[1] * 0.95, ax.get_ylim()[1] * (1 - scale)
        except AttributeError:
            return ax.xlim()[1] * 0.95, ax.ylim()[1] * (1 - scale)
    elif position == 'lower-left':
        try:
            return ax.get_xlim()[1] * 0.95, ax.get_ylim()[1] * 0.95 * (1 -
                scale)
        except AttributeError:
            return ax.xlim()[1] * 0.95, ax.ylim()[1] * 0.95 * (1 - scale)
