Skip to content

Instantly share code, notes, and snippets.

@ZGainsforth
Created June 24, 2014 17:06
Show Gist options
  • Save ZGainsforth/c611cd30566717c63055 to your computer and use it in GitHub Desktop.
Save ZGainsforth/c611cd30566717c63055 to your computer and use it in GitHub Desktop.
Takes (x1, y1) and (x2, y2) where x1, and x2 have some overlap. Merges them to produce: (xx1, yy1) and (xx2, yy2) where xx1 = xx2.
def Marry2ColumnDomains(x1, y1, x2, y2):
#Based on: http://stackoverflow.com/questions/24317761/numpy-function-to-find-indices-for-overlapping-vectors?noredirect=1#comment37587212_24317761
mask1 = np.in1d(x1, x2)
mask2 = np.in1d(x2, x1)
xx1 = x1[mask1]
yy1 = y1[mask1]
xx2 = x2[mask2]
yy2 = y2[mask2]
return xx1, yy1, xx2, yy2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment