Changeset 1151
 Timestamp:
 Nov 25, 2013 2:01:08 PM (8 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r1149 r1151 279 279 return ring,(delt > 90),sumI/len(ring) 280 280 281 def makeIdealRing(ellipse,azm=None):282 'Needs a doc string'283 cent,phi,radii = ellipse284 cphi = cosd(phi)285 sphi = sind(phi)286 if azm:287 aR = azm[0]90,azm[1]90,azm[1]azm[0]288 if azm[1]azm[0] > 180:289 aR[2] /= 2290 else:291 aR = 0,362,181292 293 a = np.linspace(aR[0],aR[1],aR[2])294 slr = radii[0]**2/radii[1]295 rat2 = (radii[0]/radii[1])**2296 if radii[0] > 0.: #ellipse297 ecc = np.sqrt(max(1.rat2,0.))298 else: #hyperbola299 ecc = np.sqrt(1.+rat2)300 rad = slr/(1.+ecc*npcosd(a))301 xy = np.array([rad*npsind(a)+cent[0],rad*npcosd(a)+cent[1]])302 return xy303 304 def calcDist(radii,tth):305 'Needs a doc string'306 stth = sind(tth)307 ctth = cosd(tth)308 ttth = tand(tth)309 return math.sqrt(radii[0]**4/(ttth**2*((radii[0]*ctth)**2+(radii[1]*stth)**2)))310 311 def calcZdisCosB(radius,tth,radii):312 'Needs a doc string'313 cosB = sinb = radii[0]**2/(radius*radii[1])314 if cosB > 1.:315 return 0.,1.316 else:317 cosb = math.sqrt(1.sinb**2)318 ttth = tand(tth)319 zdis = radii[1]*ttth*cosb/sinb320 return zdis,cosB321 322 281 def GetEllipse2(tth,dxy,dist,cent,tilt,phi): 323 282 '''uses Dandelin spheres to find ellipse or hyperbola parameters from detector geometry 
trunk/GSASIIplot.py
r1148 r1151 2113 2113 from matplotlib.patches import Ellipse,Arc,Circle,Polygon 2114 2114 import numpy.ma as ma 2115 Dsp = lambda tth,wave: wave/(2.* sind(tth/2.))2115 Dsp = lambda tth,wave: wave/(2.*npsind(tth/2.)) 2116 2116 global Data,Masks 2117 2117 colors=['b','g','r','c','m','k'] … … 2494 2494 xyI = [] 2495 2495 for azm in Azm: 2496 xyI.append(G2img.GetDetectorXY(dspI,azm,Data)) 2496 xyI.append(G2img.GetDetectorXY(dspI,azm,Data)) #what about hyperbola? 2497 2497 xyI = np.array(xyI) 2498 2498 arcxI,arcyI = xyI.T … … 2501 2501 xyO = [] 2502 2502 for azm in Azm: 2503 xyO.append(G2img.GetDetectorXY(dspO,azm,Data)) 2503 xyO.append(G2img.GetDetectorXY(dspO,azm,Data)) #what about hyperbola? 2504 2504 xyO = np.array(xyO) 2505 2505 arcxO,arcyO = xyO.T … … 2519 2519 Plot.plot(xring,yring,'r+',picker=3) 2520 2520 if Data['setRings']: 2521 # rings = np.concatenate((Data['rings']),axis=0)2522 2521 N = 0 2523 2522 for ring in Data['rings']: … … 2525 2524 Plot.plot(xring,yring,'+',color=colors[N%6]) 2526 2525 N += 1 2527 for ellipse in Data['ellipses']: 2528 # print 'plot:',ellipse 2526 for ellipse in Data['ellipses']: #what about hyperbola? 2529 2527 cent,phi,[width,height],col = ellipse 2530 Plot.add_artist(Ellipse([cent[0],cent[1]],2*width,2*height,phi,ec=col,fc='none')) 2531 Plot.text(cent[0],cent[1],'+',color=col,ha='center',va='center') 2528 if width > 0: #ellipses 2529 Plot.add_artist(Ellipse([cent[0],cent[1]],2*width,2*height,phi,ec=col,fc='none')) 2530 Plot.text(cent[0],cent[1],'+',color=col,ha='center',va='center') 2532 2531 if G2frame.PatternTree.GetItemText(G2frame.PickId) in 'Stress/Strain': 2533 2532 print 'plot stress/strain stuff' … … 2555 2554 tth,thick = ring 2556 2555 wave = Data['wavelength'] 2557 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data))),2) 2558 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tththick/2.,wave),Data))),2) 2556 xy1 = [] 2557 xy2 = [] 2558 Azm = np.linspace(0,362,181) 2559 for azm in Azm: 2560 xy1.append(G2img.GetDetectorXY(Dsp(tth+thick/2.,wave),azm,Data)) #what about hyperbola 2561 xy2.append(G2img.GetDetectorXY(Dsp(tththick/2.,wave),azm,Data)) #what about hyperbola 2562 x1,y1 = np.array(xy1).T 2563 x2,y2 = np.array(xy2).T 2559 2564 G2frame.ringList.append([Plot.plot(x1,y1,'r',picker=3),iring,'o']) 2560 2565 G2frame.ringList.append([Plot.plot(x2,y2,'r',picker=3),iring,'i']) … … 2564 2569 tth,azm,thick = arc 2565 2570 wave = Data['wavelength'] 2566 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data),azm)),2) 2567 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(max(0.01,tththick/2.),wave),Data),azm)),2) 2571 xy1 = [] 2572 xy2 = [] 2573 aR = azm[0],azm[1],azm[1]azm[0] 2574 if azm[1]azm[0] > 180: 2575 aR[2] /= 2 2576 Azm = np.linspace(aR[0],aR[1],aR[2]) 2577 for azm in Azm: 2578 xy1.append(G2img.GetDetectorXY(Dsp(tth+thick/2.,wave),azm,Data)) #what about hyperbola 2579 xy2.append(G2img.GetDetectorXY(Dsp(tththick/2.,wave),azm,Data)) #what about hyperbola 2580 x1,y1 = np.array(xy1).T 2581 x2,y2 = np.array(xy2).T 2568 2582 G2frame.arcList.append([Plot.plot(x1,y1,'r',picker=3),iarc,'o']) 2569 2583 G2frame.arcList.append([Plot.plot(x2,y2,'r',picker=3),iarc,'i'])
Note: See TracChangeset
for help on using the changeset viewer.