Changeset 3262
- Timestamp:
- Feb 5, 2018 1:06:13 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3254 r3262 1475 1475 def OnMotion(event): 1476 1476 xpos = event.xdata 1477 if xpos: #avoid out of frame mouse position 1478 ypos = event.ydata 1479 Page.canvas.SetCursor(wx.CROSS_CURSOR) 1480 try: 1481 Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters') 1482 if not Id: return 1483 Parms,Parms2 = G2frame.GPXtree.GetItemPyData(Id) 1484 if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype: 1485 q = xpos 1486 dsp = 2.*np.pi/q 1487 try: 1488 xpos = G2lat.Dsp2pos(Parms,2.0*np.pi/xpos) 1489 except ValueError: #avoid bad value in asin beyond upper limit 1490 pass 1491 elif plottype in ['SASD','REFD']: 1492 q = xpos 1493 dsp = 2.*np.pi/q 1494 elif G2frame.plotStyle['dPlot']: 1495 dsp = xpos 1496 q = 2.*np.pi/dsp 1497 xpos = G2lat.Dsp2pos(Parms,xpos) 1498 elif G2frame.Contour and 'T' in Parms['Type'][0]: 1499 xpos = X[int(xpos)] 1500 dsp = G2lat.Pos2dsp(Parms,xpos) 1501 q = 2.*np.pi/dsp 1477 if xpos is None: return #avoid out of frame mouse position 1478 ypos = event.ydata 1479 Page.canvas.SetCursor(wx.CROSS_CURSOR) 1480 try: 1481 Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters') 1482 if not Id: return 1483 Parms,Parms2 = G2frame.GPXtree.GetItemPyData(Id) 1484 if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype: 1485 q = xpos 1486 dsp = 2.*np.pi/q 1487 try: 1488 xpos = G2lat.Dsp2pos(Parms,2.0*np.pi/xpos) 1489 except ValueError: #avoid bad value in asin beyond upper limit 1490 return 1491 limx = Plot.get_xlim() 1492 try: 1493 xmin = G2lat.Dsp2pos(Parms,2.0*np.pi/limx[0]) 1494 except ValueError: #fix bad value in asin beyond upper limit 1495 #if 'C' in Parms['Type'][0]: # how to handle TOF? 1496 xmin = 0. 1497 try: 1498 xmax = G2lat.Dsp2pos(Parms,2.0*np.pi/limx[1]) 1499 except ValueError: #fix bad value in asin beyond upper limit 1500 #if 'C' in Parms['Type'][0]: # how to handle TOF? 1501 xmin = 180. 1502 wid = np.fabs(xmax - xmin) 1503 elif plottype in ['SASD','REFD']: 1504 q = xpos 1505 dsp = 2.*np.pi/q 1506 limx = Plot.get_xlim() 1507 wid = np.fabs(2.*np.pi/limx[1] - 2.*np.pi/limx[0]) 1508 elif G2frame.plotStyle['dPlot']: 1509 dsp = xpos 1510 q = 2.*np.pi/dsp 1511 xpos = G2lat.Dsp2pos(Parms,xpos) 1512 limx = Plot.get_xlim() 1513 wid = np.fabs(2.*np.pi/limx[1] - 2.*np.pi/limx[0]) 1514 elif G2frame.Contour and 'T' in Parms['Type'][0]: 1515 xpos = X[int(xpos)] 1516 dsp = G2lat.Pos2dsp(Parms,xpos) 1517 q = 2.*np.pi/dsp 1518 limx = Plot.get_xlim() 1519 wid = np.fabs(limx[1]-limx[0]) 1520 else: 1521 dsp = G2lat.Pos2dsp(Parms,xpos) 1522 q = 2.*np.pi/dsp 1523 limx = Plot.get_xlim() 1524 wid = np.fabs(limx[1]-limx[0]) 1525 if G2frame.Contour: #PWDR only 1526 if 'C' in Parms['Type'][0]: 1527 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 1502 1528 else: 1503 dsp = G2lat.Pos2dsp(Parms,xpos) 1504 q = 2.*np.pi/dsp 1505 if G2frame.Contour: #PWDR only 1506 if 'C' in Parms['Type'][0]: 1507 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 1529 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 1530 else: 1531 if 'C' in Parms['Type'][0]: 1532 if 'PWDR' in plottype: 1533 if G2frame.plotStyle['sqrtPlot']: 1534 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1535 else: 1536 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 1537 elif plottype == 'SASD': 1538 G2frame.G2plotNB.status.SetStatusText('q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp),1) 1539 elif plottype == 'REFD': 1540 G2frame.G2plotNB.status.SetStatusText('q =%12.5g Reflectivity =%12.5g d =%9.1f'%(q,ypos,dsp),1) 1541 else: 1542 if G2frame.plotStyle['sqrtPlot']: 1543 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1508 1544 else: 1509 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 1510 else: 1511 if 'C' in Parms['Type'][0]: 1512 if 'PWDR' in plottype: 1513 if G2frame.plotStyle['sqrtPlot']: 1514 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1515 else: 1516 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 1517 elif plottype == 'SASD': 1518 G2frame.G2plotNB.status.SetStatusText('q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp),1) 1519 elif plottype == 'REFD': 1520 G2frame.G2plotNB.status.SetStatusText('q =%12.5g Reflectivity =%12.5g d =%9.1f'%(q,ypos,dsp),1) 1545 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 1546 s = '' 1547 if G2frame.PickId: 1548 pickIdText = G2frame.GPXtree.GetItemText(G2frame.PickId) 1549 else: 1550 pickIdText = '?' # unexpected 1551 if pickIdText in ['Index Peak List', 1552 'Unit Cells List','Reflection Lists'] and len(G2frame.HKL): 1553 found = [] 1554 indx = -1 1555 if pickIdText in ['Index Peak List','Unit Cells List',]: 1556 indx = -2 1557 found = G2frame.HKL[np.where(np.fabs(G2frame.HKL.T[indx]-xpos) < 0.005*wid)] # finds reflections within 1% of plot range 1558 if len(found): 1559 if len(found[0]) > 6: #SS reflections 1560 fmt = "{:.0f},{:.0f},{:.0f},{:.0f}" 1561 n = 4 1521 1562 else: 1522 if G2frame.plotStyle['sqrtPlot']: 1523 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1524 else: 1525 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 1526 if G2frame.itemPicked: 1527 Page.SetToolTipString('%9.5f'%(xpos)) 1528 if G2frame.PickId: 1529 found = [] 1530 pickIdText = G2frame.GPXtree.GetItemText(G2frame.PickId) 1531 if pickIdText in ['Index Peak List','Unit Cells List','Reflection Lists'] or \ 1532 'PWDR' in pickIdText: 1533 indx = -1 1534 if pickIdText in ['Index Peak List','Unit Cells List',]: 1535 indx = -2 1536 if len(G2frame.HKL): 1537 limx = Plot.get_xlim() 1538 wid = limx[1]-limx[0] 1539 found = G2frame.HKL[np.where(np.fabs(G2frame.HKL.T[indx]-xpos) < 0.002*wid)] 1540 if len(found): 1541 if len(found[0]) > 6: #SS reflections 1542 h,k,l,m = found[0][:4] 1543 Page.SetToolTipString('%d,%d,%d,%d'%(int(h),int(k),int(l),int(m))) 1544 else: 1545 h,k,l = found[0][:3] 1546 Page.SetToolTipString('%d,%d,%d'%(int(h),int(k),int(l))) 1547 else: 1548 Page.SetToolTipString('') 1549 1550 except TypeError: 1551 G2frame.G2plotNB.status.SetStatusText('Select '+plottype+' pattern first',1) 1563 fmt = "{:.0f},{:.0f},{:.0f}" 1564 n = 3 1565 for i,hkl in enumerate(found): 1566 if i >= 3: 1567 s += '\n...' 1568 break 1569 if s: s += '\n' 1570 s += fmt.format(*hkl[:n]) 1571 elif G2frame.itemPicked: # not sure when this will happen 1572 s = '%9.5f'%(xpos) 1573 Page.SetToolTipString(s) 1574 1575 except TypeError: 1576 G2frame.G2plotNB.status.SetStatusText('Select '+plottype+' pattern first',1) 1552 1577 1553 1578 def OnPress(event): #ugh - this removes a matplotlib error for mouse clicks in log plots
Note: See TracChangeset
for help on using the changeset viewer.