Changeset 2075 for trunk


Ignore:
Timestamp:
Dec 1, 2015 12:23:23 PM (10 years ago)
Author:
vondreele
Message:

explicit plot destroy when GSAS2 closes
work on scrolling on phase data tabs - scroll back to place last used
fix(?) Block/ZigZag? derivatives
eliminate Refine & max index buttons for mod vector for single crystal data

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASII.py

    r2071 r2075  
    31153115    def OnFileExit(self, event):
    31163116        '''Called in response to the File/Quit menu button'''
     3117        if self.G2plotNB:
     3118            self.G2plotNB.Destroy()
    31173119        if self.dataFrame:
    31183120            self.dataFrame.Clear()
  • TabularUnified trunk/GSASIIddataGUI.py

    r1922 r2075  
    4343##### DData routines
    4444################################################################################       
    45 def UpdateDData(G2frame,DData,data,hist=''):
     45def UpdateDData(G2frame,DData,data,hist='',Scroll=0):
    4646    '''Display the Diffraction Data associated with a phase
    4747    (items where there is a value for each histogram and phase)
    4848
    4949    :param wx.frame G2frame: the main GSAS-II frame object
    50 
    5150    :param wx.ScrolledWindow DData: notebook page to be used for the display
    52 
    5351    :param dict data: all the information on the phase in a dictionary
     52    :param str hist: histogram name
     53    :param int Scroll: previous scroll position
    5454
    5555    '''
     
    171171        UseList[G2frame.hist]['Size'][0] = Obj.GetValue()
    172172        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
    173         wx.CallLater(100,RepaintHistogramInfo)
     173        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    174174       
    175175    def OnSizeRef(event):
     
    208208        UseList[G2frame.hist]['Mustrain'][0] = Obj.GetValue()
    209209        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
    210         wx.CallLater(100,RepaintHistogramInfo)
     210        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    211211       
    212212    def OnStrainRef(event):
     
    271271                UseList[item]['Mustrain'][4][i] = vals[i]
    272272        G2plt.PlotSizeStrainPO(G2frame,data,item)
    273         wx.CallLater(100,RepaintHistogramInfo)
     273        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    274274           
    275275    def OnHstrainRef(event):
     
    317317        UseList[G2frame.hist]['Pref.Ori.'][4] = Order
    318318        UseList[G2frame.hist]['Pref.Ori.'][5] = SetPOCoef(Order,G2frame.hist)
    319         wx.CallLater(100,RepaintHistogramInfo)
     319        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    320320
    321321    def OnPOType(event):
     
    325325        else:
    326326            UseList[G2frame.hist]['Pref.Ori.'][0] = 'SH'
    327         wx.CallLater(100,RepaintHistogramInfo)
     327        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    328328
    329329    def OnPORef(event):
     
    562562            finally:
    563563                dlg.Destroy()
    564             wx.CallLater(100,RepaintHistogramInfo)
     564            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    565565           
    566566        def OnshToler(event):
     
    594594            item = Indx[Obj.GetId()]
    595595            UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue()
    596             wx.CallLater(100,RepaintHistogramInfo)
     596            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    597597               
    598598        def OnTbarVal(event):
     
    787787                UseList[G2frame.hist]['Twins'].append([False,0.0])
    788788            addtwin.SetValue(False)
    789             wx.CallLater(100,RepaintHistogramInfo)
     789            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    790790           
    791791        def OnMat(event):
     
    815815                    sumTw += twin[1]
    816816            UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw
    817             wx.CallLater(100,RepaintHistogramInfo)
     817            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    818818           
    819819        def OnTwinRef(event):
     
    840840            if len(UseList[G2frame.hist]['Twins']) == 1:
    841841                UseList[G2frame.hist]['Twins'][0][1][1] = False
    842             wx.CallLater(100,RepaintHistogramInfo)           
     842            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))           
    843843           
    844844        nTwin = len(UseList[G2frame.hist]['Twins'])
     
    914914        wx.CallLater(100,RepaintHistogramInfo)
    915915       
    916     def RepaintHistogramInfo():
     916    def RepaintHistogramInfo(Scroll=0):
    917917        G2frame.bottomSizer.DeleteWindows()
    918918        Indx.clear()
     
    922922        G2frame.dataFrame.Refresh()
    923923        DData.SetVirtualSize(mainSizer.GetMinSize())
     924        DData.Scroll(0,Scroll)
    924925        G2frame.dataFrame.SendSizeEvent()
    925926       
     
    944945                    UseList[item]['Size'][4][i+3] = 0.0
    945946            G2plt.PlotSizeStrainPO(G2frame,data,item)
    946             wx.CallLater(100,RepaintHistogramInfo)
     947            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    947948           
    948949        def OnSizeAxis(event):           
     
    11041105                      0,WACV|wx.TOP,10)
    11051106       
    1106     G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer)
     1107    G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer,Scroll)
  • TabularUnified trunk/GSASIImath.py

    r2074 r2075  
    936936    Mast: array orthogonalization matrix for Uij
    937937    '''
    938     glTau,glWt = pwd.pygauleg(0.,1.,32)         #get Gauss-Legendre intervals & weights
     938    ngl = 32
     939    glTau,glWt = pwd.pygauleg(0.,1.,ngl)         #get Gauss-Legendre intervals & weights
    939940    Ax = np.array(XSSdata[:3]).T   #atoms x waves x sin pos mods
    940941    Bx = np.array(XSSdata[3:]).T   #...cos pos mods
     
    945946    nWaves = [Af.shape[1],Ax.shape[1],Au.shape[1]]
    946947    if nWaves[0]:
    947         tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau  #Fwaves x 32
    948         FmodA = Af[:,:,nxs]*np.sin(twopi*tauF[nxs,:,:])   #atoms X Fwaves X 32
     948        tauF = np.arange(1.,nWaves[0]+1)[:,nxs]*glTau  #Fwaves x ngl
     949        FmodA = Af[:,:,nxs]*np.sin(twopi*tauF[nxs,:,:])   #atoms X Fwaves X ngl
    949950        FmodB = Bf[:,:,nxs]*np.cos(twopi*tauF[nxs,:,:])
    950         Fmod = np.sum(FmodA+FmodB,axis=1)             #atoms X 32; sum waves
     951        Fmod = np.sum(1.0+FmodA+FmodB,axis=1)             #atoms X ngl; sum waves
    951952    else:
    952953        Fmod = 1.0           
    953     XmodZ = np.zeros((Ax.shape[0],Ax.shape[1],3,32))
    954     XmodA = np.zeros((Ax.shape[0],Ax.shape[1],3,32))
    955     XmodB = np.zeros((Ax.shape[0],Ax.shape[1],3,32))
     954    XmodZ = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl))
     955    XmodA = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl))
     956    XmodB = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl))
    956957    for iatm in range(Ax.shape[0]):
    957958        nx = 0
     
    966967            XYZmax = np.array([Ax[iatm][0][2],Bx[iatm][0][0],Bx[iatm][0][1]])
    967968            XmodZ[iatm][0] += posBlock(glTau,Tmm,XYZmax).T
    968         tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Xwaves x 32
     969        tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Xwaves x ngl
    969970        if nx:   
    970             XmodA[iatm][:-nx] = Ax[iatm,nx:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X 32
     971            XmodA[iatm][:-nx] = Ax[iatm,nx:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X ngl
    971972            XmodB[iatm][:-nx] = Bx[iatm,nx:,:,nxs]*np.cos(twopi*tauX[nxs,:,nxs,:]) #ditto
    972973        else:
    973             XmodA[iatm] = Ax[iatm,:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X 32
     974            XmodA[iatm] = Ax[iatm,:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X ngl
    974975            XmodB[iatm] = Bx[iatm,:,:,nxs]*np.cos(twopi*tauX[nxs,:,nxs,:]) #ditto
    975     Xmod = np.sum(XmodA+XmodB+XmodZ,axis=1)                #atoms X 3 X 32; sum waves
     976    Xmod = np.sum(XmodA+XmodB+XmodZ,axis=1)                #atoms X 3 X ngl; sum waves
    976977    Xmod = np.swapaxes(Xmod,1,2)
    977978    if nWaves[2]:
    978         tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau     #Uwaves x 32
    979         UmodA = Au[:,:,:,:,nxs]*np.sin(twopi*tauU[nxs,:,nxs,nxs,:]) #atoms x waves x 3x3 x 32
     979        tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau     #Uwaves x ngl
     980        UmodA = Au[:,:,:,:,nxs]*np.sin(twopi*tauU[nxs,:,nxs,nxs,:]) #atoms x waves x 3x3 x ngl
    980981        UmodB = Bu[:,:,:,:,nxs]*np.cos(twopi*tauU[nxs,:,nxs,nxs,:]) #ditto
    981         Umod = np.swapaxes(np.sum(UmodA+UmodB,axis=1),1,3)      #atoms x 3x3 x 32; sum waves
     982        Umod = np.swapaxes(np.sum(UmodA+UmodB,axis=1),1,3)      #atoms x 3x3 x ngl; sum waves
    982983    else:
    983984        Umod = 1.0
    984985#    GSASIIpath.IPyBreak()
    985     return nWaves,Fmod,Xmod,Umod,glTau,glWt
     986    return ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt
    986987       
    987988def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
     
    990991    HP: array nRefBlk x ops X hklt proj to hkl
    991992    Fmod: array 2 x atoms x waves    (sin,cos terms)
    992     Xmod: array atoms X 3 X 32
    993     Umod: array atoms x 3x3 x 32
     993    Xmod: array atoms X 3 X ngl
     994    Umod: array atoms x 3x3 x ngl
    994995    glTau,glWt: arrays Gauss-Lorentzian pos & wts
    995996    '''
    996997   
    997     nxs = np.newaxis   
     998    nxs = np.newaxis
    998999    if nWaves[2]:
    9991000        if len(HP.shape) > 2:
    1000             HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x 32 add Overhauser corr.?
     1001            HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.?
    10011002        else:
    1002             HbH = np.exp(-np.sum(HP[:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x 32 add Overhauser corr.?
     1003            HbH = np.exp(-np.sum(HP[:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.?
    10031004    else:
    10041005        HbH = 1.0
    1005     HdotX = np.inner(HP,Xmod)                   #refBlk x ops x atoms X 32
     1006    HdotX = np.inner(HP,Xmod)                   #refBlk x ops x atoms X ngl
    10061007    if len(H.shape) > 2:
    1007         D = H[:,:,3:]*glTau[nxs,nxs,:]              #m*e*tau; refBlk x ops X 32
     1008        D = H[:,:,3:]*glTau[nxs,nxs,:]              #m*e*tau; refBlk x ops X ngl
    10081009        HdotXD = twopi*(HdotX+D[:,:,nxs,:])
    10091010    else:
    1010         D = H[:,3:]*glTau[nxs,:]              #m*e*tau; refBlk x ops X 32
     1011        D = H[:,3:]*glTau[nxs,:]              #m*e*tau; refBlk x ops X ngl
    10111012        HdotXD = twopi*(HdotX+D[:,nxs,:])
    10121013    cosHA = np.sum(Fmod*HbH*np.cos(HdotXD)*glWt,axis=-1)       #real part; refBlk X ops x atoms; sum for G-L integration
     
    10141015    return np.array([cosHA,sinHA])             # 2 x refBlk x SGops x atoms
    10151016   
    1016 def makeWavesDerv(waveTypes,FSSdata,XSSdata,USSdata,Mast):
     1017def makeWavesDerv(ngl,waveTypes,FSSdata,XSSdata,USSdata,Mast):
    10171018    '''
    10181019    FSSdata: array 2 x atoms x waves    (sin,cos terms)
     
    10211022    Mast: array orthogonalization matrix for Uij
    10221023    '''
    1023     glTau,glWt = pwd.pygauleg(0.,1.,32)         #get Gauss-Legendre intervals & weights
    1024     dT = 1/32.
     1024    glTau,glWt = pwd.pygauleg(0.,1.,ngl)         #get Gauss-Legendre intervals & weights
     1025    dT = 1./ngl
    10251026    dX = 0.0001
    10261027    waveShapes = [FSSdata.T.shape,XSSdata.T.shape,USSdata.T.shape]
     
    10321033    Bu = Mast*np.array(G2lat.U6toUij(USSdata[6:])).T   #...cos Uij mods
    10331034    nWaves = [Af.shape[1],Ax.shape[1],Au.shape[1]]
    1034     nx = 0
    1035     StauX = np.zeros((Ax.shape[0],Ax.shape[1],3,32))    #atoms x waves x 3 x 32
    1036     CtauX = np.zeros((Ax.shape[0],Ax.shape[1],3,32))
    1037     ZtauXx = np.zeros((Ax.shape[0],3,32))               #atoms x XYZmax x 32
    1038     ZtauXt = np.zeros((Ax.shape[0],2,32))               #atoms x Tminmax x 32
     1035    StauX = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl))    #atoms x waves x 3 x ngl
     1036    CtauX = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl))
     1037    ZtauXt = np.zeros((Ax.shape[0],2,ngl))               #atoms x Tminmax x ngl
     1038    ZtauXx = np.zeros((Ax.shape[0],3,ngl))               #atoms x XYZmax x ngl
    10391039    for iatm in range(Ax.shape[0]):
    10401040        nx = 0
     
    10751075                XYZmax[i] += dX
    10761076                ZtauXx[iatm][i] = (Zp-Zm)[i]/(2.*dX)
    1077         tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Xwaves x 32
     1077        tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Xwaves x ngl
    10781078        if nx:   
    1079             StauX[iatm][:-nx] = np.ones_like(Ax)[iatm,nx:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:]   #atoms X waves X 3(xyz) X 32
     1079            StauX[iatm][:-nx] = np.ones_like(Ax)[iatm,nx:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:]   #atoms X waves X 3(xyz) X ngl
    10801080            CtauX[iatm][:-nx] = np.ones_like(Bx)[iatm,nx:,:,nxs]*np.cos(twopi*tauX)[nxs,:,nxs,:]   #ditto
    10811081        else:
    1082             StauX[iatm] = np.ones_like(Ax)[iatm,:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:]   #atoms X waves X 3(xyz) X 32
     1082            StauX[iatm] = np.ones_like(Ax)[iatm,:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:]   #atoms X waves X 3(xyz) X ngl
    10831083            CtauX[iatm] = np.ones_like(Bx)[iatm,:,:,nxs]*np.cos(twopi*tauX)[nxs,:,nxs,:]   #ditto
    10841084#    GSASIIpath.IPyBreak()
    10851085    if nWaves[0]:
    1086         tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau  #Fwaves x 32
     1086        tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau  #Fwaves x ngl
    10871087        StauF = np.ones_like(Af)[:,:,nxs]*np.sin(twopi*tauF)[nxs,:,:] #also dFmod/dAf
    10881088        CtauF = np.ones_like(Bf)[:,:,nxs]*np.cos(twopi*tauF)[nxs,:,:] #also dFmod/dBf
     
    10911091        CtauF = 1.0
    10921092    if nWaves[2]:
    1093         tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau     #Uwaves x 32
     1093        tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau     #Uwaves x ngl
    10941094        StauU = np.ones_like(Au)[:,:,:,:,nxs]*np.sin(twopi*tauU)[nxs,:,nxs,nxs,:]   #also dUmodA/dAu
    10951095        CtauU = np.ones_like(Bu)[:,:,:,:,nxs]*np.cos(twopi*tauU)[nxs,:,nxs,nxs,:]   #also dUmodB/dBu
    1096         UmodA = Au[:,:,:,:,nxs]*StauU #atoms x waves x 3x3 x 32
     1096        UmodA = Au[:,:,:,:,nxs]*StauU #atoms x waves x 3x3 x ngl
    10971097        UmodB = Bu[:,:,:,:,nxs]*CtauU #ditto
    1098 #derivs need to be ops x atoms x waves x 6uij; ops x atoms x waves x 32 x 6uij before sum
     1098#derivs need to be ops x atoms x waves x 6uij; ops x atoms x waves x ngl x 6uij before sum
    10991099        StauU = np.rollaxis(np.rollaxis(np.swapaxes(StauU,2,4),-1),-1)
    11001100        CtauU = np.rollaxis(np.rollaxis(np.swapaxes(CtauU,2,4),-1),-1)
     
    11231123    dGdMuS = np.zeros(Mu)
    11241124   
    1125     D = twopi*H[:,3][:,nxs]*glTau[nxs,:]              #m*e*tau; ops X 32
    1126     HdotX = twopi*np.inner(HP,Xmod)        #ops x atoms X 32
     1125    D = twopi*H[:,3][:,nxs]*glTau[nxs,:]              #m*e*tau; ops X ngl
     1126    HdotX = twopi*np.inner(HP,Xmod)        #ops x atoms X ngl
    11271127    HdotXD = HdotX+D[:,nxs,:]
    11281128    if nWaves[2]:
    1129         Umod = np.swapaxes((UmodAB),2,4)      #atoms x waves x 32 x 3x3 (symmetric so I can do this!)
    1130         HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1)    #ops x atoms x waves x 32
    1131         HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1)    #ops x atoms x waves x 32
    1132         HbH = np.exp(-np.sum(HuH,axis=-2)) # ops x atoms x 32; sum waves - OK vs Modulation version
    1133         part1 = -np.exp(-HuH)*Fmod    #ops x atoms x waves x 32
    1134         dUdAu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[0]),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x 32 x 6sinUij
    1135         dUdBu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[1]),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x 32 x 6cosUij
     1129        Umod = np.swapaxes((UmodAB),2,4)      #atoms x waves x ngl x 3x3 (symmetric so I can do this!)
     1130        HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1)    #ops x atoms x waves x ngl
     1131        HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1)    #ops x atoms x waves x ngl
     1132        HbH = np.exp(-np.sum(HuH,axis=-2)) # ops x atoms x ngl; sum waves - OK vs Modulation version
     1133        part1 = -np.exp(-HuH)*Fmod    #ops x atoms x waves x ngl
     1134        dUdAu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[0]),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x ngl x 6sinUij
     1135        dUdBu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[1]),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x ngl x 6cosUij
    11361136        dGdMuCa = np.sum(part1[:,:,:,:,nxs]*dUdAu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)   #ops x atoms x waves x 6uij; G-L sum
    11371137        dGdMuCb = np.sum(part1[:,:,:,:,nxs]*dUdBu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)
     
    11421142    else:
    11431143        HbH = np.ones_like(HdotX)
    1144     dHdXA = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[0],-1,-2)[nxs,:,:,:,:]    #ops x atoms x sine waves x 32 x xyz
     1144    dHdXA = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[0],-1,-2)[nxs,:,:,:,:]    #ops x atoms x sine waves x ngl x xyz
    11451145    dHdXB = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[1],-1,-2)[nxs,:,:,:,:]    #ditto - cos waves
    11461146    dGdMxCa = -np.sum((Fmod*HbH)[:,:,nxs,:,nxs]*(dHdXA*np.sin(HdotXD)[:,:,nxs,:,nxs])*glWt[nxs,nxs,nxs,:,nxs],axis=-2)
     
    11521152    dGdMxS = np.concatenate((dGdMxSa,dGdMxSb),axis=-1)
    11531153# ZigZag/Block waves
    1154     dHdXZt = twopi*np.ones(HP.shape[0])[:,nxs,nxs,nxs]*np.swapaxes(SCtauX[2],-1,-2)[nxs,:,:,:]          #??ops x atoms x 32 x 3(ZigZag/Block Tminmax)
    1155     dHdXZx = twopi*HP[:,nxs,nxs,:]*np.swapaxes(SCtauX[3],-1,-2)[nxs,:,:,:]          #ops x atoms x 32 x 3(ZigZag/Block XYZmax)
     1154    dHdXZt = twopi*np.ones(HP.shape[0])[:,nxs,nxs,nxs]*np.swapaxes(SCtauX[2],-1,-2)[nxs,:,:,:]          #??ops x atoms x ngl x 3(ZigZag/Block Tminmax)
     1155    dHdXZx = twopi*HP[:,nxs,nxs,:]*np.swapaxes(SCtauX[3],-1,-2)[nxs,:,:,:]          #ops x atoms x ngl x 3(ZigZag/Block XYZmax)
    11561156    dGdMzCt = -np.sum((Fmod*HbH)[:,:,:,nxs]*(dHdXZt*np.sin(HdotXD)[:,:,:,nxs])*glWt[nxs,nxs,:,nxs],axis=-2)
    11571157    dGdMzCx = -np.sum((Fmod*HbH)[:,:,:,nxs]*(dHdXZx*np.sin(HdotXD)[:,:,:,nxs])*glWt[nxs,nxs,:,nxs],axis=-2)
  • TabularUnified trunk/GSASIIphsGUI.py

    r2070 r2075  
    6868atan2d = lambda x,y: 180.*np.arctan2(y,x)/np.pi
    6969
    70 def SetPhaseWindow(mainFrame,phasePage,mainSizer):
     70def SetPhaseWindow(mainFrame,phasePage,mainSizer,Scroll=0):
    7171    phasePage.SetSizer(mainSizer)
    7272    Size = mainSizer.GetMinSize()
    7373    Size[0] += 40
    7474    Size[1] = min(Size[1]+ 150,500)
     75    phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1)
    7576    phasePage.SetSize(Size)
    76     phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1)
     77    phasePage.Scroll(0,Scroll)
    7778    mainFrame.setSizePosLeft(Size)
    78     mainFrame.SendSizeEvent()
    7979   
    8080#def FindBondsToo():                         #works but slow for large structures - keep as reference
     
    319319################################################################################
    320320
    321     def UpdateGeneral():
     321    def UpdateGeneral(Scroll=0):
    322322        '''Draw the controls for the General phase data subpage
    323323        '''
     
    715715        def ModulatedSizer(name):
    716716           
    717             def OnSuperGp(event):
     717            def OnSuperGp(event):   #for HKLF needs to reject SSgps not agreeing with modVec!
    718718                SSymbol = superGp.GetValue()
    719719                E,SSGData = G2spc.SSpcGroup(generalData['SGData'],SSymbol)
     
    771771                superGp.Bind(wx.EVT_TEXT_ENTER,OnSuperGp)                       
    772772            modSizer.Add(superGp,0,WACV)
    773             modSizer.Add(wx.StaticText(General,label=' Max index: '),0,WACV)
    774             indChoice = ['1','2','3','4','5','6','7']
    775             Max = wx.ComboBox(General,-1,value='%d'%(generalData['SuperVec'][2]),choices=indChoice,
    776                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    777             Max.Bind(wx.EVT_COMBOBOX,OnMax)       
    778             modSizer.Add(Max,0,WACV)
     773            if PWDR:
     774                modSizer.Add(wx.StaticText(General,label=' Max index: '),0,WACV)
     775                indChoice = ['1','2','3','4','5','6','7']
     776                Max = wx.ComboBox(General,-1,value='%d'%(generalData['SuperVec'][2]),choices=indChoice,
     777                    style=wx.CB_READONLY|wx.CB_DROPDOWN)
     778                Max.Bind(wx.EVT_COMBOBOX,OnMax)       
     779                modSizer.Add(Max,0,WACV)
    779780            ssSizer.Add(modSizer,0,WACV)
    780781            vecSizer = wx.FlexGridSizer(1,5,5,5)
     
    796797                    modVal.SetBackgroundColour(VERY_LIGHT_GREY)
    797798                    vecSizer.Add(modVal,0,WACV)
    798             Ref = wx.CheckBox(General,label='Refine?')
    799             Ref.SetValue(generalData['SuperVec'][1])
    800             Ref.Bind(wx.EVT_CHECKBOX, OnVecRef)
    801             vecSizer.Add(Ref,0,WACV)
     799            if PWDR:
     800                Ref = wx.CheckBox(General,label='Refine?')
     801                Ref.SetValue(generalData['SuperVec'][1])
     802                Ref.Bind(wx.EVT_CHECKBOX, OnVecRef)
     803                vecSizer.Add(Ref,0,WACV)
    802804            ssSizer.Add(vecSizer)
    803805            return ssSizer
     
    818820                finally:
    819821                    dlg.Destroy()
    820                 wx.CallAfter(UpdateGeneral)               
     822                wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL))               
    821823               
    822824            def OnResVal(event):
     
    889891                finally:
    890892                    dlg.Destroy()
    891                 wx.CallAfter(UpdateGeneral)               
     893                wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL))               
    892894               
    893895            def OnNormElem(event):
     
    981983            def OnAlist(event):
    982984                MCSAdata['Algorithm'] = Alist.GetValue()
    983                 wx.CallAfter(UpdateGeneral)
     985                wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL))
    984986               
    985987            def OnSlope(event):
     
    11711173            mainSizer.Add(MCSASizer())
    11721174        G2frame.dataFrame.SetStatusText('')
    1173         SetPhaseWindow(G2frame.dataFrame,General,mainSizer)
     1175        SetPhaseWindow(G2frame.dataFrame,General,mainSizer,Scroll)
    11741176
    11751177################################################################################
     
    23362338################################################################################
    23372339
    2338     def UpdateWavesData():
     2340    def UpdateWavesData(Scroll=0):
    23392341       
    23402342        generalData = data['General']
     
    23462348                atom[-1][SS]['waveType']=waveType.GetValue()
    23472349                atom[-1][SS]['Spos'] = []
    2348                 UpdateWavesData()               
     2350                UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL))               
    23492351               
    23502352            def OnShowWave(event):
     
    23802382                    nt = numVals[waveType]
    23812383                atomData[iatm][-1][SS][item].append([[0.0 for i in range(nt)],False])
    2382                 UpdateWavesData()
     2384                UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL))
    23832385               
    23842386            def OnWaveVal(event):
     
    24062408                iatm,item,iwave = Indx[Obj.GetId()]
    24072409                del atomData[iatm][-1][SS][item][iwave]
    2408                 UpdateWavesData()               
     2410                UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL))               
    24092411           
    24102412            waveSizer = wx.BoxSizer(wx.VERTICAL)
     
    25092511                            break
    25102512                        mainSizer.Add(WaveSizer(atm[-1][SS]['waveType'],atm[-1][SS][Stype],Stype,typeNames[Stype],Labels[Stype]))                       
    2511         SetPhaseWindow(G2frame.dataFrame,waveData,mainSizer)
    2512                        
    2513     def On4DMapCompute(event):
    2514         generalData = data['General']
    2515         mapData = generalData['4DmapData']
    2516         reflNames = mapData['RefList']
    2517         generalData['Map']['Flip'] = False
    2518         if not len(reflNames):
    2519             G2frame.ErrorDialog('Fourier map error','No reflections defined for Fourier map')
    2520             return
    2521         phaseName = generalData['Name']
    2522         ReflData = GetReflData(G2frame,phaseName,reflNames)
    2523         if ReflData == None: return
    2524         G2mth.Fourier4DMap(data,ReflData)
    2525         data['Drawing']['contourLevel'] = 1.
    2526         data['Drawing']['mapSize'] = 10.
    2527         mapSig = np.std(mapData['rho'])
    2528         print '4D '+mapData['MapType']+' computed: rhomax = %.3f rhomin = %.3f sigma = %.3f'%(np.max(mapData['rho']),np.min(mapData['rho']),mapSig)
    2529         wx.CallAfter(UpdateWavesData)
    2530            
     2513       
     2514        SetPhaseWindow(G2frame.dataFrame,G2frame.waveData,mainSizer,Scroll)
     2515
    25312516################################################################################
    25322517#### Structure drawing GUI stuff               
     
    40854070            ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G))
    40864071            iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData)
    4087         #G2frame.PatternTree.SetItemPyData(Id,[refDict,reflData]) #removed by BHT -- not needed!
    40884072       
    40894073    def OnDataCopy(event):
  • TabularUnified trunk/GSASIIspc.py

    r2062 r2075  
    970970    return SSGText,SSGTable
    971971   
    972 def SSGModCheck(Vec,modSymb):
     972def SSGModCheck(Vec,modSymb,newMod=True):
    973973    ''' Checks modulation vector compatibility with supersymmetry space group symbol.
    974     Superspace group symbol takes precidence & the vector will be modified accordingly
     974    if newMod: Superspace group symbol takes precidence & the vector will be modified accordingly
    975975    '''
    976976    Fracs = {'1/2':0.5,'1/3':1./3,'1':1.0,'0':0.,'a':0.,'b':0.,'g':0.}
    977977    modQ = [Fracs[mod] for mod in modSymb]
    978     Vec = [0.1 if (vec == 0.0 and mod in ['a','b','g']) else vec for [vec,mod] in zip(Vec,modSymb)]
    979     return [Q if mod not in ['a','b','g'] and vec != Q else vec for [vec,mod,Q] in zip(Vec,modSymb,modQ)],  \
    980         [True if mod in ['a','b','g'] else False for mod in modSymb]
     978    if newMod:
     979        newVec = [0.1 if (vec == 0.0 and mod in ['a','b','g']) else vec for [vec,mod] in zip(Vec,modSymb)]
     980        return [Q if mod not in ['a','b','g'] and vec != Q else vec for [vec,mod,Q] in zip(newVec,modSymb,modQ)],  \
     981            [True if mod in ['a','b','g'] else False for mod in modSymb]
     982    else:
     983        return Vec,[True if mod in ['a','b','g'] else False for mod in modSymb]
    981984
    982985def SSMT2text(Opr):
  • TabularUnified trunk/GSASIIstrMath.py

    r2070 r2075  
    994994    Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict)
    995995    waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict)
    996     nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)
     996    ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)
    997997    modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']])
    998998    FF = np.zeros(len(Tdata))
     
    11211121    mSize = len(Mdata)  #no. atoms
    11221122    waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict)
    1123     nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)
    1124     waveShapes,SCtauF,SCtauX,SCtauU,UmodAB = G2mth.makeWavesDerv(waveTypes,FSSdata,XSSdata,USSdata,Mast)
     1123    ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)
     1124    waveShapes,SCtauF,SCtauX,SCtauU,UmodAB = G2mth.makeWavesDerv(ngl,waveTypes,FSSdata,XSSdata,USSdata,Mast)
    11251125    modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']])
    11261126    FF = np.zeros(len(Tdata))
     
    11481148        dFdfl = np.zeros((nRef,nTwin))
    11491149        dFdtw = np.zeros((nRef,nTwin))
    1150         dFdGfA = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1]))
    1151         dFdGfB = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1]))
    1152         dFdGxA = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3))
    1153         dFdGxB = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3))
    1154         dFdGuA = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6))
    1155         dFdGuB = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6))
     1150        dFdGf = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1]))
     1151        dFdGx = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3))
     1152        dFdGz = np.zeros((nRef,nTwin,mSize,5))
     1153        dFdGu = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6))
    11561154    else:
    11571155        dFdfr = np.zeros((nRef,mSize))
     
    12421240            dfadGx = np.sum(fa[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1)
    12431241            dfbdGx = np.sum(fb[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1)
    1244             dfadGz = np.sum(fa[:,it,:,0,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:]-fb[:,it,:,0,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:],axis=1)
    1245             dfbdGz = np.sum(fb[:,it,:,0,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:]+fa[:,it,:,0,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:],axis=1)
     1242            dfadGz = np.sum(fa[:,it,:,0,nxs,nxs]*dGdz[0][nxs,nxs,:,:,:]-fb[:,it,:,0,nxs,nxs]*dGdz[1][nxs,nxs,:,:,:],axis=1)
     1243            dfbdGz = np.sum(fb[:,it,:,0,nxs,nxs]*dGdz[0][nxs,nxs,:,:,:]+fa[:,it,:,0,nxs,nxs]*dGdz[1][nxs,nxs,:,:,:],axis=1)
    12461244            dfadGu = np.sum(fa[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
    12471245            dfbdGu = np.sum(fb[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
     
    12781276            dFdGf[iref] = 2.*(SA*dfadGf[0]+SB*dfbdGf[1])      #array(nRef,natom,nwave,2)
    12791277            dFdGx[iref] = 2.*(SA*dfadGx[0]+SB*dfbdGx[1])      #array(nRef,natom,nwave,6)
     1278            dFdGz[iref] = 2.*(SA*dfadGz[0]+SB*dfbdGz[1])      #array(nRef,natom,5)
    12801279            dFdGu[iref] = 2.*(SA*dfadGu[0]+SB*dfbdGu[1])      #array(nRef,natom,nwave,12)
    12811280#            dFdfr[iref] = 2.*(fas[0]*dfadfr[0]+fas[1]*dfadfr[1])*Mdata/len(Uniq)+   \
     
    13031302                dFdGf[iref] = [2.*TwMask[it]*(SA[it]*dfadGf[1]+SB[it]*dfbdGf[1]) for it in range(nTwin)]
    13041303                dFdGx[iref] = [2.*TwMask[it]*(SA[it]*dfadGx[1]+SB[it]*dfbdGx[1]) for it in range(nTwin)]
    1305                 dFdGz[iref] = [2.*TwMask[it]*(SA[it]*dfadGx[1]+SB[it]*dfbdGx[1]) for it in range(nTwin)]
     1304                dFdGz[iref] = [2.*TwMask[it]*(SA[it]*dfadGz[1]+SB[it]*dfbdGz[1]) for it in range(nTwin)]
    13061305                dFdGu[iref] = [2.*TwMask[it]*(SA[it]*dfadGu[1]+SB[it]*dfbdGu[1]) for it in range(nTwin)]               
    13071306            else:   #these are good for no twin single crystals
     
    13191318            2.*fbs[0]*np.array([np.sum(dfbdba*dBabdA),np.sum(-dfbdba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T
    13201319        #loop over atoms - each dict entry is list of derivatives for all the reflections
    1321 #        GSASIIpath.IPyBreak()
    13221320        if not iref%100 :
    13231321            print ' %d derivative time %.4f\r'%(iref,time.time()-time0),
    1324     for i in range(len(Mdata)):     #loop over atoms 
     1322    for i in range(len(Mdata)):     #loop over atoms
    13251323        dFdvDict[pfx+'Afrac:'+str(i)] = dFdfr.T[i]
    13261324        dFdvDict[pfx+'dAx:'+str(i)] = dFdx.T[0][i]
     
    13371335            dFdvDict[pfx+'Fsin:'+str(i)+':'+str(j)] = dFdGf.T[0][j][i]
    13381336            dFdvDict[pfx+'Fcos:'+str(i)+':'+str(j)] = dFdGf.T[1][j][i]
    1339         for j in range(XSSdata.shape[1]):       #loop over waves
    1340             dFdvDict[pfx+'Xsin:'+str(i)+':'+str(j)] = dFdGx.T[0][j][i]
    1341             dFdvDict[pfx+'Ysin:'+str(i)+':'+str(j)] = dFdGx.T[1][j][i]
    1342             dFdvDict[pfx+'Zsin:'+str(i)+':'+str(j)] = dFdGx.T[2][j][i]
    1343             dFdvDict[pfx+'Xcos:'+str(i)+':'+str(j)] = dFdGx.T[3][j][i]
    1344             dFdvDict[pfx+'Ycos:'+str(i)+':'+str(j)] = dFdGx.T[4][j][i]
    1345             dFdvDict[pfx+'Zcos:'+str(i)+':'+str(j)] = dFdGx.T[5][j][i]
    1346         dFdvDict[pfx+'Tmin:'+str(i)+':0'] = dFdGz.T[0][i]
    1347         dFdvDict[pfx+'Tmax:'+str(i)+':0'] = dFdGz.T[0][i]
    1348         dFdvDict[pfx+'Xmax:'+str(i)+':0'] = dFdGz.T[0][i]
    1349         dFdvDict[pfx+'Ymax:'+str(i)+':0'] = dFdGz.T[0][i]
    1350         dFdvDict[pfx+'Zmax:'+str(i)+':0'] = dFdGz.T[0][i]
     1337        nx = 0
     1338        if waveTypes[i] in ['Block','ZigZag']:
     1339            nx = 1
     1340            dFdvDict[pfx+'Tmin:'+str(i)+':0'] = dFdGz.T[0][i]   #ZigZag/Block waves (if any)
     1341            dFdvDict[pfx+'Tmax:'+str(i)+':0'] = dFdGz.T[1][i]
     1342            dFdvDict[pfx+'Xmax:'+str(i)+':0'] = dFdGz.T[2][i]
     1343            dFdvDict[pfx+'Ymax:'+str(i)+':0'] = dFdGz.T[3][i]
     1344            dFdvDict[pfx+'Zmax:'+str(i)+':0'] = dFdGz.T[4][i]
     1345        for j in range(XSSdata.shape[1]-nx):       #loop over waves
     1346            dFdvDict[pfx+'Xsin:'+str(i)+':'+str(j+nx)] = dFdGx.T[0][j][i]
     1347            dFdvDict[pfx+'Ysin:'+str(i)+':'+str(j+nx)] = dFdGx.T[1][j][i]
     1348            dFdvDict[pfx+'Zsin:'+str(i)+':'+str(j+nx)] = dFdGx.T[2][j][i]
     1349            dFdvDict[pfx+'Xcos:'+str(i)+':'+str(j+nx)] = dFdGx.T[3][j][i]
     1350            dFdvDict[pfx+'Ycos:'+str(i)+':'+str(j+nx)] = dFdGx.T[4][j][i]
     1351            dFdvDict[pfx+'Zcos:'+str(i)+':'+str(j+nx)] = dFdGx.T[5][j][i]
    13511352        for j in range(USSdata.shape[1]):       #loop over waves
    13521353            dFdvDict[pfx+'U11sin:'+str(i)+':'+str(j)] = dFdGu.T[0][j][i]
     
    13631364            dFdvDict[pfx+'U23cos:'+str(i)+':'+str(j)] = 2.*dFdGu.T[11][j][i]
    13641365           
     1366#    GSASIIpath.IPyBreak()
    13651367    dFdvDict[phfx+'BabA'] = dFdbab.T[0]
    13661368    dFdvDict[phfx+'BabU'] = dFdbab.T[1]
     
    26442646                        try:
    26452647                            aname = name.split(pfx)[1][:2]
    2646                             if aname not in ['Af','dA','AU','RB','Xs','Xc','Ys','Yc','Zs','Zc','U1','U2','U3']: continue # skip anything not an atom or rigid body param
     2648                            if aname not in ['Af','dA','AU','RB','Xs','Xc','Ys','Yc','Zs','Zc','Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param
    26472649                        except IndexError:
    26482650                            continue
Note: See TracChangeset for help on using the changeset viewer.