Changeset 1172
- Timestamp:
- Dec 17, 2013 4:12:54 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1170 r1172 73 73 import GSASIImapvars as G2mv 74 74 import GSASIIobj as G2obj 75 import GSASIIlattice as G2lat 75 76 76 77 #wx inspector - use as needed … … 417 418 errorReport = '' 418 419 for rd in primaryReaders+secondaryReaders: 420 rd.ReInitialize() # purge anything from a previous read 419 421 fp.seek(0) # rewind 420 422 rd.errors = "" # clear out any old errors … … 502 504 # look up which format was requested 503 505 reqrdr = self.ImportMenuId.get(event.GetId()) 504 # make a list of used phase ranId's 505 phaseRIdList = [] 506 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 507 if sub: 508 item, cookie = self.PatternTree.GetFirstChild(sub) 509 while item: 510 phaseName = self.PatternTree.GetItemText(item) 511 ranId = self.PatternTree.GetItemPyData(item).get('ranId') 512 if ranId: phaseRIdList.append(ranId) 513 item, cookie = self.PatternTree.GetNextChild(sub, cookie) 506 507 # make a list of phase names, ranId's and the histograms used in those phases 508 phaseRIdList,usedHistograms = self.GetPhaseInfofromTree() 509 phaseNameList = usedHistograms.keys() # phase names in use 510 usedHKLFhists = [] # used single-crystal histograms 511 for p in usedHistograms: 512 for h in usedHistograms[p]: 513 if h.startswith('HKLF ') and h not in usedHKLFhists: 514 usedHKLFhists.append(h) 514 515 rdlist = self.OnImportGeneric(reqrdr, 515 516 self.ImportPhaseReaderlist, … … 517 518 if len(rdlist) == 0: return 518 519 # for now rdlist is only expected to have one element 519 # but this will allow multiple phases to be imported 520 # but below will allow multiple phases to be imported 521 # if ever the import routines ever implement multiple phase reads. 520 522 self.CheckNotebook() 523 newPhaseList = [] 521 524 for rd in rdlist: 522 525 dlg = wx.TextEntryDialog( # allow editing of phase name … … 528 531 rd.Phase['General']['Name'] = dlg.GetValue() 529 532 dlg.Destroy() 533 # make new phase names unique 534 rd.Phase['General']['Name'] = G2obj.MakeUniqueLabel(rd.Phase['General']['Name'],phaseNameList) 530 535 PhaseName = rd.Phase['General']['Name'] 536 newPhaseList.append(PhaseName) 531 537 print 'Read phase '+str(PhaseName)+' from file '+str(self.lastimport) 532 538 if not G2gd.GetPatternTreeItemId(self,self.root,'Phases'): … … 539 545 self.PatternTree.Expand(sub) 540 546 self.PatternTree.Expand(psub) 547 self.PatternTree.UnselectAll() 548 self.PatternTree.SelectItem(psub) # show the page to complete the initialization (yuk!) 549 wx.Yield() # make sure call of GSASII.OnPatternTreeSelChanged happens before we go on 550 541 551 if rd.Constraints: 542 552 sub = G2gd.GetPatternTreeItemId(self,self.root,'Constraints') # was created in CheckNotebook if needed … … 550 560 continue 551 561 Constraints['Phase'].append(i) 562 if not newPhaseList: return # somehow, no new phases 563 # get a list of existing histograms 564 PWDRlist = [] 565 HKLFlist = [] 566 if self.PatternTree.GetCount(): 567 item, cookie = self.PatternTree.GetFirstChild(self.root) 568 while item: 569 name = self.PatternTree.GetItemText(item) 570 if name.startswith('PWDR ') and name not in PWDRlist: 571 PWDRlist.append(name) 572 if name.startswith('HKLF ') and name not in HKLFlist: 573 HKLFlist.append(name) 574 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 575 TextList = PWDRlist + HKLFlist 576 if not len(TextList): return # no data loaded yet 577 header = 'Select histogram(s) to add to new phase(s):' 578 for phaseName in newPhaseList: 579 header += '\n '+str(phaseName) 580 581 notOK = True 582 while notOK: 583 result = G2gd.ItemSelector(TextList,self,header,header='Add histogram(s)',multiple=True) 584 if not result: return 585 # check that selected single crystal histograms are not already in use! 586 used = [TextList[i] for i in result if TextList[i] in usedHKLFhists] 587 #for i in result: 588 # if TextList[i] in usedHKLFhists: used.append(TextList[i]) 589 if used: 590 msg = 'The following single crystal histogram(s) are already in use' 591 for i in used: 592 msg += '\n '+str(i) 593 msg += '\nAre you sure you want to add them to this phase? ' 594 msg += 'Associating a single crystal dataset to >1 histogram is usually an error, ' 595 msg += 'so No is suggested here.' 596 if self.ErrorDialog('Likely error',msg,self,wtype=wx.YES_NO) == wx.ID_YES: notOK = False 597 else: 598 notOK = False 599 # connect new phases to histograms 600 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 601 if not sub: 602 raise Exception('ERROR -- why are there no phases here?') 603 wx.BeginBusyCursor() 604 item, cookie = self.PatternTree.GetFirstChild(sub) 605 while item: # loop over (new) phases 606 phaseName = self.PatternTree.GetItemText(item) 607 data = self.PatternTree.GetItemPyData(item) 608 item, cookie = self.PatternTree.GetNextChild(sub, cookie) 609 if phaseName not in newPhaseList: continue 610 generalData = data['General'] 611 SGData = generalData['SGData'] 612 UseList = data['Histograms'] 613 NShkl = len(G2spc.MustrainNames(SGData)) 614 NDij = len(G2spc.HStrainNames(SGData)) 615 for i in result: 616 histoName = TextList[i] 617 if histoName in HKLFlist: 618 UseList[histoName] = { 619 'Histogram':histoName,'Show':False,'Scale':[1.0,True], 620 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, 621 'Extinction':['Lorentzian','None', {'Tbar':0.1,'Cos2TM':0.955, 622 'Eg':[1.e-10,False], 623 'Es':[1.e-10,False], 624 'Ep':[1.e-10,False]},] 625 } 626 #redo UpdateHKLFdata(histoName) here: 627 Id = G2gd.GetPatternTreeItemId(self,self.root,histoName) 628 refDict,reflData = self.PatternTree.GetItemPyData(Id) 629 G,g = G2lat.cell2Gmat(generalData['Cell'][1:7]) 630 for iref,ref in enumerate(reflData['RefList']): 631 H = list(ref[:3]) 632 ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G)) 633 iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData) 634 elif histoName in PWDRlist: 635 UseList[histoName] = { 636 'Histogram':histoName,'Show':False, 637 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{}], 638 'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1], 639 [1.,1.,1.,0.,0.,0.],6*[False,]], 640 'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1], 641 NShkl*[0.01,],NShkl*[False,]], 642 'HStrain':[NDij*[0.0,],NDij*[False,]], 643 'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}} 644 Id = G2gd.GetPatternTreeItemId(self,self.root,histoName) 645 refList = self.PatternTree.GetItemPyData( 646 G2gd.GetPatternTreeItemId(self,Id,'Reflection Lists')) 647 refList[generalData['Name']] = [] 648 else: 649 raise Exception('Unexpected histogram '+str(histoName)) 650 wx.EndBusyCursor() 552 651 return # success 553 652 … … 577 676 where all appropriate formats will be tried. 578 677 ''' 678 # get a list of existing histograms 679 HKLFlist = [] 680 if self.PatternTree.GetCount(): 681 item, cookie = self.PatternTree.GetFirstChild(self.root) 682 while item: 683 name = self.PatternTree.GetItemText(item) 684 if name.startswith('HKLF ') and name not in HKLFlist: 685 HKLFlist.append(name) 686 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 579 687 # look up which format was requested 580 688 reqrdr = self.ImportMenuId.get(event.GetId()) … … 583 691 if len(rdlist) == 0: return 584 692 self.CheckNotebook() 693 newHistList = [] 585 694 for rd in rdlist: 586 695 HistName = rd.objname … … 594 703 HistName = dlg.GetValue() 595 704 dlg.Destroy() 705 HistName = 'HKLF '+HistName 706 # make new phase names unique 707 HistName = G2obj.MakeUniqueLabel(HistName,HKLFlist) 596 708 print 'Read structure factor table '+str(HistName)+' from file '+str(self.lastimport) 597 if not rd.RefDict ['FF']:709 if not rd.RefDict.get('FF'): 598 710 rd.RefDict['FF'] = [{} for i in range(len(rd.RefDict['RefList']))] 599 Id = self.PatternTree.AppendItem(parent=self.root, 600 text='HKLF '+HistName) 711 Id = self.PatternTree.AppendItem(parent=self.root,text=HistName) 601 712 valuesdict = { 602 713 'wtFactor':1.0, … … 615 726 self.PatternTree.Expand(Id) 616 727 self.Sngl = Id 728 newHistList.append(HistName) 729 730 if not newHistList: return # somehow, no new histograms 731 # make a list of phase names 732 phaseRIdList,usedHistograms = self.GetPhaseInfofromTree() 733 phaseNameList = usedHistograms.keys() # phase names in use 734 if not phaseNameList: return # no phases yet, nothing to do 735 header = 'Select phase(s) to add the new\nsingle crystal dataset(s) to:' 736 for Name in newHistList: 737 header += '\n '+str(Name) 738 739 notOK = True 740 result = G2gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True) 741 if not result: return 742 # connect new phases to histograms 743 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 744 if not sub: 745 raise Exception('ERROR -- why are there no phases here?') 746 wx.BeginBusyCursor() 747 item, cookie = self.PatternTree.GetFirstChild(sub) 748 iph = -1 749 while item: # loop over (new) phases 750 iph += 1 751 phaseName = self.PatternTree.GetItemText(item) 752 data = self.PatternTree.GetItemPyData(item) 753 item, cookie = self.PatternTree.GetNextChild(sub, cookie) 754 if iph not in result: continue 755 generalData = data['General'] 756 SGData = generalData['SGData'] 757 UseList = data['Histograms'] 758 NShkl = len(G2spc.MustrainNames(SGData)) 759 NDij = len(G2spc.HStrainNames(SGData)) 760 for histoName in newHistList: 761 UseList[histoName] = { 762 'Histogram':histoName,'Show':False,'Scale':[1.0,True], 763 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, 764 'Extinction':['Lorentzian','None', {'Tbar':0.1,'Cos2TM':0.955, 765 'Eg':[1.e-10,False], 766 'Es':[1.e-10,False], 767 'Ep':[1.e-10,False]},] 768 } 769 #redo UpdateHKLFdata(histoName) here: 770 Id = G2gd.GetPatternTreeItemId(self,self.root,histoName) 771 refDict,reflData = self.PatternTree.GetItemPyData(Id) 772 G,g = G2lat.cell2Gmat(generalData['Cell'][1:7]) 773 for iref,ref in enumerate(reflData['RefList']): 774 H = list(ref[:3]) 775 ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G)) 776 iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData) 777 wx.EndBusyCursor() 778 617 779 return # success 618 780 … … 986 1148 Also reads an instrument parameter file for each dataset. 987 1149 ''' 988 reqrdr = self.ImportMenuId.get(event.GetId()) # look up which format was requested 1150 # get a list of existing histograms 1151 PWDRlist = [] 1152 if self.PatternTree.GetCount(): 1153 item, cookie = self.PatternTree.GetFirstChild(self.root) 1154 while item: 1155 name = self.PatternTree.GetItemText(item) 1156 if name.startswith('PWDR ') and name not in PWDRlist: 1157 PWDRlist.append(name) 1158 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 1159 # look up which format was requested 1160 reqrdr = self.ImportMenuId.get(event.GetId()) 989 1161 rdlist = self.OnImportGeneric( 990 1162 reqrdr,self.ImportPowderReaderlist,'Powder Data',multiple=True) … … 994 1166 lastIparmfile = '' 995 1167 lastdatafile = '' 1168 newHistList = [] 996 1169 for rd in rdlist: 997 1170 # get instrument parameters for each dataset … … 1000 1173 lastIparmfile = rd.instfile 1001 1174 lastdatafile = rd.powderentry[0] 1002 print 'Read powder data '+str(rd.idstring)+ \ 1175 HistName = rd.idstring 1176 HistName = 'PWDR '+HistName 1177 # make new phase names unique 1178 HistName = G2obj.MakeUniqueLabel(HistName,PWDRlist) 1179 print 'Read powder data '+str(HistName)+ \ 1003 1180 ' from file '+str(self.lastimport) + \ 1004 1181 ' with parameters from '+str(rd.instmsg) 1005 1182 # data are read, now store them in the tree 1006 Id = self.PatternTree.AppendItem(parent=self.root, 1007 text='PWDR '+rd.idstring) 1183 Id = self.PatternTree.AppendItem(parent=self.root,text=HistName) 1008 1184 if 'T' in Iparm1['Type'][0]: 1009 1185 if not rd.clockWd and rd.GSAS: … … 1065 1241 {}) 1066 1242 self.PatternTree.Expand(Id) 1067 self.PatternTree.SelectItem(Id) 1243 self.PatternTree.SelectItem(Id) 1244 newHistList.append(HistName) 1245 1246 if not newHistList: return # somehow, no new histograms 1247 # make a list of phase names 1248 phaseRIdList,usedHistograms = self.GetPhaseInfofromTree() 1249 phaseNameList = usedHistograms.keys() # phase names in use 1250 if not phaseNameList: return # no phases yet, nothing to do 1251 header = 'Select phase(s) to add the new\npowder dataset(s) to:' 1252 for Name in newHistList: 1253 header += '\n '+str(Name) 1254 1255 notOK = True 1256 result = G2gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True) 1257 if not result: return 1258 # connect new phases to histograms 1259 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 1260 if not sub: 1261 raise Exception('ERROR -- why are there no phases here?') 1262 item, cookie = self.PatternTree.GetFirstChild(sub) 1263 iph = -1 1264 while item: # loop over (new) phases 1265 iph += 1 1266 phaseName = self.PatternTree.GetItemText(item) 1267 data = self.PatternTree.GetItemPyData(item) 1268 item, cookie = self.PatternTree.GetNextChild(sub, cookie) 1269 if iph not in result: continue 1270 generalData = data['General'] 1271 SGData = generalData['SGData'] 1272 UseList = data['Histograms'] 1273 NShkl = len(G2spc.MustrainNames(SGData)) 1274 NDij = len(G2spc.HStrainNames(SGData)) 1275 for histoName in newHistList: 1276 UseList[histoName] = { 1277 'Histogram':histoName,'Show':False, 1278 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{}], 1279 'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1], 1280 [1.,1.,1.,0.,0.,0.],6*[False,]], 1281 'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1], 1282 NShkl*[0.01,],NShkl*[False,]], 1283 'HStrain':[NDij*[0.0,],NDij*[False,]], 1284 'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}} 1285 Id = G2gd.GetPatternTreeItemId(self,self.root,histoName) 1286 refList = self.PatternTree.GetItemPyData( 1287 G2gd.GetPatternTreeItemId(self,Id,'Reflection Lists')) 1288 refList[generalData['Name']] = [] 1068 1289 return # success 1069 1290 … … 1589 1810 finally: 1590 1811 dlg.Destroy() 1591 1812 1592 1813 def OnImageRead(self,event): 1593 1814 'Called to read in an image in any known format' … … 2533 2754 return phaseData 2534 2755 2756 def GetPhaseInfofromTree(self): 2757 '''Get the phase names and their rId values, 2758 also the histograms used in each phase. 2759 2760 :returns: (phaseRIdList, usedHistograms) where 2761 2762 * 2763 ,phaseRIdList,usedHistograms 2764 ''' 2765 phaseRIdList = [] 2766 usedHistograms = {} 2767 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 2768 if sub: 2769 item, cookie = self.PatternTree.GetFirstChild(sub) 2770 while item: 2771 phaseName = self.PatternTree.GetItemText(item) 2772 ranId = self.PatternTree.GetItemPyData(item).get('ranId') 2773 if ranId: phaseRIdList.append(ranId) 2774 data = self.PatternTree.GetItemPyData(item) 2775 UseList = data['Histograms'] 2776 usedHistograms[phaseName] = UseList.keys() 2777 item, cookie = self.PatternTree.GetNextChild(sub, cookie) 2778 return phaseRIdList,usedHistograms 2779 2535 2780 def GetPhaseNames(self): 2536 2781 '''Returns a list of defined phases. -
trunk/GSASIIIO.py
r1168 r1172 1294 1294 #print 'created',self.__class__ 1295 1295 1296 def ReInitialize(self): 1297 'Reinitialize the Reader to initital settings' 1298 self.errors = '' 1299 self.warnings = '' 1300 self.repeat = False 1301 self.repeatcount = 0 1302 1296 1303 def BlockSelector(self, ChoiceList, ParentFrame=None, 1297 1304 title='Select a block', … … 1494 1501 is left as initialized (an empty list) it will be initialized as needed later. 1495 1502 ''' 1503 def ReInitialize(self): 1504 'Reinitialize the Reader to initital settings' 1505 ImportBaseclass.ReInitialize(self) 1506 self.InitParameters() 1507 self.InitControls() 1508 self.RefDict = {'RefList':[],'FF':[]} 1509 1496 1510 1497 1511 def InitControls(self): -
trunk/GSASIIddataGUI.py
r1077 r1172 972 972 mainSizer.Add((0,5),0) 973 973 pass 974 #G2gd.HorizontalLine(mainSizer,DData) 974 if UseList[item]['Show']: 975 G2gd.HorizontalLine(mainSizer,DData) 976 975 977 mainSizer.Add((5,5),0) 976 978 G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer) -
trunk/GSASIIgrid.py
r1161 r1172 1436 1436 size=None, header='Item Selector', 1437 1437 useCancel=True,multiple=False): 1438 ''' Provide a wx dialog to select a single item from list of choices 1439 1440 :param list ChoiceList: a list of choices where one will be selected 1441 :param wx.Frame ParentFrame: Name of parent frame (default None) 1442 :param str title: heading above list of choices (default 'Select an item') 1443 :param wx.Size size: Size for dialog to be created (default None -- size as needed) 1444 :param str header: Title to place on window frame (default 'Item Selector') 1445 :param bool useCancel: If True (default) both the OK and Cancel buttons are offered 1446 :param bool multiple: If True then multiple items can be selected (default False) 1447 1448 :returns: the selection index or None or a selection list if multiple is true 1449 ''' 1438 ''' Provide a wx dialog to select a single item or multiple items from list of choices 1439 1440 :param list ChoiceList: a list of choices where one will be selected 1441 :param wx.Frame ParentFrame: Name of parent frame (default None) 1442 :param str title: heading above list of choices (default 'Select an item') 1443 :param wx.Size size: Size for dialog to be created (default None -- size as needed) 1444 :param str header: Title to place on window frame (default 'Item Selector') 1445 :param bool useCancel: If True (default) both the OK and Cancel buttons are offered 1446 :param bool multiple: If True then multiple items can be selected (default False) 1447 1448 :returns: the selection index or None or a selection list if multiple is true 1449 ''' 1450 if multiple: 1451 if useCancel: 1452 dlg = G2MultiChoiceDialog( 1453 ParentFrame,title, header, ChoiceList) 1454 else: 1455 dlg = G2MultiChoiceDialog( 1456 ParentFrame,title, header, ChoiceList, 1457 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 1458 else: 1459 if useCancel: 1460 dlg = wx.SingleChoiceDialog( 1461 ParentFrame,title, header, ChoiceList) 1462 else: 1463 dlg = wx.SingleChoiceDialog( 1464 ParentFrame,title, header,ChoiceList, 1465 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 1466 if size: dlg.SetSize(size) 1467 if dlg.ShowModal() == wx.ID_OK: 1450 1468 if multiple: 1451 if useCancel: 1452 dlg = G2MultiChoiceDialog( 1453 ParentFrame,title, header, ChoiceList) 1454 else: 1455 dlg = G2MultiChoiceDialog( 1456 ParentFrame,title, header, ChoiceList, 1457 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 1458 else: 1459 if useCancel: 1460 dlg = wx.SingleChoiceDialog( 1461 ParentFrame,title, header, ChoiceList) 1462 else: 1463 dlg = wx.SingleChoiceDialog( 1464 ParentFrame,title, header,ChoiceList, 1465 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) 1466 if size: dlg.SetSize(size) 1467 if dlg.ShowModal() == wx.ID_OK: 1468 if multiple: 1469 dlg.Destroy() 1470 return dlg.GetSelections() 1471 else: 1472 dlg.Destroy() 1473 return dlg.GetSelection() 1469 dlg.Destroy() 1470 return dlg.GetSelections() 1474 1471 else: 1475 1472 dlg.Destroy() 1476 return None 1473 return dlg.GetSelection() 1474 else: 1477 1475 dlg.Destroy() 1476 return None 1477 dlg.Destroy() 1478 1478 1479 1479 ################################################################################ … … 2474 2474 self.DataEdit.Append(id=wxID_HKLFADD, kind=wx.ITEM_NORMAL,text='Add single crystal histograms', 2475 2475 help='Select new single crystal histograms to be used for this phase') 2476 self.DataEdit.Append(id=wxID_DATADELETE, kind=wx.ITEM_NORMAL,text=' Delete histograms',2477 help=' Delete histograms from use for this phase')2476 self.DataEdit.Append(id=wxID_DATADELETE, kind=wx.ITEM_NORMAL,text='Remove histograms', 2477 help='Remove histograms from use for this phase') 2478 2478 self.PostfillDataMenu() 2479 2479 -
trunk/GSASIIphsGUI.py
r1161 r1172 3264 3264 keyList = UseList.keys() 3265 3265 TextList = [] 3266 if G2frame.PatternTree.GetCount(): 3267 item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) 3268 while item: 3269 name = G2frame.PatternTree.GetItemText(item) 3270 if name not in keyList and 'HKLF' in name: 3271 TextList.append(name) 3272 item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) 3273 dlg = wx.MultiChoiceDialog(G2frame, 'Which new data to use?', 'Use data', TextList, wx.CHOICEDLG_STYLE) 3274 try: 3275 if dlg.ShowModal() == wx.ID_OK: 3276 result = dlg.GetSelections() 3277 for i in result: 3278 histoName = TextList[i] 3279 UseList[histoName] = {'Histogram':histoName,'Show':False,'Scale':[1.0,True], 3280 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, 3281 'Extinction':['Lorentzian','None', 3282 {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-10,False],'Es':[1.e-10,False],'Ep':[1.e-10,False]},]} 3283 wx.BeginBusyCursor() 3284 UpdateHKLFdata(histoName) 3285 wx.EndBusyCursor() 3286 data['Histograms'] = UseList 3287 wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 3288 finally: 3289 dlg.Destroy() 3266 if not G2frame.PatternTree.GetCount(): 3267 return 3268 3269 item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) 3270 while item: 3271 name = G2frame.PatternTree.GetItemText(item) 3272 if name not in keyList and 'HKLF' in name: 3273 TextList.append(name) 3274 item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) 3275 dlg = wx.MultiChoiceDialog(G2frame, 'Which new data to use?', 'Use data', TextList, wx.CHOICEDLG_STYLE) 3276 try: 3277 if dlg.ShowModal() == wx.ID_OK: 3278 result = dlg.GetSelections() 3279 else: 3280 return 3281 finally: 3282 dlg.Destroy() 3283 3284 # get the histograms used in other phases 3285 phaseRIdList,usedHistograms = G2frame.GetPhaseInfofromTree() 3286 usedHKLFhists = [] # used single-crystal histograms 3287 for p in usedHistograms: 3288 for h in usedHistograms[p]: 3289 if h.startswith('HKLF ') and h not in usedHKLFhists: 3290 usedHKLFhists.append(h) 3291 # check that selected single crystal histograms are not already in use! 3292 for i in result: 3293 used = [TextList[i] for i in result if TextList[i] in usedHKLFhists] 3294 if used: 3295 msg = 'The following single crystal histogram(s) are already in use' 3296 for i in used: 3297 msg += '\n '+str(i) 3298 msg += '\nAre you sure you want to add them to this phase? ' 3299 msg += 'Associating a single crystal dataset to >1 histogram is usually an error, ' 3300 msg += 'so No is suggested here.' 3301 if G2frame.ErrorDialog('Likely error',msg,G2frame,wtype=wx.YES_NO) != wx.ID_YES: return 3302 3303 wx.BeginBusyCursor() 3304 for i in result: 3305 histoName = TextList[i] 3306 UseList[histoName] = {'Histogram':histoName,'Show':False,'Scale':[1.0,True], 3307 'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}, 3308 'Extinction':['Lorentzian','None', 3309 {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-10,False],'Es':[1.e-10,False],'Ep':[1.e-10,False]},]} 3310 UpdateHKLFdata(histoName) 3311 data['Histograms'] = UseList 3312 wx.CallAfter(G2ddG.UpdateDData,G2frame,DData,data) 3313 wx.EndBusyCursor() 3290 3314 3291 3315 def UpdateHKLFdata(histoName): … … 3300 3324 ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G)) 3301 3325 iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData) 3302 G2frame.PatternTree.SetItemPyData(Id,[refDict,reflData])3326 #G2frame.PatternTree.SetItemPyData(Id,[refDict,reflData]) #removed by BHT -- not needed! 3303 3327 3304 3328 def OnPwdrAdd(event): … … 3326 3350 newList = TextList[1:] 3327 3351 for histoName in newList: 3328 pId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName)3352 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName) 3329 3353 UseList[histoName] = {'Histogram':histoName,'Show':False, 3330 3354 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{}], … … 3335 3359 'HStrain':[NDij*[0.0,],NDij*[False,]], 3336 3360 'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}} 3337 refList = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame, pId,'Reflection Lists'))3361 refList = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists')) 3338 3362 refList[generalData['Name']] = [] 3339 3363 data['Histograms'] = UseList -
trunk/sphinxdocs/source/imports.rst
r1168 r1172 115 115 *support routines* 116 116 _________________________ 117 117 118 Note that the base class (:class:`GSASIIIO.ImportBaseclass`) supplies two routines, 118 119 :meth:`~GSASIIIO.ImportBaseclass.BlockSelector` and … … 147 148 148 149 150 ReInitialize() 151 ~~~~~~~~~~~~~~~~~~~~ 152 153 Import classes are substantiated only once and are used as needed. 154 This means that if something needs to be initialized before the 155 ``Reader()`` will be called to read a new file, it must be coded. The 156 ``ReInitialize()`` method is provided for this and it is always called 157 before the ``ContentsValidator`` method is called. Use care to call 158 the parent class ``ReInitialize()`` method, if this is overridden. 159 160 149 161 ContentsValidator return values 150 162 ________________________________
Note: See TracChangeset
for help on using the changeset viewer.