Changeset 2873
- Timestamp:
- Jun 23, 2017 2:33:41 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r2841 r2873 50 50 51 51 ''' 52 G2frame.dataFrame.SetStatusText('')53 keyList = G2frame.GetHistogramNames(['PWDR','HKLF'])54 UseList = data['Histograms']55 if UseList:56 G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,True)57 for item in G2frame.Refine: item.Enable(True)58 else:59 G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,False)60 for item in G2frame.Refine: item.Enable(False)61 generalData = data['General']62 PhaseName = generalData['Name']63 SGData = generalData['SGData']64 if len(UseList) == 0: # no associated, don't display anything65 G2frame.hist = ''66 elif hist: # something was input as a selection67 G2frame.hist = hist68 elif not G2frame.hist or G2frame.hist not in UseList: # no or bad selection but have data, take the first69 for key in keyList:70 if key in UseList:71 G2frame.hist = key72 break73 PWDR = any(['PWDR' in item for item in keyList])74 Indx = {}75 76 52 def PlotSizer(): 77 53 … … 794 770 795 771 def OnSelect(event): 796 G2frame.hist = keyList[select.GetSelection()]772 G2frame.hist = G2frame.dataFrame.HistsInPhase[select.GetSelection()] 797 773 oldFocus = wx.Window.FindFocus() 798 774 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) … … 812 788 813 789 def ShowHistogramInfo(): 790 '''This creates a sizer with all the information pulled out from the Phase/data dict 791 ''' 814 792 815 793 def OnUseData(event): … … 979 957 bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5) 980 958 return bottomSizer 981 959 960 ###################################################################### 961 # Beginning of UpdateDData execution here 962 ###################################################################### 963 G2frame.dataFrame.SetStatusText('') 964 keyList = G2frame.GetHistogramNames(['PWDR','HKLF']) 965 UseList = data['Histograms'] 966 if UseList: 967 G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,True) 968 for item in G2frame.Refine: item.Enable(True) 969 else: 970 G2frame.dataFrame.DataMenu.Enable(G2gd.wxID_DATADELETE,False) 971 for item in G2frame.Refine: item.Enable(False) 972 # make a list of histograms (any type) used in this phase, ordered as in tree 973 G2frame.dataFrame.HistsInPhase = [name for name in keyList if name in UseList] 974 generalData = data['General'] 975 PhaseName = generalData['Name'] 976 SGData = generalData['SGData'] 977 if len(G2frame.dataFrame.HistsInPhase) == 0: # no associated histograms, nothing to display here 978 G2frame.hist = '' 979 elif hist and hist in G2frame.dataFrame.HistsInPhase: # something was input as a selection as an argument 980 G2frame.hist = hist 981 elif (not G2frame.hist) or (G2frame.hist not in G2frame.dataFrame.HistsInPhase): # no or bad selection but have data, take the first 982 G2frame.hist = G2frame.dataFrame.HistsInPhase[0] 983 Indx = {} 984 982 985 if DData.GetSizer(): 983 986 DData.GetSizer().Clear(True) 984 useList = []985 for name in keyList:986 if name in UseList:987 useList.append(name)988 987 if not G2frame.dataFrame.GetStatusBar(): 989 988 G2frame.dataFrame.CreateStatusBar() 990 989 mainSizer = wx.BoxSizer(wx.VERTICAL) 991 990 mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Histogram data for '+PhaseName+':'),0,WACV|wx.LEFT,5) 992 if G2frame.hist != '':991 if G2frame.hist: 993 992 topSizer = wx.FlexGridSizer(1,2,5,5) 994 select = wx.ListBox(DData,choices=useList,style=wx.LB_SINGLE,size=(-1,120)) 995 select.SetSelection(useList.index(G2frame.hist)) 996 select.SetFirstItem(useList.index(G2frame.hist)) 993 select = wx.ListBox(DData,choices=G2frame.dataFrame.HistsInPhase, 994 style=wx.LB_SINGLE,size=(-1,120)) 995 select.SetSelection(G2frame.dataFrame.HistsInPhase.index(G2frame.hist)) 996 select.SetFirstItem(G2frame.dataFrame.HistsInPhase.index(G2frame.hist)) 997 997 select.Bind(wx.EVT_LISTBOX,OnSelect) 998 998 topSizer.Add(select,0,WACV|wx.LEFT,5) 999 if PWDR:999 if any(['PWDR' in item for item in keyList]): 1000 1000 topSizer.Add(PlotSizer()) 1001 1001 mainSizer.Add(topSizer) … … 1005 1005 mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,' (This project has no data; use Import to read it)'), 1006 1006 0,WACV|wx.TOP,10) 1007 elif not UseList :1007 elif not UseListG2frame.dataFrame.HistsInPhase: 1008 1008 mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,' (This phase has no associated data; use appropriate Edit/Add... menu item)'), 1009 1009 0,WACV|wx.TOP,10) -
trunk/GSASIIphsGUI.py
r2872 r2873 506 506 NShkl = len(G2spc.MustrainNames(SGData)) 507 507 NDij = len(G2spc.HStrainNames(SGData)) 508 UseList = data['Histograms'] 509 for hist in UseList: 510 UseList[hist]['Mustrain'][4:6] = [NShkl*[0.01,],NShkl*[False,]] 511 UseList[hist]['HStrain'] = [NDij*[0.0,],NDij*[False,]] 508 for hist in data['Histograms']: 509 data['Histograms'][hist]['Mustrain'][4:6] = [NShkl*[0.01,],NShkl*[False,]] 510 data['Histograms'][hist]['HStrain'] = [NDij*[0.0,],NDij*[False,]] 512 511 wx.CallAfter(UpdateGeneral) 513 512 … … 5556 5555 5557 5556 def OnHklfAdd(event): 5558 UseList = data['Histograms'] 5559 keyList = UseList.keys() 5557 keyList = data['Histograms'].keys() 5560 5558 TextList = [] 5561 5559 if not G2frame.PatternTree.GetCount(): … … 5605 5603 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) 5606 5604 refDict,reflData = G2frame.PatternTree.GetItemPyData(Id) 5607 UseList[histoName] = {'Histogram':histoName,'Show':False,'Scale':[1.0,True],5605 data['Histograms'][histoName] = {'Histogram':histoName,'Show':False,'Scale':[1.0,True], 5608 5606 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, 5609 5607 'Extinction':['Lorentzian','None', … … 5611 5609 'Flack':[0.0,False],'Twins':[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False,0]],]} 5612 5610 if 'TwMax' in reflData: #nonmerohedral twins present 5613 UseList[histoName]['Twins'] = []5611 data['Histograms'][histoName]['Twins'] = [] 5614 5612 for iT in range(reflData['TwMax'][0]+1): 5615 5613 if iT in reflData['TwMax'][1]: 5616 UseList[histoName]['Twins'].append([False,0.0])5614 data['Histograms'][histoName]['Twins'].append([False,0.0]) 5617 5615 else: 5618 UseList[histoName]['Twins'].append([np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False,reflData['TwMax'][0]]])5616 data['Histograms'][histoName]['Twins'].append([np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False,reflData['TwMax'][0]]]) 5619 5617 else: #no nonmerohedral twins 5620 UseList[histoName]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False,0]],]5618 data['Histograms'][histoName]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False,0]],] 5621 5619 UpdateHKLFdata(histoName) 5622 data['Histograms'] = UseList5623 5620 wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 5624 5621 wx.EndBusyCursor() 5625 5622 5626 5623 def OnDataUse(event): 5627 UseList = data['Histograms']5628 5624 hist = G2frame.hist 5629 keyList = sorted(UseList.keys()) 5630 if UseList: 5625 if data['Histograms']: 5631 5626 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Use histograms', 5632 'Use which histograms?', keyList)5627 'Use which histograms?',G2frame.dataFrame.HistsInPhase) 5633 5628 try: 5634 5629 if dlg.ShowModal() == wx.ID_OK: 5635 5630 sel = dlg.GetSelections() 5636 for id,item in enumerate( keyList):5631 for id,item in enumerate(G2frame.dataFrame.HistsInPhase): 5637 5632 if id in sel: 5638 UseList[item]['Use'] = True5633 data['Histograms'][item]['Use'] = True 5639 5634 else: 5640 UseList[item]['Use'] = False5635 data['Histograms'][item]['Use'] = False 5641 5636 finally: 5642 5637 dlg.Destroy() 5643 5638 wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 5639 5640 # Note: function replaced by one with identical name, below 5641 # def UpdateHKLFdata(histoName): 5642 # generalData = data['General'] 5643 # Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) 5644 # refDict,reflData = G2frame.PatternTree.GetItemPyData(Id) 5645 # SGData = generalData['SGData'] 5646 # Cell = generalData['Cell'][1:7] 5647 # G,g = G2lat.cell2Gmat(Cell)) 5648 # try: 5649 # if dlg.ShowModal() == wx.ID_OK: 5650 # sel = dlg.GetSelections() 5651 # for id,item in enumerate(keyList): # <<<<< something is likely wrong here 5652 # if id in sel: 5653 # data['Histograms'][item]['Use'] = True 5654 # else: 5655 # data['Histograms'][item]['Use'] = False 5656 # finally: 5657 # dlg.Destroy() 5658 # wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 5644 5659 5645 5660 def UpdateHKLFdata(histoName): … … 5656 5671 5657 5672 def OnDataCopy(event): 5658 UseList = data['Histograms']5659 5673 hist = G2frame.hist 5660 keyList = sorted(UseList.keys())5674 keyList = G2frame.dataFrame.HistsInPhase[:] 5661 5675 if hist in keyList: keyList.remove(hist) 5662 sourceDict = UseList[hist] 5676 if not keyList: 5677 G2G.G2MessageBox(G2frame.dataFrame,'No histograms to copy to') 5678 return 5679 sourceDict = data['Histograms'][hist] 5663 5680 if 'HKLF' in sourceDict['Histogram']: 5664 5681 copyNames = ['Scale','Extinction','Babinet','Flack','Twins'] … … 5668 5685 for name in copyNames: 5669 5686 copyDict[name] = copy.deepcopy(sourceDict[name]) #force copy 5670 if UseList: 5671 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5672 u'Copy phase/histogram parameters\nfrom '+hist[5:][:35], 5673 'Copy phase/hist parameters', keyList) 5674 try: 5675 if dlg.ShowModal() == wx.ID_OK: 5676 for sel in dlg.GetSelections(): 5677 UseList[keyList[sel]].update(copy.deepcopy(copyDict)) 5678 finally: 5679 dlg.Destroy() 5687 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5688 u'Copy phase/histogram parameters\nfrom '+hist[5:][:35], 5689 'Copy phase/hist parameters', keyList) 5690 try: 5691 if dlg.ShowModal() == wx.ID_OK: 5692 for sel in dlg.GetSelections(): 5693 data['Histograms'][keyList[sel]].update(copy.deepcopy(copyDict)) 5694 finally: 5695 dlg.Destroy() 5680 5696 5681 5697 def OnDataCopyFlags(event): 5682 UseList = data['Histograms']5683 5698 hist = G2frame.hist 5684 sourceDict = UseList[hist]5699 sourceDict = data['Histograms'][hist] 5685 5700 copyDict = {} 5686 5701 if 'HKLF' in sourceDict['Histogram']: … … 5713 5728 for bab in babNames: 5714 5729 copyDict[name][bab] = sourceDict[name][bab][1] 5715 keyList = sorted(UseList.keys())5730 keyList = G2frame.dataFrame.HistsInPhase[:] 5716 5731 if hist in keyList: keyList.remove(hist) 5717 if UseList: 5718 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5719 u'Copy phase/histogram flags\nfrom '+hist[5:][:35], 5720 'Copy phase/hist flags', keyList) 5721 try: 5722 if dlg.ShowModal() == wx.ID_OK: 5723 for sel in dlg.GetSelections(): 5724 item = keyList[sel] 5725 UseList[item] 5726 for name in copyNames: 5727 if name in ['Scale','Extinction','HStrain','Flack','Twins']: 5728 if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']: 5729 UseList[item][name][:2] = copy.deepcopy(sourceDict[name][:2]) 5730 for itm in ['Eg','Es','Ep']: 5731 UseList[item][name][2][itm][1] = copy.deepcopy(copyDict[name][itm]) 5732 elif name == 'Twins': 5733 UseList[item]['Twins'][0][1][1] = copyDict['Twins'] 5734 else: 5735 try: 5736 UseList[item][name][1] = copy.deepcopy(copyDict[name]) 5737 except KeyError: 5738 continue 5739 elif name in ['Size','Mustrain']: 5740 UseList[item][name][0] = copy.deepcopy(copyDict[name][0]) 5741 UseList[item][name][2] = copy.deepcopy(copyDict[name][1]) 5742 UseList[item][name][4] = copy.deepcopy(copyDict[name][2]) 5743 elif name == 'Pref.Ori.': 5744 UseList[item][name][0] = copy.deepcopy(copyDict[name][0]) 5745 UseList[item][name][2] = copy.deepcopy(copyDict[name][1]) 5746 if sourceDict[name][0] == 'SH': 5747 SHflags = copy.deepcopy(copyDict[name][2]) 5748 SHterms = copy.deepcopy(sourceDict[name][5]) 5749 UseList[item][name][6] = copy.deepcopy(sourceDict[name][6]) 5750 UseList[item][name][7] = copy.deepcopy(sourceDict[name][7]) 5751 elif name == 'Babinet': 5752 for bab in babNames: 5753 UseList[item][name][bab][1] = copy.deepcopy(copyDict[name][bab]) 5754 finally: 5755 dlg.Destroy() 5732 if not keyList: 5733 G2G.G2MessageBox(G2frame.dataFrame,'No histograms to copy to') 5734 return 5735 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5736 u'Copy phase/histogram flags\nfrom '+hist[5:][:35], 5737 'Copy phase/hist flags', keyList) 5738 try: 5739 if dlg.ShowModal() == wx.ID_OK: 5740 for sel in dlg.GetSelections(): 5741 item = keyList[sel] 5742 for name in copyNames: 5743 if name in ['Scale','Extinction','HStrain','Flack','Twins']: 5744 if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']: 5745 data['Histograms'][item][name][:2] = copy.deepcopy(sourceDict[name][:2]) 5746 for itm in ['Eg','Es','Ep']: 5747 data['Histograms'][item][name][2][itm][1] = copy.deepcopy(copyDict[name][itm]) 5748 elif name == 'Twins': 5749 data['Histograms'][item]['Twins'][0][1][1] = copyDict['Twins'] 5750 else: 5751 try: 5752 data['Histograms'][item][name][1] = copy.deepcopy(copyDict[name]) 5753 except KeyError: 5754 continue 5755 elif name in ['Size','Mustrain']: 5756 data['Histograms'][item][name][0] = copy.deepcopy(copyDict[name][0]) 5757 data['Histograms'][item][name][2] = copy.deepcopy(copyDict[name][1]) 5758 data['Histograms'][item][name][4] = copy.deepcopy(copyDict[name][2]) 5759 elif name == 'Pref.Ori.': 5760 data['Histograms'][item][name][0] = copy.deepcopy(copyDict[name][0]) 5761 data['Histograms'][item][name][2] = copy.deepcopy(copyDict[name][1]) 5762 if sourceDict[name][0] == 'SH': 5763 SHflags = copy.deepcopy(copyDict[name][2]) 5764 SHterms = copy.deepcopy(sourceDict[name][5]) 5765 data['Histograms'][item][name][6] = copy.deepcopy(sourceDict[name][6]) 5766 data['Histograms'][item][name][7] = copy.deepcopy(sourceDict[name][7]) 5767 elif name == 'Babinet': 5768 for bab in babNames: 5769 data['Histograms'][item][name][bab][1] = copy.deepcopy(copyDict[name][bab]) 5770 finally: 5771 dlg.Destroy() 5756 5772 5757 5773 def OnSelDataCopy(event): 5758 UseList = data['Histograms']5759 5774 hist = G2frame.hist 5760 keyList = sorted(UseList.keys()) 5775 sourceDict = data['Histograms'][hist] 5776 keyList = G2frame.dataFrame.HistsInPhase[:] 5761 5777 if hist in keyList: keyList.remove(hist) 5762 sourceDict = UseList[hist] 5778 if not keyList: 5779 G2G.G2MessageBox(G2frame.dataFrame,'No histograms to copy to') 5780 return 5763 5781 copyDict = {} 5764 5782 if 'HKLF' in sourceDict['Histogram']: … … 5778 5796 for parm in selectedItems: 5779 5797 copyDict[parm] = copy.deepcopy(sourceDict[parm]) 5780 if UseList: 5781 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5782 u'Copy selected phase/histogram parameters\nfrom '+hist[5:][:35], 5783 'Copy selected phase/hist parameters', keyList) 5784 try: 5785 if dlg.ShowModal() == wx.ID_OK: 5786 for sel in dlg.GetSelections(): 5787 UseList[keyList[sel]].update(copy.deepcopy(copyDict)) 5788 finally: 5789 dlg.Destroy() 5798 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 5799 u'Copy selected phase/histogram parameters\nfrom '+hist[5:][:35], 5800 'Copy selected phase/hist parameters', keyList) 5801 try: 5802 if dlg.ShowModal() == wx.ID_OK: 5803 for sel in dlg.GetSelections(): 5804 data['Histograms'][keyList[sel]].update(copy.deepcopy(copyDict)) 5805 finally: 5806 dlg.Destroy() 5790 5807 5791 5808 def OnPwdrAdd(event): 5792 5809 generalData = data['General'] 5793 5810 SGData = generalData['SGData'] 5794 UseList = data['Histograms']5795 5811 newList = [] 5796 5812 NShkl = len(G2spc.MustrainNames(SGData)) 5797 5813 NDij = len(G2spc.HStrainNames(SGData)) 5798 keyList = UseList.keys()5814 keyList = data['Histograms'].keys() 5799 5815 TextList = [] 5800 5816 if G2frame.PatternTree.GetCount(): … … 5818 5834 for histoName in newList: 5819 5835 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) 5820 UseList[histoName] = {'Histogram':histoName,'Show':False,'LeBail':False,'newLeBail':True,5836 data['Histograms'][histoName] = {'Histogram':histoName,'Show':False,'LeBail':False,'newLeBail':True, 5821 5837 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{},['',],0.1], 5822 5838 'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1], … … 5828 5844 refList = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists')) 5829 5845 refList[generalData['Name']] = {} 5830 data['Histograms'] = UseList5831 5846 wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 5832 5847 finally: … … 5834 5849 5835 5850 def OnDataDelete(event): 5836 UseList = data['Histograms'] 5837 keyList = sorted(UseList.keys()) 5838 keyList.sort() 5839 if UseList: 5851 if G2frame.dataFrame.HistsInPhase: 5840 5852 DelList = [] 5841 5853 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Delete histogram', 5842 'Which histogram to delete from this phase?', keyList)5854 'Which histogram to delete from this phase?',G2frame.dataFrame.HistsInPhase) 5843 5855 try: 5844 5856 if dlg.ShowModal() == wx.ID_OK: 5845 result = dlg.GetSelections() 5846 for i in result: 5847 DelList.append(keyList[i]) 5857 DelList = [G2frame.dataFrame.HistsInPhase[i] for i in dlg.GetSelections()] 5848 5858 for i in DelList: 5849 del UseList[i] 5850 data['Histograms'] = UseList 5859 del data['Histograms'][i] 5851 5860 finally: 5852 5861 dlg.Destroy()
Note: See TracChangeset
for help on using the changeset viewer.