def remove_xenon(te_img, xe_img, te_iso, xe_iso, clamp_neg=True):
    """
    Based on the abundances of the Xe and Te isotopes in question, and the Xe
    images, calculates the expected component the Te image that actually comes
    from Xe and subtracts it.
    By default the function assumes any pixels that become negative after
    subtraction contain no tellurium and so clamps them to 0.
    """
    # Percentage abundance of different Xe isotopes
    xe_abundances = {'124': 0.095,
                     '126': 0.089,
                     '128': 1.910,
                     '129': 26.401,
                     '130': 4.071,
                     '131': 21.232,
                     '132': 26.909,
                     '134': 10.436,
                     '136': 8.857}
    """
    Checks that the isotope requested is xenon contaminated.
    Returns the input array if not, and prints a warning.
    """
    if str(te_iso)not in xe_abundances:
        print('{0} is not contaminated with Xe.  Input image returned.'.format(str(te_iso)))
        return te_img

    ratio = xe_abundances[str(te_iso)] / xe_abundances[str(xe_iso)]

    scaled_xe = xe_img * ratio

    subtracted = te_img - scaled_xe

    # Clamp negative pixels to zero if clamp_neg
    if clamp_neg:
        subtracted[subtracted < 0] = 0

    return subtracted