def _mask_to_limits(a, limits, inclusive):
 (lower_limit, upper_limit) = limits
 (lower_include, upper_include) = inclusive
 am = ma.MaskedArray(a)
 if (lower_limit is not None):
  if lower_include:
   am = ma.masked_less(am, lower_limit)
  else:
   am = ma.masked_less_equal(am, lower_limit)
 if (upper_limit is not None):
  if upper_include:
   am = ma.masked_greater(am, upper_limit)
  else:
   am = ma.masked_greater_equal(am, upper_limit)
 if (am.count() == 0):
  raise ValueError('No array values within given limits')
 return am

def _mask_to_limits ( a , limits , inclusive ) : ( lower_limit , upper_limit ) = limits ( lower_include , upper_include ) = inclusive am = ma . MaskedArray ( a ) if ( lower_limit is not None ) : if lower_include : am = ma . masked_less ( am , lower_limit ) else : am = ma . masked_less_equal ( am , lower_limit ) if ( upper_limit is not None ) : if upper_include : am = ma . masked_greater ( am , upper_limit ) else : am = ma . masked_greater_equal ( am , upper_limit ) if ( am . count ( ) == 0 ) : raise ValueError ( 'No array values within given limits' ) return am
mask an array for values outside of given limits .