Changeset 94 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Jul 1, 2010 9:25:08 AM (12 years ago)
Author:
vondreel
Message:

move all fortran to fsource
add gray for readonly textctrl
do polygon insert, show in imageGUI and make mask
fix to ReadPDBphase to use correct crystal to cartesian transformation matrix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r89 r94  
    2424npatand = lambda x: 180.*np.arctan(x)/np.pi
    2525npatan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi
     26   
     27def 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)*(p2x-p1x)/(p2y-p1y)+p1x
     37            if p1x == p2x or xy[0] <= xinters:
     38                Inside = not Inside
     39        p1x,p1y = p2x,p2y
     40    return Inside
    2641       
    2742def makeMat(Angle,Axis):
     
    454469    #make position masks here
    455470    spots = masks['Points']
     471    polygons = masks['Polygons']
    456472    tam = ma.make_mask_none((imageN,imageN))
    457473    for X,Y,diam in spots:
    458474        tam = ma.mask_or(tam,ma.getmask(ma.masked_less((tax-X)**2+(tay-Y)**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())]))
    459477    return GetTthAzm(tax,tay,data),tam           #2-theta & azimuth arrays & position mask
    460478
Note: See TracChangeset for help on using the changeset viewer.