average() nominally computes the average pixel value for a stack of identically shaped images.
>>> a = np.arange(4)
>>> a = a.reshape((2,2))
>>> arrays = [a*16, a*4, a*2, a*8]
>>> average(arrays)
array([[ 0, 7],
[15, 22]])
>>> average(arrays, nhigh=1)
array([[ 0, 4],
[ 9, 14]])
>>> average(arrays, nlow=1)
array([[ 0, 9],
[18, 28]])
>>> average(arrays, outtype=np.float32)
array([[ 0. , 7.5],
[ 15. , 22.5]], dtype=float32)
>>> bm = np.zeros((4,2,2), dtype=np.bool8)
>>> bm[2,...] = 1
>>> average(arrays, badmasks=bm)
array([[ 0, 9],
[18, 28]])
>>> average(arrays, badmasks=threshhold(arrays, high=25))
array([[ 0, 7],
[ 9, 14]])