def sigmaclip(a, low=4.0, high=4.0):
 c = np.asarray(a).ravel()
 delta = 1
 while delta:
  c_std = c.std()
  c_mean = c.mean()
  size = c.size
  critlower = (c_mean - (c_std * low))
  critupper = (c_mean + (c_std * high))
  c = c[((c > critlower) & (c < critupper))]
  delta = (size - c.size)
 return SigmaclipResult(c, critlower, critupper)

def sigmaclip ( a , low = 4.0 , high = 4.0 ) : c = np . asarray ( a ) . ravel ( ) delta = 1 while delta : c_std = c . std ( ) c_mean = c . mean ( ) size = c . size critlower = ( c_mean - ( c_std * low ) ) critupper = ( c_mean + ( c_std * high ) ) c = c [ ( ( c > critlower ) & ( c < critupper ) ) ] delta = ( size - c . size ) return SigmaclipResult ( c , critlower , critupper )
iterative sigma-clipping of array elements .