def atmean(a,limits=None,inclusive=(1,1)):
     if a.dtype in [N.int_, N.short,N.ubyte]:
         a = a.astype(N.float_)
     if limits == None:
         return mean(a)
     assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atmean"
     if inclusive[0]:         lowerfcn = N.greater_equal
     else:               lowerfcn = N.greater
     if inclusive[1]:         upperfcn = N.less_equal
     else:               upperfcn = N.less
     if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)):
         raise ValueError, "No array values within given limits (atmean)."
     elif limits[0]==None and limits[1]<>None:
         mask = upperfcn(a,limits[1])
     elif limits[0]<>None and limits[1]==None:
         mask = lowerfcn(a,limits[0])
     elif limits[0]<>None and limits[1]<>None:
         mask = lowerfcn(a,limits[0])*upperfcn(a,limits[1])
     s = float(N.add.reduce(N.ravel(a*mask)))
     n = float(N.add.reduce(N.ravel(mask)))
     return s/n
Returns the arithmetic mean of all values in an array, ignoring values
dataset/ETHPy150Open radlab/sparrow/src/main/python/third_party/stats.py/atmean