def _inside_contour(pos, contour):
 npos = len(pos)
 (x, y) = pos[:, :2].T
 check_mask = np.ones(npos, dtype=bool)
 check_mask[((((x < np.min(x)) | (y < np.min(y))) | (x > np.max(x))) | (y > np.max(y)))] = False
 critval = 0.1
 sel = np.where(check_mask)[0]
 for this_sel in sel:
  contourx = (contour[:, 0] - pos[(this_sel, 0)])
  contoury = (contour[:, 1] - pos[(this_sel, 1)])
  angle = np.arctan2(contoury, contourx)
  angle = np.unwrap(angle)
  total = np.sum(np.diff(angle))
  check_mask[this_sel] = (np.abs(total) > critval)
 return check_mask

def _inside_contour ( pos , contour ) : npos = len ( pos ) ( x , y ) = pos [ : , : 2 ] . T check_mask = np . ones ( npos , dtype = bool ) check_mask [ ( ( ( ( x < np . min ( x ) ) | ( y < np . min ( y ) ) ) | ( x > np . max ( x ) ) ) | ( y > np . max ( y ) ) ) ] = False critval = 0.1 sel = np . where ( check_mask ) [ 0 ] for this_sel in sel : contourx = ( contour [ : , 0 ] - pos [ ( this_sel , 0 ) ] ) contoury = ( contour [ : , 1 ] - pos [ ( this_sel , 1 ) ] ) angle = np . arctan2 ( contoury , contourx ) angle = np . unwrap ( angle ) total = np . sum ( np . diff ( angle ) ) check_mask [ this_sel ] = ( np . abs ( total ) > critval ) return check_mask
check if points are inside a contour .