Changeset 94 for trunk/GSASIIimage.py
 Timestamp:
 Jul 1, 2010 9:25:08 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r89 r94 24 24 npatand = lambda x: 180.*np.arctan(x)/np.pi 25 25 npatan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi 26 27 def pointInPolygon(pXY,xy): 28 #pXY  assumed closed 1st & last points are duplicates 29 Inside = False 30 N = len(pXY) 31 p1x,p1y = pXY[0] 32 for i in range(N+1): 33 p2x,p2y = pXY[i%N] 34 if (max(p1y,p2y) >= xy[1] > min(p1y,p2y)) and (xy[0] <= max(p1x,p2x)): 35 if p1y != p2y: 36 xinters = (xy[1]p1y)*(p2xp1x)/(p2yp1y)+p1x 37 if p1x == p2x or xy[0] <= xinters: 38 Inside = not Inside 39 p1x,p1y = p2x,p2y 40 return Inside 26 41 27 42 def makeMat(Angle,Axis): … … 454 469 #make position masks here 455 470 spots = masks['Points'] 471 polygons = masks['Polygons'] 456 472 tam = ma.make_mask_none((imageN,imageN)) 457 473 for X,Y,diam in spots: 458 474 tam = ma.mask_or(tam,ma.getmask(ma.masked_less((taxX)**2+(tayY)**2,(diam/2.)**2))) 475 for polygon in polygons: 476 tam = ma.mask_or(tam.flatten(),ma.make_mask([pointInPolygon(polygon,xy) for xy in zip(tax.flatten(),tay.flatten())])) 459 477 return GetTthAzm(tax,tay,data),tam #2theta & azimuth arrays & position mask 460 478
Note: See TracChangeset
for help on using the changeset viewer.