Changeset 1173


Ignore:
Timestamp:
Dec 17, 2013 5:21:46 PM (8 years ago)
Author:
toby
Message:

ask to link phases to histograms after dummy hist

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1172 r1173  
    704704                dlg.Destroy()
    705705            HistName = 'HKLF '+HistName
    706             # make new phase names unique
     706            # make new histogram names unique
    707707            HistName = G2obj.MakeUniqueLabel(HistName,HKLFlist)
    708708            print 'Read structure factor table '+str(HistName)+' from file '+str(self.lastimport)
     
    736736        for Name in newHistList:
    737737            header += '\n  '+str(Name)
    738 
    739         notOK = True
    740738        result = G2gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)
    741739        if not result: return
     
    11751173            HistName = rd.idstring
    11761174            HistName = 'PWDR '+HistName
    1177             # make new phase names unique
     1175            # make new histogram names unique
    11781176            HistName = G2obj.MakeUniqueLabel(HistName,PWDRlist)
    11791177            print 'Read powder data '+str(HistName)+ \
     
    12531251            header += '\n  '+str(Name)
    12541252
    1255         notOK = True
    12561253        result = G2gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)
    12571254        if not result: return
     
    12951292        Reads an instrument parameter file and then gets input from the user
    12961293        '''
     1294        # get a list of existing histograms
     1295        PWDRlist = []
     1296        if self.PatternTree.GetCount():
     1297            item, cookie = self.PatternTree.GetFirstChild(self.root)
     1298            while item:
     1299                name = self.PatternTree.GetItemText(item)
     1300                if name.startswith('PWDR ') and name not in PWDRlist:
     1301                    PWDRlist.append(name)
     1302                item, cookie = self.PatternTree.GetNextChild(self.root, cookie)
     1303        # Initialize a base class reader
    12971304        rd = G2IO.ImportPowderData(
    12981305            extensionlist=tuple(),
     
    13091316        lastdatafile = ''
    13101317        self.zipfile = None
    1311         # get instrument parameters for
     1318        # get instrument parameters for it
    13121319        Iparm1,Iparm2 = self.GetPowderIparm(rd, Iparm, lastIparmfile, lastdatafile)
    13131320        if 'T' in Iparm1['Type'][0]:
     
    13661373        Tmax = rd.powderdata[0][-1]
    13671374        # data are read, now store them in the tree
    1368         Id = self.PatternTree.AppendItem(parent=self.root,
    1369                                          text='PWDR '+inp[0])
     1375        HistName = inp[0]
     1376        HistName = 'PWDR '+HistName
     1377        HistName = G2obj.MakeUniqueLabel(HistName,PWDRlist)  # make new histogram names unique
     1378        Id = self.PatternTree.AppendItem(parent=self.root,text=HistName)
    13701379        valuesdict = {
    13711380            'wtFactor':1.0,
     
    14051414        self.PatternTree.Expand(Id)
    14061415        self.PatternTree.SelectItem(Id)
    1407         print('Added simulation powder data '+str(rd.idstring)+
     1416        print('Added simulation powder data '+str(HistName)+
    14081417              ' with parameters from '+str(rd.instmsg))
     1418
     1419        # make a list of phase names
     1420        phaseRIdList,usedHistograms = self.GetPhaseInfofromTree()
     1421        phaseNameList = usedHistograms.keys() # phase names in use
     1422        if not phaseNameList: return # no phases yet, nothing to do
     1423        header = 'Select phase(s) to add the new\npowder simulation (dummy) dataset to:'
     1424        result = G2gd.ItemSelector(phaseNameList,self,header,header='Add to phase(s)',multiple=True)
     1425        if not result: return
     1426        # connect new phases to histograms
     1427        sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases')
     1428        if not sub:
     1429            raise Exception('ERROR -- why are there no phases here?')
     1430        item, cookie = self.PatternTree.GetFirstChild(sub)
     1431        iph = -1
     1432        while item: # loop over (new) phases
     1433            iph += 1
     1434            phaseName = self.PatternTree.GetItemText(item)
     1435            data = self.PatternTree.GetItemPyData(item)
     1436            item, cookie = self.PatternTree.GetNextChild(sub, cookie)
     1437            if iph not in result: continue
     1438            generalData = data['General']
     1439            SGData = generalData['SGData']
     1440            UseList = data['Histograms']
     1441            NShkl = len(G2spc.MustrainNames(SGData))
     1442            NDij = len(G2spc.HStrainNames(SGData))
     1443            UseList[HistName] = {
     1444                'Histogram':HistName,'Show':False,
     1445                'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{}],
     1446                'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1],
     1447                        [1.,1.,1.,0.,0.,0.],6*[False,]],
     1448                'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1],
     1449                            NShkl*[0.01,],NShkl*[False,]],
     1450                'HStrain':[NDij*[0.0,],NDij*[False,]],                         
     1451                'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]}}
     1452            Id = G2gd.GetPatternTreeItemId(self,self.root,HistName)
     1453            refList = self.PatternTree.GetItemPyData(
     1454                G2gd.GetPatternTreeItemId(self,Id,'Reflection Lists'))
     1455            refList[generalData['Name']] = []
    14091456        return # success
    14101457
Note: See TracChangeset for help on using the changeset viewer.