def lerp(xvar, xlim, ylim):
    """linearly interpolate a value of y given ranges for x, y.
    
    arguments:
        xvar: scalar
        xlim: array with xmin, xmax
        ylim: array with ymin, ymax
    """
    delta_x = (xvar - xlim[0])
    slope = ((ylim[1] - ylim[0]) / (xlim[1] - xlim[0]))
    yvar = ylim[0] + slope * delta_x
    return yvar