Changeset 2216 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
Apr 15, 2016 2:57:57 PM (6 years ago)
Author:
vondreele
Message:

implement import layer from another gpx file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r2212 r2216  
    4444import GSASIIIO as G2IO
    4545import GSASIIstrMain as G2stMn
     46import GSASIIstrIO as G2strIO
    4647import GSASIImath as G2mth
    4748import GSASIIpwd as G2pwd
     
    25872588           
    25882589        def OnImportLayer(event):
    2589             print 'Import atoms for a layer - TBD'
    2590             #from where? DIFFaX files? other phases? NB: transformation issues
    2591             event.Skip()
     2590            dlg = wx.FileDialog(G2frame, 'Choose GSAS-II project file',
     2591                wildcard='GSAS-II project file (*.gpx)|*.gpx',style=wx.OPEN| wx.CHANGE_DIR)
     2592            try:
     2593                if dlg.ShowModal() == wx.ID_OK:
     2594                    GPXFile = dlg.GetPath()
     2595                    phaseNames = G2strIO.GetPhaseNames(GPXFile)
     2596            finally:
     2597                dlg.Destroy()
     2598            dlg = wx.SingleChoiceDialog(G2frame,'Phase to use for layer','Select',phaseNames)
     2599            if dlg.ShowModal() == wx.ID_OK:
     2600                sel = dlg.GetSelection()
     2601                PhaseName = phaseNames[sel]
     2602            else:
     2603                return
     2604            Phase = G2strIO.GetAllPhaseData(GPXFile,PhaseName)
     2605            #need cell compatibility check here
     2606            Layer = {'Name':Phase['General']['Name'],'SameAs':'','Symm':'None'}
     2607            cx,ct,cs,cia = Phase['General']['AtomPtrs']
     2608            atoms = Phase['Atoms']
     2609            Atoms = []
     2610            for atom in atoms:
     2611                x,y,z,f = atom[cx:cx+4]
     2612                u = atom[cia+1]
     2613                if not u: u = 0.01
     2614                Atoms.append([atom[ct-1],atom[ct],x,y,z,f,u])
     2615                if atom[ct] not in data['Layers']['AtInfo']:
     2616                    data['Layers']['AtInfo'][atom[ct]] = G2elem.GetAtomInfo(atom[ct])
     2617            Layer['Atoms'] = Atoms
     2618            data['Layers']['Layers'].append(Layer)
     2619            Trans = data['Layers']['Transitions']
     2620            if len(Trans):
     2621                Trans.append([[0.,0.,0.,0.,'',False] for trans in Trans])
     2622                for trans in Trans:
     2623                    trans.append([0.,0.,0.,0.,'',False])
     2624            else:
     2625                Trans = [[[1.,0.,0.,0.,'',False],],]
     2626            data['Layers']['Transitions'] = Trans
     2627            UpdateLayerData()
    25922628           
    25932629        def LayerSizer(il,Layer):
Note: See TracChangeset for help on using the changeset viewer.