Changeset 1672
 Timestamp:
 Feb 26, 2015 3:02:57 PM (8 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASII.py
r1657 r1672 2087 2087 self.undofile = '' 2088 2088 self.TreeItemDelete = False 2089 self.Offset = [0.0,0.0]2090 self.delOffset = .022091 self.refOffset = 1.02092 self.refDelt = .012089 # self.Offset = [0.0,0.0] 2090 # self.delOffset = .02 2091 # self.refOffset = 1.0 2092 # self.refDelt = .01 2093 2093 self.Weight = False 2094 self.IparmName = '' # to be removed when SelectPowderData & GetInstrumentFile is2095 2094 self.IfPlot = False 2096 2095 self.DDShowAll = False … … 2099 2098 self.PeakTable = [] 2100 2099 self.LimitsTable = [] 2101 self.ifX20 = True #use M20 /= (1+X20) 2100 self.ifX20 = True #use M20 /= (1+X20) in powder indexing, etc. 2102 2101 self.HKL = [] 2103 2102 self.Lines = [] … … 2110 2109 self.Projection = 'equal area' 2111 2110 self.logPlot = False 2112 self.qPlot = False2113 self.dPlot = False2114 2111 self.sqPlot = False 2115 self.SqrtPlot = False2116 2112 self.ErrorBars = False 2117 2113 self.Contour = False … … 2577 2573 'Dummy':False, 2578 2574 'ranId':ran.randint(0,sys.maxint), 2575 'Offset':[0.0,0.0],'delOffset':0.02,'refOffset':1.0,'refDelt':0.01, 2576 'qPlot':False,'dPlot':False,'sqrtPlot':False 2579 2577 } 2580 2578 self.PatternTree.SetItemPyData(Id,[valuesdict,[np.array(Xsum),np.array(Ysum),np.array(Wsum), 
trunk/GSASIIplot.py
r1669 r1672 951 951 global Ymax 952 952 plottype = plotType 953 953 #patch 954 data = G2frame.PatternTree.GetItemPyData(G2frame.PatternId) 955 if 'Offset' not in data[0] and plotType in ['PWDR','SASD']: #plot offset data 956 data[0].update({'Offset':[0.0,0.0],'delOffset':0.02,'refOffset':1.0, 957 'refDelt':0.01,'qPlot':False,'dPlot':False,'sqrtPlot':False}) 958 G2frame.PatternTree.SetItemPyData(G2frame.PickId,data) 959 #end patch 954 960 def OnPlotKeyPress(event): 955 961 try: #one way to check if key stroke will work on plot … … 976 982 G2frame.logPlot = not G2frame.logPlot 977 983 if not G2frame.logPlot: 978 G2frame.Offset[0] = 0984 Pattern[0]['Offset'][0] = 0 979 985 newPlot = True 980 986 elif event.key == 's' and 'PWDR' in plottype: … … 990 996 dlg.Destroy() 991 997 elif G2frame.SinglePlot: 992 G2frame.SqrtPlot = not G2frame.SqrtPlot993 if G2frame.SqrtPlot:994 G2frame.delOffset= .002995 G2frame.refOffset= 1.0996 G2frame.refDelt= .001998 Pattern[0]['sqrtPlot'] = not Pattern[0]['sqrtPlot'] 999 if Pattern[0]['sqrtPlot']: 1000 Pattern[0]['delOffset'] = .002 1001 Pattern[0]['refOffset'] = 1.0 1002 Pattern[0]['refDelt'] = .001 997 1003 else: 998 G2frame.delOffset= .02999 G2frame.refOffset= 1.01000 G2frame.refDelt= .011004 Pattern[0]['delOffset'] = .02 1005 Pattern[0]['refOffset'] = 1.0 1006 Pattern[0]['refDelt'] = .01 1001 1007 newPlot = True 1002 1008 elif event.key == 'u' and (G2frame.Contour or not G2frame.SinglePlot): 1003 1009 if G2frame.Contour: 1004 1010 G2frame.Cmax = min(1.0,G2frame.Cmax*1.2) 1005 elif G2frame.Offset[0] < 100.:1006 G2frame.Offset[0] += 1.1011 elif Pattern[0]['Offset'][0] < 100.: 1012 Pattern[0]['Offset'][0] += 1. 1007 1013 elif event.key == 'd' and (G2frame.Contour or not G2frame.SinglePlot): 1008 1014 if G2frame.Contour: 1009 1015 G2frame.Cmax = max(0.0,G2frame.Cmax*0.8) 1010 elif G2frame.Offset[0] > 0.:1011 G2frame.Offset[0] = 1.1016 elif Pattern[0]['Offset'][0] > 0.: 1017 Pattern[0]['Offset'][0] = 1. 1012 1018 elif event.key == 'l' and not G2frame.SinglePlot: 1013 G2frame.Offset[1] = 1.1019 Pattern[0]['Offset'][1] = 1. 1014 1020 elif event.key == 'r' and not G2frame.SinglePlot: 1015 G2frame.Offset[1] += 1.1021 Pattern[0]['Offset'][1] += 1. 1016 1022 elif event.key == 'o' and not G2frame.SinglePlot: 1017 1023 G2frame.Cmax = 1.0 1018 G2frame.Offset= [0,0]1024 Pattern[0]['Offset'] = [0,0] 1019 1025 elif event.key == 'c' and 'PWDR' in plottype: 1020 1026 newPlot = True 1021 1027 if not G2frame.Contour: 1022 1028 G2frame.SinglePlot = False 1023 G2frame.Offset= [0.,0.]1029 Pattern[0]['Offset'] = [0.,0.] 1024 1030 else: 1025 1031 G2frame.SinglePlot = True … … 1028 1034 if 'PWDR' in plottype: 1029 1035 newPlot = True 1030 G2frame.qPlot = not G2frame.qPlot1031 G2frame.dPlot= False1036 Pattern[0]['qPlot'] = not Pattern[0]['qPlot'] 1037 Pattern[0]['dPlot'] = False 1032 1038 elif 'SASD' in plottype: 1033 1039 newPlot = True 1034 1040 G2frame.sqPlot = not G2frame.sqPlot 1035 1041 elif event.key == 't' and 'PWDR' in plottype: 1036 G2frame.dPlot = not G2frame.dPlot1037 G2frame.qPlot= False1042 Pattern[0]['dPlot'] = not Pattern[0]['dPlot'] 1043 Pattern[0]['qPlot'] = False 1038 1044 newPlot = True 1039 1045 elif event.key == 'm': 1040 G2frame.SqrtPlot= False1046 Pattern[0]['sqrtPlot'] = False 1041 1047 G2frame.SinglePlot = not G2frame.SinglePlot 1042 1048 newPlot = True … … 1068 1074 try: 1069 1075 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')) 1070 if G2frame.qPlotand 'PWDR' in plottype:1076 if Pattern[0]['qPlot'] and 'PWDR' in plottype: 1071 1077 q = xpos 1072 1078 dsp = 2.*np.pi/q … … 1078 1084 q = xpos 1079 1085 dsp = 2.*np.pi/q 1080 elif G2frame.dPlot:1086 elif Pattern[0]['dPlot']: 1081 1087 dsp = xpos 1082 1088 q = 2.*np.pi/dsp … … 1097 1103 if 'C' in Parms['Type'][0]: 1098 1104 if 'PWDR' in plottype: 1099 if G2frame.SqrtPlot:1105 if Pattern[0]['sqrtPlot']: 1100 1106 G2frame.G2plotNB.status.SetStatusText('2theta =%9.3f d =%9.5f q = %9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1101 1107 else: … … 1104 1110 G2frame.G2plotNB.status.SetStatusText('q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp),1) 1105 1111 else: 1106 if G2frame.SqrtPlot:1112 if Pattern[0]['sqrtPlot']: 1107 1113 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 1108 1114 else: … … 1155 1161 if ind.all() != [0] and ObsLine[0].get_label() in str(pick): #picked a data point 1156 1162 data = G2frame.PatternTree.GetItemPyData(G2frame.PickId) 1157 if G2frame.qPlot: #qplot  convert back to 2theta1163 if Pattern[0]['qPlot']: #qplot  convert back to 2theta 1158 1164 xy[0] = G2lat.Dsp2pos(Parms,2*np.pi/xy[0]) 1159 elif G2frame.dPlot: #dplot  convert back to 2theta1165 elif Pattern[0]['dPlot']: #dplot  convert back to 2theta 1160 1166 xy[0] = G2lat.Dsp2pos(Parms,xy[0]) 1161 1167 XY = G2mth.setPeakparms(Parms,Parms2,xy[0],xy[1]) … … 1170 1176 LimitId = G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits') 1171 1177 data = G2frame.PatternTree.GetItemPyData(LimitId) 1172 if G2frame.qPlot: #qplot  convert back to 2theta1178 if Pattern[0]['qPlot']: #qplot  convert back to 2theta 1173 1179 xy[0] = G2lat.Dsp2pos(Parms,2*np.pi/xy[0]) 1174 elif G2frame.dPlot: #dplot  convert back to 2theta1180 elif Pattern[0]['dPlot']: #dplot  convert back to 2theta 1175 1181 xy[0] = G2lat.Dsp2pos(Parms,xy[0]) 1176 1182 if G2frame.ifGetExclude: … … 1209 1215 def OnRelease(event): 1210 1216 if G2frame.itemPicked is None: return 1217 PickId = G2frame.PickId 1211 1218 if str(DifLine[0]) == str(G2frame.itemPicked): 1219 data = G2frame.PatternTree.GetItemPyData(PickId) 1212 1220 ypos = event.ydata 1213 G2frame.delOffset= ypos/Ymax1221 data[0]['delOffset'] = ypos/Ymax 1214 1222 G2frame.itemPicked = None 1223 G2frame.PatternTree.SetItemPyData(PickId,data) 1215 1224 PlotPatterns(G2frame,plotType=plottype) 1216 1225 return 1217 1226 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')) 1218 1227 xpos = event.xdata 1219 PickId = G2frame.PickId1220 1228 if G2frame.PatternTree.GetItemText(PickId) in ['Peak List','Limits'] and xpos: 1221 1229 lines = [] … … 1231 1239 id = lineNo/2+1 1232 1240 id2 = lineNo%2 1233 if G2frame.qPlotand 'PWDR' in plottype:1241 if Pattern[0]['qPlot'] and 'PWDR' in plottype: 1234 1242 data[id][id2] = G2lat.Dsp2pos(Parms,2.*np.pi/xpos) 1235 elif G2frame.dPlotand 'PWDR' in plottype:1243 elif Pattern[0]['dPlot'] and 'PWDR' in plottype: 1236 1244 data[id][id2] = G2lat.Dsp2pos(Parms,xpos) 1237 1245 else: … … 1250 1258 del data['peaks'][lineNo2] 1251 1259 else: 1252 if G2frame.qPlot:1260 if Pattern[0]['qPlot']: 1253 1261 data['peaks'][lineNo2][0] = G2lat.Dsp2pos(Parms,2.*np.pi/xpos) 1254 elif G2frame.dPlot:1262 elif Pattern[0]['dPlot']: 1255 1263 data['peaks'][lineNo2][0] = G2lat.Dsp2pos(Parms,xpos) 1256 1264 else: … … 1279 1287 pick = str(G2frame.itemPicked).split('(')[1].strip(')') 1280 1288 if 'line' not in pick: #avoid data points, etc. 1289 data = G2frame.PatternTree.GetItemPyData(PickId) 1281 1290 num = Phases.keys().index(pick) 1282 1291 if num: 1283 G2frame.refDelt = (event.ydataG2frame.refOffset)/(num*Ymax)1292 data[0]['refDelt'] = (event.ydataPattern[0]['refOffset'])/(num*Ymax) 1284 1293 else: #1st row of refl ticks 1285 G2frame.refOffset = event.ydata 1294 data[0]['refOffset'] = event.ydata 1295 G2frame.PatternTree.SetItemPyData(PickId,data) 1286 1296 PlotPatterns(G2frame,plotType=plottype) 1287 1297 G2frame.itemPicked = None … … 1414 1424 Ymax = max(Ymax,max(xye[1])) 1415 1425 if Ymax is None: return # nothing to plot 1416 offset = G2frame.Offset[0]*Ymax/100.01426 offset = Pattern[0]['Offset'][0]*Ymax/100.0 1417 1427 if G2frame.logPlot: 1418 1428 Title = 'log('+Title+')' 1419 1429 Plot.set_title(Title) 1420 if G2frame.qPlotor 'SASD' in plottype and not G2frame.Contour:1430 if Pattern[0]['qPlot'] or 'SASD' in plottype and not G2frame.Contour: 1421 1431 Plot.set_xlabel(r'$Q, \AA^{1}$',fontsize=16) 1422 elif G2frame.dPlotand 'PWDR' in plottype and not G2frame.Contour:1432 elif Pattern[0]['dPlot'] and 'PWDR' in plottype and not G2frame.Contour: 1423 1433 Plot.set_xlabel(r'$d, \AA$',fontsize=16) 1424 1434 else: … … 1438 1448 if 'C' in ParmList[0]['Type'][0]: 1439 1449 if 'PWDR' in plottype: 1440 if G2frame.SqrtPlot:1450 if Pattern[0]['sqrtPlot']: 1441 1451 Plot.set_ylabel(r'$\sqrt{Intensity}$',fontsize=16) 1442 1452 else: … … 1448 1458 Plot.set_ylabel(r'$Intensity, cm^{1}$',fontsize=16) 1449 1459 else: 1450 if G2frame.SqrtPlot:1460 if Pattern[0]['sqrtPlot']: 1451 1461 Plot.set_ylabel(r'$\sqrt{Normalized\ intensity}$',fontsize=16) 1452 1462 else: … … 1475 1485 for excl in excls: 1476 1486 xye[0] = ma.masked_inside(xye[0],excl[0],excl[1]) 1477 if G2frame.qPlotand 'PWDR' in plottype:1487 if Pattern[0]['qPlot'] and 'PWDR' in plottype: 1478 1488 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2]) 1479 1489 X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye[0]) 1480 elif G2frame.dPlotand 'PWDR' in plottype:1490 elif Pattern[0]['dPlot'] and 'PWDR' in plottype: 1481 1491 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2]) 1482 1492 X = G2lat.Pos2dsp(Parms,xye[0]) … … 1486 1496 lenX = len(X) 1487 1497 if 'PWDR' in plottype: 1488 if G2frame.SqrtPlot:1498 if Pattern[0]['sqrtPlot']: 1489 1499 olderr = np.seterr(invalid='ignore') #get around sqrt(ve) error 1490 1500 Y = np.where(xye[1]>=0.,np.sqrt(xye[1]),np.sqrt(xye[1])) … … 1495 1505 B = xye[5] 1496 1506 if G2frame.sqPlot: 1497 Y = xye[1]*Sample['Scale'][0]*(1.05)**( G2frame.Offset[0]*N)*X**41507 Y = xye[1]*Sample['Scale'][0]*(1.05)**(Pattern[0]['Offset'][0]*N)*X**4 1498 1508 else: 1499 Y = xye[1]*Sample['Scale'][0]*(1.05)**( G2frame.Offset[0]*N)1509 Y = xye[1]*Sample['Scale'][0]*(1.05)**(Pattern[0]['Offset'][0]*N) 1500 1510 if LimitId and ifpicked: 1501 1511 limits = np.array(G2frame.PatternTree.GetItemPyData(LimitId)) 1502 1512 lims = limits[1] 1503 if G2frame.qPlotand 'PWDR' in plottype:1513 if Pattern[0]['qPlot'] and 'PWDR' in plottype: 1504 1514 lims = 2.*np.pi/G2lat.Pos2dsp(Parms,lims) 1505 elif G2frame.dPlotand 'PWDR' in plottype:1515 elif Pattern[0]['dPlot'] and 'PWDR' in plottype: 1506 1516 lims = G2lat.Pos2dsp(Parms,lims) 1507 1517 Lines.append(Plot.axvline(lims[0],color='g',dashes=(5,5),picker=3.)) … … 1523 1533 else: 1524 1534 if 'SASD' in plottype and G2frame.logPlot: 1525 X *= (1.01)**( G2frame.Offset[1]*N)1535 X *= (1.01)**(Pattern[0]['Offset'][1]*N) 1526 1536 else: 1527 X += G2frame.Offset[1]*.005*N1537 X += Pattern[0]['Offset'][1]*.005*N 1528 1538 Xum = ma.getdata(X) 1529 1539 DifLine = [''] 1530 1540 if ifpicked: 1531 if G2frame.SqrtPlot:1541 if Pattern[0]['sqrtPlot']: 1532 1542 olderr = np.seterr(invalid='ignore') #get around sqrt(ve) error 1533 1543 Z = np.where(xye[3]>=0.,np.sqrt(xye[3]),np.sqrt(xye[3])) … … 1536 1546 Z = xye[3]+offset*N 1537 1547 if 'PWDR' in plottype: 1538 if G2frame.SqrtPlot:1548 if Pattern[0]['sqrtPlot']: 1539 1549 olderr = np.seterr(invalid='ignore') #get around sqrt(ve) error 1540 1550 W = np.where(xye[4]>=0.,np.sqrt(xye[4]),np.sqrt(xye[4])) 1541 1551 np.seterr(invalid=olderr['invalid']) 1542 D = np.where(xye[5],(YZ),0.)Ymax* G2frame.delOffset1552 D = np.where(xye[5],(YZ),0.)Ymax*Pattern[0]['delOffset'] 1543 1553 else: 1544 1554 W = xye[4]+offset*N 1545 D = xye[5]Ymax* G2frame.delOffset#powder background1555 D = xye[5]Ymax*Pattern[0]['delOffset'] #powder background 1546 1556 elif 'SASD' in plottype: 1547 1557 if G2frame.sqPlot: … … 1595 1605 Ymax = max(DY) 1596 1606 DZ = xye[3]*np.sqrt(xye[2]) 1597 DS = xye[5]*np.sqrt(xye[2])Ymax* G2frame.delOffset1607 DS = xye[5]*np.sqrt(xye[2])Ymax*Pattern[0]['delOffset'] 1598 1608 ObsLine = Plot.plot(X,DY,colors[N%6]+'+',picker=3.,clip_on=False) #Io/sig(Io) 1599 1609 Plot.plot(X,DZ,colors[(N+1)%6],picker=False) #Ic/sig(Io) … … 1625 1635 data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List')) 1626 1636 for item in data['peaks']: 1627 if G2frame.qPlot:1637 if Pattern[0]['qPlot']: 1628 1638 Lines.append(Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,item[0]),color=colors[N%6],picker=2.)) 1629 elif G2frame.dPlot:1639 elif Pattern[0]['dPlot']: 1630 1640 Lines.append(Plot.axvline(G2lat.Pos2dsp(Parms,item[0]),color=colors[N%6],picker=2.)) 1631 1641 else: … … 1658 1668 for peak in peaks[0]: 1659 1669 if peak[2]: 1660 if G2frame.qPlot:1670 if Pattern[0]['qPlot']: 1661 1671 Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,peak[0]),color='b') 1662 if G2frame.dPlot:1672 if Pattern[0]['dPlot']: 1663 1673 Plot.axvline(G2lat.Pos2dsp(Parms,peak[0]),color='b') 1664 1674 else: … … 1668 1678 if len(hkl) > 6 and hkl[3]: 1669 1679 clr = 'g' 1670 if G2frame.qPlot:1680 if Pattern[0]['qPlot']: 1671 1681 Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,hkl[2]),color=clr,dashes=(5,5)) 1672 if G2frame.dPlot:1682 if Pattern[0]['dPlot']: 1673 1683 Plot.axvline(G2lat.Pos2dsp(Parms,hkl[2]),color=clr,dashes=(5,5)) 1674 1684 else: … … 1689 1699 else: 1690 1700 peak = np.array([[peak[4],peak[5]] for peak in peaks]) 1691 pos = G2frame.refOffsetpId*Ymax*G2frame.refDelt*np.ones_like(peak)1692 if G2frame.qPlot:1701 pos = Pattern[0]['refOffset']pId*Ymax*Pattern[0]['refDelt']*np.ones_like(peak) 1702 if Pattern[0]['qPlot']: 1693 1703 Plot.plot(2*np.pi/peak.T[0],pos,refColors[pId%6]+'',mew=1,ms=8,picker=3.,label=phase) 1694 elif G2frame.dPlot:1704 elif Pattern[0]['dPlot']: 1695 1705 Plot.plot(peak.T[0],pos,refColors[pId%6]+'',mew=1,ms=8,picker=3.,label=phase) 1696 1706 else: … … 1799 1809 if G2frame.Contour: 1800 1810 G2frame.Cmax = min(1.0,G2frame.Cmax*1.2) 1801 elif G2frame.Offset[0] < 100.:1802 G2frame.Offset[0] += 1.1811 elif Pattern[0]['Offset'][0] < 100.: 1812 Pattern[0]['Offset'][0] += 1. 1803 1813 elif event.key == 'd': 1804 1814 if G2frame.Contour: 1805 1815 G2frame.Cmax = max(0.0,G2frame.Cmax*0.8) 1806 elif G2frame.Offset[0] > 0.:1807 G2frame.Offset[0] = 1.1816 elif Pattern[0]['Offset'][0] > 0.: 1817 Pattern[0]['Offset'][0] = 1. 1808 1818 elif event.key == 'l': 1809 G2frame.Offset[1] = 1.1819 Pattern[0]['Offset'][1] = 1. 1810 1820 elif event.key == 'r': 1811 G2frame.Offset[1] += 1.1821 Pattern[0]['Offset'][1] += 1. 1812 1822 elif event.key == 'o': 1813 G2frame.Offset= [0,0]1823 Pattern[0]['Offset'] = [0,0] 1814 1824 elif event.key == 'c': 1815 1825 newPlot = True … … 1817 1827 if not G2frame.Contour: 1818 1828 G2frame.SinglePlot = False 1819 G2frame.Offset= [0.,0.]1829 Pattern[0]['Offset'] = [0.,0.] 1820 1830 elif event.key == 's': 1821 1831 if G2frame.Contour: … … 1936 1946 return 1937 1947 Ymax = max(Ymax,max(xye[1])) 1938 offset = G2frame.Offset[0]*Ymax/100.01948 offset = Pattern[0]['Offset'][0]*Ymax/100.0 1939 1949 if G2frame.Contour: 1940 1950 ContourZ = [] … … 1957 1967 Plot.set_ylabel('Data sequence',fontsize=12) 1958 1968 else: 1959 X = xye[0]+ G2frame.Offset[1]*.005*N1969 X = xye[0]+Pattern[0]['Offset'][1]*.005*N 1960 1970 if ifpicked: 1961 1971 Plot.plot(X,Y,colors[N%6]+'+',picker=3.,clip_on=False)
Note: See TracChangeset
for help on using the changeset viewer.