Changeset 2165


Ignore:
Timestamp:
Mar 8, 2016 4:08:27 PM (6 years ago)
Author:
vondreele
Message:

stacking fault plots now OK
add new menu item - 'simulate'

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2161 r2165  
    8787] = [wx.NewId() for item in range(2)]
    8888
    89 [ wxID_LOADDIFFAX,
    90 ] = [wx.NewId() for item in range(1)]
     89[ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,
     90] = [wx.NewId() for item in range(2)]
    9191
    9292[ wxID_PAWLEYLOAD, wxID_PAWLEYESTIMATE, wxID_PAWLEYUPDATE,
     
    16391639        self.LayerDataEdit.Append(id=wxID_LOADDIFFAX, kind=wx.ITEM_NORMAL,text='Load from DIFFaX file',
    16401640            help='Load layer info from DIFFaX file')
     1641        self.LayerDataEdit.Append(id=wxID_LAYERSIMULATE, kind=wx.ITEM_NORMAL,text='Simulate PWDR pattern',
     1642            help='Simulate powder pattern from layer stacking')
    16411643        self.PostfillDataMenu()
    16421644                 
  • trunk/GSASIIphsGUI.py

    r2163 r2165  
    411411                    elif generalData['Type'] == 'faulted':
    412412                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadDIFFaX, id=G2gd.wxID_LOADDIFFAX)
     413                        G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
    413414                        if 'Wave Data' in pages:
    414415                            pass
     
    23972398        transTypes = [wg.GRID_VALUE_FLOAT+':10,3',]+3*[wg.GRID_VALUE_FLOAT+':10,5',]+ \
    23982399            [wg.GRID_VALUE_CHOICE+": ,P,PX,PY,PZ,PXY,PXZ,PYZ,PXYZ,X,Y,Z,XY,XZ,YZ,XYZ",wg.GRID_VALUE_BOOL,]
    2399         plotDefaults = {'oldxy':[0.,0.],'Quaternion':[0.,0.,0.,1.],'cameraPos':30.,'viewDir':[0,0,1],}
     2400        plotDefaults = {'oldxy':[0.,0.],'Quaternion':[0.,0.,0.,1.],'cameraPos':30.,'viewDir':[0,0,1],
     2401            'viewPoint':[[0.,0.,0.],[]],}
    24002402
    24012403        def OnLaue(event):
     
    28522854            dlg.Destroy()
    28532855        wx.CallAfter(UpdateLayerData)
     2856       
     2857    def OnSimulate(event):
     2858        print 'simulate PWDR pattern'
    28542859       
    28552860################################################################################
     
    69726977            FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.WavesData)
    69736978            G2frame.dataFrame.Bind(wx.EVT_MENU, OnWaveVary, id=G2gd.wxID_WAVEVARY)
    6974         # Stacking faults
     6979        # Stacking faults wxID_LAYERSIMULATE
    69756980        if data['General']['Type'] == 'faulted':
    69766981            FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.LayerData)
    69776982            G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadDIFFaX, id=G2gd.wxID_LOADDIFFAX)
     6983            G2frame.dataFrame.Bind(wx.EVT_MENU, OnSimulate, id=G2gd.wxID_LAYERSIMULATE)
    69786984        # Draw Options
    69796985        FillSelectPageMenu(TabSelectionIdDict, G2frame.dataFrame.DataDrawOptions)
  • trunk/GSASIIplot.py

    r2163 r2165  
    6666GkDelta = unichr(0x0394)
    6767Gkrho = unichr(0x03C1)
     68nxs = np.newaxis
    6869   
    6970class G2PlotMpl(wx.Panel):   
     
    58035804    AtInfo = Layers['AtInfo']
    58045805    Names = [layer['Name'] for layer in Layers['Layers']]
    5805     atNames = []
    5806     atTypes = []
     5806    AtNames = []
     5807    AtTypes = []
    58075808    newXYZ = np.zeros((0,3))
    58085809    TX = np.zeros(3)
    5809     for il,layer in enumerate(laySeq):       
     5810    for il in range(len(laySeq)):
     5811        layer = laySeq[il]     
    58105812        if Layers['Layers'][layer]['SameAs']:
    5811             layer = Names.index(Layers['Layers'][layer]['SameAs'])
    5812         atNames += [atom[0] for atom in Layers['Layers'][layer]['Atoms']]
    5813         atTypes += [atom[1] for atom in Layers['Layers'][layer]['Atoms']]
    5814         XYZ = np.array([atom[3:6] for atom in Layers['Layers'][layer]['Atoms']])+TX
     5813            alayer = Names.index(Layers['Layers'][layer]['SameAs'])
     5814        atNames = [atom[0] for atom in Layers['Layers'][layer]['Atoms']]
     5815        atTypes = [atom[1] for atom in Layers['Layers'][layer]['Atoms']]
     5816        XYZ = np.array([atom[3:6] for atom in Layers['Layers'][layer]['Atoms']])
    58155817        if '-1' in Layers['Layers'][layer]['Symm']:
    58165818            atNames += atNames
     
    58185820            XYZ = np.concatenate((XYZ,-XYZ))
    58195821        if il:
    5820             TX = np.array(Trans[laySeq[il-1]][layer][1:4])
    5821             XYZ += TX
     5822            TX += np.array(Trans[laySeq[il-1]][layer][1:4])
     5823        XYZ += TX
     5824        XYZT = XYZ.T
     5825        XYZT[0] = XYZT[0]%1.
     5826        XYZT[1] = XYZT[1]%1.
     5827        XYZ = XYZT.T
     5828        AtNames += atNames
     5829        AtTypes += atTypes
    58225830        newXYZ = np.concatenate((newXYZ,XYZ))
    58235831    XYZ = newXYZ
     
    58285836    indB = range(-nb,nb)
    58295837    Units = np.array([[h,k,0] for h in indA for k in indB])
    5830     newXYZ = np.copy(XYZ)
     5838    newXYZ = np.zeros((0,3))
    58315839    for unit in Units:
    5832         if np.any(unit):
    5833             newXYZ = np.concatenate((newXYZ,unit+XYZ))
     5840        newXYZ = np.concatenate((newXYZ,unit+XYZ))
    58345841    if len(Units):
    5835         atNames *= len(Units)
    5836         atTypes *= len(Units)
     5842        AtNames *= len(Units)
     5843        AtTypes *= len(Units)
    58375844    XYZ = newXYZ
    5838     Bonds = FindBonds(atTypes,XYZ)
     5845    Bonds = FindBonds(AtTypes,XYZ)
    58395846           
    58405847    def OnMouseDown(event):
     
    58505857                Q = defaults['Quaternion']
    58515858                G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1)
     5859            elif event.RightIsDown():
     5860                SetTranslation(newxy)
     5861                Tx,Ty,Tz = defaults['viewPoint'][0]
    58525862            elif event.MiddleIsDown():
    58535863                SetRotationZ(newxy)
     
    58755885        glLightfv(GL_LIGHT0,GL_AMBIENT,[1,1,1,.8])
    58765886        glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1])
     5887       
     5888    def SetTranslation(newxy):
     5889#first get translation vector in screen coords.       
     5890        oldxy = defaults['oldxy']
     5891        if not len(oldxy): oldxy = list(newxy)
     5892        dxy = newxy-oldxy
     5893        defaults['oldxy'] = list(newxy)
     5894        V = np.array([-dxy[0],dxy[1],0.])
     5895#then transform to rotated crystal coordinates & apply to view point       
     5896        Q = defaults['Quaternion']
     5897        V = np.inner(Bmat,G2mth.prodQVQ(G2mth.invQ(Q),V))
     5898        Tx,Ty,Tz = defaults['viewPoint'][0]
     5899        Tx += V[0]*0.1
     5900        Ty += V[1]*0.1
     5901        Tz += V[2]*0.1
     5902        defaults['viewPoint'][0] =  np.array([Tx,Ty,Tz])
    58775903       
    58785904    def SetRotation(newxy):
     
    60076033        for iat,atom in enumerate(XYZ):
    60086034            x,y,z = atom
    6009             CL = AtInfo[atTypes[iat]]['Color']
     6035            CL = AtInfo[AtTypes[iat]]['Color']
    60106036            color = np.array(CL)/255.
    60116037            RenderSphere(x,y,z,radius,color)
    60126038            RenderBonds(x,y,z,Bonds[iat],0.05,color)
    6013             RenderLabel(x,y,z,'  '+atNames[iat],matRot)
     6039            RenderLabel(x,y,z,'  '+AtNames[iat],matRot)
    60146040        if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
    60156041        Page.canvas.SwapBuffers()
Note: See TracChangeset for help on using the changeset viewer.