Changeset 3000 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Aug 11, 2017 5:34:54 PM (4 years ago)
Author:
toby
Message:

make the two frame version the trunk as we hit version 3000

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/GSASIIIO.py

    r2871 r3000  
    1818Also includes base classes for data import routines.
    1919
     20This module needs some work to separate wx from non-wx routines
    2021'''
    2122"""GSASIIIO: functions for IO of data
     
    3233import GSASIIpath
    3334GSASIIpath.SetVersionNumber("$Revision$")
    34 import GSASIIgrid as G2gd
     35import GSASIIdataGUI as G2gd
    3536import GSASIIobj as G2obj
    3637import GSASIIlattice as G2lat
     
    4243import GSASIIstrIO as G2stIO
    4344import GSASIImapvars as G2mv
    44 import GSASIIctrls as G2G
     45import GSASIIctrlGUI as G2G
    4546import os
    4647import os.path as ospath
     
    7879    '''
    7980    return re.sub('\s+', ' ', val).strip()
    80 
    81 def makeInstDict(names,data,codes):
    82     inst = dict(zip(names,zip(data,data,codes)))
    83     for item in inst:
    84         inst[item] = list(inst[item])
    85     return inst
    8681
    8782def FileDlgFixExt(dlg,file):
     
    153148
    154149    '''
    155     Npix,Imagefile,imagetag = G2frame.PatternTree.GetImageLoc(treeId)
     150    Npix,Imagefile,imagetag = G2frame.GPXtree.GetImageLoc(treeId)
    156151    if isinstance(Imagefile,list):
    157152        imagefile,imagetag = Imagefile
     
    169164                print 'found image file '+os.path.join(G2frame.dirname,fil)
    170165                imagefile = os.path.join(G2frame.dirname,fil)
    171                 G2frame.PatternTree.UpdateImageLoc(treeId,imagefile)
     166                G2frame.GPXtree.UpdateImageLoc(treeId,imagefile)
    172167                return Npix,imagefile,imagetag
    173168            pth,enddir = os.path.split(pth)
     
    177172        #      & GPX was  .../A/B/C/refs/fil.gpx but is now .../NEW/TEST/TEST1
    178173        #    will look for .../NEW/TEST/TEST1/imgs/ima.ge, .../NEW/TEST/imgs/ima.ge, .../NEW/imgs/ima.ge and so on
    179         Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls'))
     174        Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root, 'Controls'))
    180175        gpxPath = Controls.get('LastSavedAs','').replace('\\','/').split('/') # blank in older .GPX files
    181176        imgPath = imagefile.replace('\\','/').split('/')
     
    193188                print 'found image file '+os.path.join(pth,fil)
    194189                imagefile = os.path.join(pth,fil)
    195                 G2frame.PatternTree.UpdateImageLoc(treeId,imagefile)
     190                G2frame.GPXtree.UpdateImageLoc(treeId,imagefile)
    196191                return Npix,imagefile,imagetag
    197192            pth,enddir = os.path.split(pth)
     
    208203            if dlg.ShowModal() == wx.ID_OK:
    209204                imagefile = dlg.GetPath()
    210                 G2frame.PatternTree.UpdateImageLoc(treeId,imagefile)
     205                G2frame.GPXtree.UpdateImageLoc(treeId,imagefile)
    211206            else:
    212207                imagefile = False
     
    282277    ImageTag (where there is more than one image in the file), if defined.
    283278    '''
    284     ImgNames = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
     279    ImgNames = G2gd.GetGPXtreeDataNames(G2frame,['IMG ',])
    285280    TreeLbl = 'IMG '+os.path.basename(imagefile)
    286281    ImageTag = Data.get('ImageTag')
     
    291286        imageInfo = imagefile
    292287    TreeName = G2obj.MakeUniqueLabel(TreeLbl,ImgNames)
    293     Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=TreeName)
    294     G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments)
     288    Id = G2frame.GPXtree.AppendItem(parent=G2frame.root,text=TreeName)
     289    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Comments'),Comments)
    295290    Imax = np.amax(Image)
    296291    if G2frame.imageDefault:
     
    339334    Data['setDefault'] = False
    340335    Data['range'] = [(0,Imax),[0,Imax]]
    341     G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Image Controls'),Data)
     336    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Image Controls'),Data)
    342337    Masks = {'Points':[],'Rings':[],'Arcs':[],'Polygons':[],'Frames':[],'Thresholds':[(0,Imax),[0,Imax]]}
    343     G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Masks'),Masks)
    344     G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Stress/Strain'),
     338    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Masks'),Masks)
     339    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Stress/Strain'),
    345340        {'Type':'True','d-zero':[],'Sample phi':0.0,'Sample z':0.0,'Sample load':0.0})
    346     G2frame.PatternTree.SetItemPyData(Id,[Npix,imageInfo])
     341    G2frame.GPXtree.SetItemPyData(Id,[Npix,imageInfo])
    347342    G2frame.PickId = Id
    348343    G2frame.PickIdText = G2frame.GetTreeItemsList(G2frame.PickId)
     
    495490
    496491def SaveMultipleImg(G2frame):
    497     if not G2frame.PatternTree.GetCount():
     492    if not G2frame.GPXtree.GetCount():
    498493        print 'no images!'
    499494        return
    500     choices = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
     495    choices = G2gd.GetGPXtreeDataNames(G2frame,['IMG ',])
    501496    if len(choices) == 1:
    502497        names = choices
     
    510505    if not names: return
    511506    for name in names:
    512         Id = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, name)
    513         Npix,imagefile,imagetag = G2frame.PatternTree.GetImageLoc(Id)
     507        Id = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, name)
     508        Npix,imagefile,imagetag = G2frame.GPXtree.GetImageLoc(Id)
    514509        imroot = os.path.splitext(imagefile)[0]
    515510        if imagetag:
    516511            imroot += '_' + str(imagetag)
    517         Data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Image Controls'))
     512        Data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id, 'Image Controls'))
    518513        print('Writing '+imroot+'.imctrl')
    519514        File = open(imroot+'.imctrl','w')
     
    527522            File.write(key+':'+str(Data[key])+'\n')
    528523        File.close()
    529         mask = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Masks'))
     524        mask = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id, 'Masks'))
    530525        G2imG.CleanupMasks(mask)
    531526        print('Writing '+imroot+'.immask')
     
    551546    file = open(G2frame.GSASprojectfile,'rb')
    552547    if showProvenance: print 'loading from file: ',G2frame.GSASprojectfile
     548    #G2frame.SetTitle("GSAS-II data tree: "+
     549    #                 os.path.split(G2frame.GSASprojectfile)[1])
    553550    G2frame.SetTitle("GSAS-II data tree: "+
    554                      os.path.split(G2frame.GSASprojectfile)[1])
     551                     os.path.split(G2frame.GSASprojectfile)[1],1)
    555552    wx.BeginBusyCursor()
    556553    try:
     
    562559            datum = data[0]
    563560           
    564             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=datum[0])
     561            Id = G2frame.GPXtree.AppendItem(parent=G2frame.root,text=datum[0])
    565562            if datum[0].startswith('PWDR'):               
    566563                if 'ranId' not in datum[1][0]: # patch: add random Id if not present
    567564                    datum[1][0]['ranId'] = ran.randint(0,sys.maxint)
    568                 G2frame.PatternTree.SetItemPyData(Id,datum[1][:3])  #temp. trim off junk (patch?)
     565                G2frame.GPXtree.SetItemPyData(Id,datum[1][:3])  #temp. trim off junk (patch?)
    569566            elif datum[0].startswith('HKLF'):
    570567                if 'ranId' not in datum[1][0]: # patch: add random Id if not present
    571568                    datum[1][0]['ranId'] = ran.randint(0,sys.maxint)
    572                 G2frame.PatternTree.SetItemPyData(Id,datum[1])
     569                G2frame.GPXtree.SetItemPyData(Id,datum[1])
    573570            else:
    574                 G2frame.PatternTree.SetItemPyData(Id,datum[1])             
     571                G2frame.GPXtree.SetItemPyData(Id,datum[1])             
    575572                if datum[0] == 'Controls' and 'LastSavedUsing' in datum[1]:
    576573                    LastSavedUsing = datum[1]['LastSavedUsing']
     
    591588                    continue
    592589#end PDF cleanup
    593                 sub = G2frame.PatternTree.AppendItem(Id,datus[0])
     590                sub = G2frame.GPXtree.AppendItem(Id,datus[0])
    594591#patch
    595592                if datus[0] == 'Instrument Parameters' and len(datus[1]) == 1:
     
    601598                        datus[1][0][item] = list(datus[1][0][item])
    602599#end patch
    603                 G2frame.PatternTree.SetItemPyData(sub,datus[1])
     600                G2frame.GPXtree.SetItemPyData(sub,datus[1])
    604601            if 'PDF ' in datum[0][:4] and oldPDF:
    605                 sub = G2frame.PatternTree.AppendItem(Id,'PDF Peaks')
    606                 G2frame.PatternTree.SetItemPyData(sub,{'Limits':[1.,5.],'Background':[2,[0.,-0.2*np.pi],False],'Peaks':[]})
     602                sub = G2frame.GPXtree.AppendItem(Id,'PDF Peaks')
     603                G2frame.GPXtree.SetItemPyData(sub,{'Limits':[1.,5.],'Background':[2,[0.,-0.2*np.pi],False],'Peaks':[]})
    607604            if datum[0].startswith('IMG'):                   #retrieve image default flag & data if set
    608                 Data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Image Controls'))
     605                Data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Image Controls'))
    609606                if Data['setDefault']:
    610607                    G2frame.imageDefault = Data               
     
    622619    finally:
    623620        wx.EndBusyCursor()
    624         G2frame.Status.SetStatusText('Mouse RB click item to refresh/raise; RB drag/drop to reorder')
     621        G2frame.Status.SetStatusText('Mouse RB drag/drop to reorder',0)
    625622   
    626623def ProjFileSave(G2frame):
    627624    'Save a GSAS-II project file'
    628     if not G2frame.PatternTree.IsEmpty():
     625    if not G2frame.GPXtree.IsEmpty():
    629626        file = open(G2frame.GSASprojectfile,'wb')
    630627        print 'save to file: ',G2frame.GSASprojectfile
     
    632629        # (Controls should always be created at this point)
    633630        try:
    634             Controls = G2frame.PatternTree.GetItemPyData(
    635                 G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls'))
     631            Controls = G2frame.GPXtree.GetItemPyData(
     632                G2gd.GetGPXtreeItemId(G2frame,G2frame.root, 'Controls'))
    636633            Controls['LastSavedAs'] = os.path.abspath(G2frame.GSASprojectfile)
    637634            Controls['LastSavedUsing'] = str(GSASIIpath.GetVersionNumber())
     
    641638        wx.BeginBusyCursor()
    642639        try:
    643             item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)
     640            item, cookie = G2frame.GPXtree.GetFirstChild(G2frame.root)
    644641            while item:
    645642                data = []
    646                 name = G2frame.PatternTree.GetItemText(item)
    647                 data.append([name,G2frame.PatternTree.GetItemPyData(item)])
    648                 item2, cookie2 = G2frame.PatternTree.GetFirstChild(item)
     643                name = G2frame.GPXtree.GetItemText(item)
     644                data.append([name,G2frame.GPXtree.GetItemPyData(item)])
     645                item2, cookie2 = G2frame.GPXtree.GetFirstChild(item)
    649646                while item2:
    650                     name = G2frame.PatternTree.GetItemText(item2)
    651                     data.append([name,G2frame.PatternTree.GetItemPyData(item2)])
    652                     item2, cookie2 = G2frame.PatternTree.GetNextChild(item, cookie2)                           
    653                 item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)                           
     647                    name = G2frame.GPXtree.GetItemText(item2)
     648                    data.append([name,G2frame.GPXtree.GetItemPyData(item2)])
     649                    item2, cookie2 = G2frame.GPXtree.GetNextChild(item, cookie2)                           
     650                item, cookie = G2frame.GPXtree.GetNextChild(G2frame.root, cookie)                           
    654651                cPickle.dump(data,file,1)
    655652            file.close()
     
    666663    X = G2frame.Integrate[2][:-1]
    667664    N = len(X)
    668     Id = G2frame.PatternTree.GetItemParent(PickId)
    669     name = G2frame.PatternTree.GetItemText(Id)
     665    Id = G2frame.GPXtree.GetItemParent(PickId)
     666    name = G2frame.GPXtree.GetItemText(Id)
    670667    name = name.replace('IMG ',data['type']+' ')
    671     Comments = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Comments'))
     668    Comments = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id, 'Comments'))
    672669    if 'PWDR' in name:
    673670        names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
     
    692689    for i,azm in enumerate(azms[:-1]):
    693690        Aname = name+" Azm= %.2f"%((azm+dazm)%360.)
    694         item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)
     691        item, cookie = G2frame.GPXtree.GetFirstChild(G2frame.root)
    695692        # if Overwrite delete any duplicate
    696         if Overwrite and G2gd.GetPatternTreeItemId(G2frame,G2frame.root,Aname):
     693        if Overwrite and G2gd.GetGPXtreeItemId(G2frame,G2frame.root,Aname):
    697694            print('Replacing '+Aname)
    698             item = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,Aname)
    699             G2frame.PatternTree.Delete(item)
     695            item = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,Aname)
     696            G2frame.GPXtree.Delete(item)
    700697        else:
    701698            nOcc = 0
    702699            while item:
    703                 Name = G2frame.PatternTree.GetItemText(item)
     700                Name = G2frame.GPXtree.GetItemText(item)
    704701                if Aname in Name:
    705702                    nOcc += 1
    706                 item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
     703                item, cookie = G2frame.GPXtree.GetNextChild(G2frame.root, cookie)
    707704            if nOcc:
    708705                Aname += '(%d)'%(nOcc)
     
    729726        Ymax = np.max(Y)
    730727        W = np.where(Y>0.,1./Y,1.e-6)                    #probably not true
    731         Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=Aname)
     728        Id = G2frame.GPXtree.AppendItem(parent=G2frame.root,text=Aname)
    732729        G2frame.IntgOutList.append(Id)
    733         G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments)                   
    734         G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Limits'),[tuple(Xminmax),Xminmax])
     730        G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Comments'),Comments)                   
     731        G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Limits'),[tuple(Xminmax),Xminmax])
    735732        if 'PWDR' in Aname:
    736             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Background'),[['chebyschev',1,3,1.0,0.0,0.0],
     733            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Background'),[['chebyschev',1,3,1.0,0.0,0.0],
    737734                {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    738735        inst = [dict(zip(names,zip(parms,parms,codes))),{}]
    739736        for item in inst[0]:
    740737            inst[0][item] = list(inst[0][item])
    741         G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Instrument Parameters'),inst)
     738        G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Instrument Parameters'),inst)
    742739        if 'PWDR' in Aname:
    743             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Sample Parameters'),Sample)
    744             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Peak List'),{'sigDict':{},'peaks':[]})
    745             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Index Peak List'),[[],[]])
    746             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Unit Cells List'),[])
    747             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Reflection Lists'),{})
     740            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Sample Parameters'),Sample)
     741            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Peak List'),{'sigDict':{},'peaks':[]})
     742            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Index Peak List'),[[],[]])
     743            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Unit Cells List'),[])
     744            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Reflection Lists'),{})
    748745        elif 'SASD' in Aname:             
    749             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Substances'),G2pdG.SetDefaultSubstances())
    750             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Sample Parameters'),Sample)
    751             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Models'),G2pdG.SetDefaultSASDModel())
     746            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Substances'),G2pdG.SetDefaultSubstances())
     747            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Sample Parameters'),Sample)
     748            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Models'),G2pdG.SetDefaultSASDModel())
    752749        valuesdict = {
    753750            'wtFactor':1.0,
     
    757754            'qPlot':False,'dPlot':False,'sqrtPlot':False,'Yminmax':[Ymin,Ymax]
    758755            }
    759         G2frame.PatternTree.SetItemPyData(
     756        G2frame.GPXtree.SetItemPyData(
    760757            Id,[valuesdict,
    761758                [np.array(X),np.array(Y),np.array(W),np.zeros(N),np.zeros(N),np.zeros(N)]])
     
    794791    import scipy.interpolate as scintp
    795792    for export in exports:
    796         PickId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, export)
    797         PDFControls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame, PickId,'PDF Controls'))
     793        PickId = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, export)
     794        PDFControls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame, PickId,'PDF Controls'))
    798795        if PDFsaves[0]:     #I(Q)
    799796            iqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.iq')
     
    853850       
    854851        if PDFsaves[4]: #pdfGUI file for G(R)
    855             pId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, 'PWDR'+export[4:])
    856             Inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame, pId,'Instrument Parameters'))[0]
    857             Limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame, pId,'Limits'))
     852            pId = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, 'PWDR'+export[4:])
     853            Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame, pId,'Instrument Parameters'))[0]
     854            Limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame, pId,'Limits'))
    858855            grfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.gr')
    859856            grdata = PDFControls['G(R)'][1]
     
    956953    selections are placed in self.chosen when OK is pressed
    957954
    958     Also see GSASIIctrls
     955    Also see GSASIIctrlGUI
    959956    '''
    960957    def __init__(self,choicelist,headinglist,
     
    12211218
    12221219    This class is subclassed in the various exports/G2export_*.py files. Those files
    1223     are imported in :meth:`GSASII.GSASII._init_Exports` which defines the
     1220    are imported in :meth:`GSASIIdataGUI.GSASII._init_Exports` which defines the
    12241221    appropriate menu items for each one and the .Exporter method is called
    12251222    directly from the menu item.
     
    14631460        consDict = {}
    14641461        Histograms,Phases = self.G2frame.GetUsedHistogramsAndPhasesfromTree()
    1465         if self.G2frame.PatternTree.IsEmpty(): return # nothing to do
    1466         item, cookie = self.G2frame.PatternTree.GetFirstChild(self.G2frame.root)
     1462        if self.G2frame.GPXtree.IsEmpty(): return # nothing to do
     1463        item, cookie = self.G2frame.GPXtree.GetFirstChild(self.G2frame.root)
    14671464        while item:
    1468             name = self.G2frame.PatternTree.GetItemText(item)
     1465            name = self.G2frame.GPXtree.GetItemText(item)
    14691466            if name == 'Rigid bodies':
    1470                  rigidbodyDict = self.G2frame.PatternTree.GetItemPyData(item)
     1467                 rigidbodyDict = self.G2frame.GPXtree.GetItemPyData(item)
    14711468            elif name == 'Covariance':
    1472                  covDict = self.G2frame.PatternTree.GetItemPyData(item)
     1469                 covDict = self.G2frame.GPXtree.GetItemPyData(item)
    14731470            elif name == 'Constraints':
    1474                  consDict = self.G2frame.PatternTree.GetItemPyData(item)
    1475             item, cookie = self.G2frame.PatternTree.GetNextChild(self.G2frame.root, cookie)
     1471                 consDict = self.G2frame.GPXtree.GetItemPyData(item)
     1472            item, cookie = self.G2frame.GPXtree.GetNextChild(self.G2frame.root, cookie)
    14761473        rbVary,rbDict =  G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False)
    14771474        self.parmDict.update(rbDict)
     
    15431540        self.SeqRefdata = None
    15441541        self.SeqRefhist = None
    1545         if self.G2frame.PatternTree.IsEmpty(): return # nothing to do
     1542        if self.G2frame.GPXtree.IsEmpty(): return # nothing to do
    15461543        histType = None       
    15471544        if self.currentExportType == 'phase':
    15481545            # if exporting phases load them here
    1549             sub = G2gd.GetPatternTreeItemId(self.G2frame,self.G2frame.root,'Phases')
     1546            sub = G2gd.GetGPXtreeItemId(self.G2frame,self.G2frame.root,'Phases')
    15501547            if not sub:
    15511548                print 'no phases found'
    15521549                return True
    1553             item, cookie = self.G2frame.PatternTree.GetFirstChild(sub)
     1550            item, cookie = self.G2frame.GPXtree.GetFirstChild(sub)
    15541551            while item:
    1555                 phaseName = self.G2frame.PatternTree.GetItemText(item)
    1556                 self.Phases[phaseName] =  self.G2frame.PatternTree.GetItemPyData(item)
    1557                 item, cookie = self.G2frame.PatternTree.GetNextChild(sub, cookie)
     1552                phaseName = self.G2frame.GPXtree.GetItemText(item)
     1553                self.Phases[phaseName] =  self.G2frame.GPXtree.GetItemPyData(item)
     1554                item, cookie = self.G2frame.GPXtree.GetNextChild(sub, cookie)
    15581555            return
    15591556        elif self.currentExportType == 'single':
     
    15651562
    15661563        if histType: # Loading just one kind of tree entry
    1567             item, cookie = self.G2frame.PatternTree.GetFirstChild(self.G2frame.root)
     1564            item, cookie = self.G2frame.GPXtree.GetFirstChild(self.G2frame.root)
    15681565            while item:
    1569                 name = self.G2frame.PatternTree.GetItemText(item)
     1566                name = self.G2frame.GPXtree.GetItemText(item)
    15701567                if name.startswith(histType):
    15711568                    if self.Histograms.get(name): # there is already an item with this name
     
    15811578                    # element contains refinement results, carry
    15821579                    # that over too now.
    1583                     self.Histograms[name]['Data'] = self.G2frame.PatternTree.GetItemPyData(item)[1]
    1584                     self.Histograms[name][0] = self.G2frame.PatternTree.GetItemPyData(item)[0]
    1585                     item2, cookie2 = self.G2frame.PatternTree.GetFirstChild(item)
     1580                    self.Histograms[name]['Data'] = self.G2frame.GPXtree.GetItemPyData(item)[1]
     1581                    self.Histograms[name][0] = self.G2frame.GPXtree.GetItemPyData(item)[0]
     1582                    item2, cookie2 = self.G2frame.GPXtree.GetFirstChild(item)
    15861583                    while item2:
    1587                         child = self.G2frame.PatternTree.GetItemText(item2)
    1588                         self.Histograms[name][child] = self.G2frame.PatternTree.GetItemPyData(item2)
    1589                         item2, cookie2 = self.G2frame.PatternTree.GetNextChild(item, cookie2)
    1590                 item, cookie = self.G2frame.PatternTree.GetNextChild(self.G2frame.root, cookie)
     1584                        child = self.G2frame.GPXtree.GetItemText(item2)
     1585                        self.Histograms[name][child] = self.G2frame.GPXtree.GetItemPyData(item2)
     1586                        item2, cookie2 = self.G2frame.GPXtree.GetNextChild(item, cookie2)
     1587                item, cookie = self.G2frame.GPXtree.GetNextChild(self.G2frame.root, cookie)
    15911588            # index powder and single crystal histograms by number
    15921589            for hist in self.Histograms:
     
    16061603        # else standard load: using all interlinked phases and histograms
    16071604        self.Histograms,self.Phases = self.G2frame.GetUsedHistogramsAndPhasesfromTree()
    1608         item, cookie = self.G2frame.PatternTree.GetFirstChild(self.G2frame.root)
     1605        item, cookie = self.G2frame.GPXtree.GetFirstChild(self.G2frame.root)
    16091606        while item:
    1610             name = self.G2frame.PatternTree.GetItemText(item)
    1611             item2, cookie2 = self.G2frame.PatternTree.GetFirstChild(item)
     1607            name = self.G2frame.GPXtree.GetItemText(item)
     1608            item2, cookie2 = self.G2frame.GPXtree.GetFirstChild(item)
    16121609            if not item2:
    1613                 self.OverallParms[name] = self.G2frame.PatternTree.GetItemPyData(item)
    1614             item, cookie = self.G2frame.PatternTree.GetNextChild(self.G2frame.root, cookie)
     1610                self.OverallParms[name] = self.G2frame.GPXtree.GetItemPyData(item)
     1611            item, cookie = self.G2frame.GPXtree.GetNextChild(self.G2frame.root, cookie)
    16151612        # index powder and single crystal histograms
    16161613        for hist in self.Histograms:
     
    21232120
    21242121if __name__ == '__main__':
    2125     import GSASII
    2126     application = GSASII.GSASIImain(0)
     2122    import GSASIIdataGUI
     2123    application = GSASIIdataGUI.GSASIImain(0)
    21272124    G2frame = application.main
    21282125    #app = wx.PySimpleApp()
Note: See TracChangeset for help on using the changeset viewer.