Changeset 2216


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

implement import layer from another gpx file

Location:
trunk
Files:
2 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):
  • trunk/GSASIIplot.py

    r2212 r2216  
    6767Gkrho = unichr(0x03C1)
    6868nxs = np.newaxis
     69#    GSASIIpath.IPyBreak()
    6970   
    7071class _tabPlotWin(wx.Panel):   
     
    60466047            newXYZ = np.concatenate((newXYZ,XYZ))
    60476048        XYZ = newXYZ
    6048         na = int(8./cell[0])
    6049         nb = int(8./cell[1])
    6050         if any([na,nb]):
    6051             nunit = [na,nb,0]
    6052             indA = range(-na,na)
    6053             indB = range(-nb,nb)
    6054             Units = np.array([[h,k,0] for h in indA for k in indB])
    6055             newXYZ = np.zeros((0,3))
    6056             for unit in Units:
    6057                 newXYZ = np.concatenate((newXYZ,unit+XYZ))
    6058             if len(Units):
    6059                 AtNames *= len(Units)
    6060                 AtTypes *= len(Units)
    6061             XYZ = newXYZ
     6049        na = max(int(8./cell[0]),1)
     6050        nb = max(int(8./cell[1]),1)
     6051        nunit = [na,nb,0]
     6052        indA = range(-na,na)
     6053        indB = range(-nb,nb)
     6054        Units = np.array([[h,k,0] for h in indA for k in indB])
     6055        newXYZ = np.zeros((0,3))
     6056        for unit in Units:
     6057            newXYZ = np.concatenate((newXYZ,unit+XYZ))
     6058        if len(Units):
     6059            AtNames *= len(Units)
     6060            AtTypes *= len(Units)
     6061        XYZ = newXYZ
     6062#        GSASIIpath.IPyBreak()
    60626063       
    60636064        Bonds = FindBonds(AtTypes,XYZ)
Note: See TracChangeset for help on using the changeset viewer.