def get_band_avg(img_hist, bins):
    """
    Returns the weighted reflectance of a band for a histogram of a particular image.
    @img_hist Distribution over bins. Should have dimensions (num_bins)
    @bins Should be the array of delimiters used as bins for the original histogram
    """
    if len(img_hist) != len(bins) - 1:
        raise Exception('Mismatch in histogram and bin list dimensions.')
    total = 0
    for i in range(len(img_hist)):
        add = img_hist[i]*(bins[i + 1] + bins[i])/2
        total += add
    if total == 0: return -1
    return total