Changeset 1626
- Timestamp:
- Jan 9, 2015 4:00:01 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1622 r1626 2490 2490 self.DrawAtomEdit.Append(id=wxID_DRAWADDEQUIV, kind=wx.ITEM_NORMAL,text='Add atoms', 2491 2491 help='Add symmetry & cell equivalents to drawing set from selected atoms') 2492 self.DrawAtomEdit.Append(id=wxID_DRAWTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform atoms',2492 self.DrawAtomEdit.Append(id=wxID_DRAWTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform draw atoms', 2493 2493 help='Transform selected atoms by symmetry & cell translations') 2494 2494 self.DrawAtomEdit.Append(id=wxID_DRAWFILLCOORD, kind=wx.ITEM_NORMAL,text='Fill CN-sphere', -
trunk/GSASIImath.py
r1625 r1626 1745 1745 DH = [] 1746 1746 Dphi = [] 1747 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1748 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 1747 1749 Hmax = 2*np.asarray(G2lat.getHKLmax(3.5,SGData,A),dtype='i') 1748 1750 for F in Flist: 1749 1751 hkl = np.unravel_index(Fdict[F],hklShape) 1752 if np.any(np.abs(hkl-hklHalf)-Hmax > 0): 1753 continue 1750 1754 iabsnt,mulp,Uniq,Phi = G2spc.GenHKLf(list(hkl-hklHalf),SGData) 1751 1755 Uniq = np.array(Uniq,dtype='i') … … 1759 1763 dH = H-hkl 1760 1764 dang = ang-ang0 1761 if np.any(np.abs(dH)- Hmax > 0): #keep low order DHs1762 continue1763 1765 DH.append(dH) 1764 1766 Dphi.append((dang+.5) % 1.0) … … 1877 1879 mapData['rho'] = np.roll(np.roll(np.roll(CErho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2) 1878 1880 mapData['rhoMax'] = max(np.max(mapData['rho']),-np.min(mapData['rho'])) 1879 mapData['rollMap'] = [0,0,0]1880 1881 return mapData 1882 1883 def findSSOffset(SGData,SSGData,A,Fhklm): 1884 '''default doc string 1885 1886 :param type name: description 1887 1888 :returns: type name: description 1889 1890 ''' 1891 if SGData['SpGrp'] == 'P 1': 1892 return [0,0,0,0] 1893 hklmShape = Fhklm.shape 1894 hklmHalf = np.array(hklmShape)/2 1895 sortHKLM = np.argsort(Fhklm.flatten()) 1896 Fdict = {} 1897 for hklm in sortHKLM: 1898 HKLM = np.unravel_index(hklm,hklmShape) 1899 F = Fhklm[HKLM[0]][HKLM[1]][HKLM[2]][HKLM[3]] 1900 if F == 0.: 1901 break 1902 Fdict['%.6f'%(np.absolute(F))] = hklm 1903 Flist = np.flipud(np.sort(Fdict.keys())) 1904 F = str(1.e6) 1905 i = 0 1906 DH = [] 1907 Dphi = [] 1908 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 1909 SSGT = np.array([ops[1] for ops in SSGData['SSGOps']]) 1910 Hmax = 2*np.asarray(G2lat.getHKLmax(3.5,SGData,A),dtype='i') 1911 for F in Flist: 1912 hklm = np.unravel_index(Fdict[F],hklmShape) 1913 if np.any(np.abs(hklm-hklmHalf)[:3]-Hmax > 0): 1914 continue 1915 Uniq = np.inner(hklm-hklmHalf,SSGMT) 1916 Phi = np.inner(hklm-hklmHalf,SSGT) 1917 Uniq = np.concatenate((Uniq,-Uniq))+hklmHalf # put in Friedel pairs & make as index to Farray 1918 Phi = np.concatenate((Phi,-Phi)) # and their phase shifts 1919 Fh0 = Fhklm[hklm[0],hklm[1],hklm[2],hklm[3]] 1920 ang0 = np.angle(Fh0,deg=True)/360. 1921 for H,phi in zip(Uniq,Phi)[1:]: 1922 ang = (np.angle(Fhklm[H[0],H[1],H[2],H[3]],deg=True)/360.-phi) 1923 dH = H-hklm 1924 dang = ang-ang0 1925 DH.append(dH) 1926 Dphi.append((dang+.5) % 1.0) 1927 if i > 20 or len(DH) > 30: 1928 break 1929 i += 1 1930 DH = np.array(DH) 1931 print ' map offset no.of terms: %d from %d reflections'%(len(DH),len(Flist)) 1932 Dphi = np.array(Dphi) 1933 steps = np.array(hklmShape) 1934 X,Y,Z,T = np.mgrid[0:1:1./steps[0],0:1:1./steps[1],0:1:1./steps[2],0:1:1./steps[3]] 1935 XYZT = np.array(zip(X.flatten(),Y.flatten(),Z.flatten(),T.flatten())) 1936 Dang = (np.dot(XYZT,DH.T)+.5)%1.-Dphi 1937 Mmap = np.reshape(np.sum((Dang)**2,axis=1),newshape=steps)/len(DH) 1938 hist,bins = np.histogram(Mmap,bins=1000) 1939 # for i,item in enumerate(hist[:10]): 1940 # print item,bins[i] 1941 chisq = np.min(Mmap) 1942 DX = -np.array(np.unravel_index(np.argmin(Mmap),Mmap.shape)) 1943 print ' map offset chi**2: %.3f, map offset: %d %d %d %d'%(chisq,DX[0],DX[1],DX[2],DX[3]) 1944 # print (np.dot(DX,DH.T)+.5)%1.-Dphi 1945 return DX 1881 1946 1882 1947 def SSChargeFlip(data,reflDict,pgbar): … … 1970 2035 SSrho = np.real(fft.fftn(fft.fftshift(CEhkl))) 1971 2036 print ' No.cycles = ',Ncyc,'Residual Rcf =%8.3f%s'%(Rcf,'%')+' Map size:',CErho.shape 1972 roll = find Offset(SGData,A,CEhkl[:,:,:,maxM+1]) #CEhkl needs to be just the observed set, not the full set!2037 roll = findSSOffset(SGData,SSGData,A,CEhkl) #CEhkl needs to be just the observed set, not the full set! 1973 2038 1974 2039 mapData['Rcf'] = Rcf 1975 2040 mapData['rho'] = np.roll(np.roll(np.roll(CErho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2) 1976 2041 mapData['rhoMax'] = max(np.max(mapData['rho']),-np.min(mapData['rho'])) 1977 mapData['rollMap'] = [0,0,0]1978 2042 1979 2043 map4DData['Rcf'] = Rcf 1980 map4DData['rho'] = np.real(np.roll(np.roll(np.roll( SSrho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2))2044 map4DData['rho'] = np.real(np.roll(np.roll(np.roll(np.roll(SSrho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2),roll[3],axis=3)) 1981 2045 map4DData['rhoMax'] = max(np.max(map4DData['rho']),-np.min(map4DData['rho'])) 1982 2046 return mapData,map4DData -
trunk/GSASIIplot.py
r1625 r1626 2798 2798 Off += 1 2799 2799 elif event.key == '-': 2800 Off -= 1 2800 Off -= 1 2801 elif event.key in ['l','r',]: 2802 roll = 1 2803 if event.key == 'l': 2804 roll = -1 2805 rho = Map['rho'] 2806 Map['rho'] = np.roll(rho,roll,axis=3) 2801 2807 wx.CallAfter(ModulationPlot,G2frame,data,Atom,Ax,Off) 2802 2808 … … 2815 2821 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 2816 2822 2817 Page.Choice = ['+: shift up','-: shift down','0: reset ']2823 Page.Choice = ['+: shift up','-: shift down','0: reset shift','l: move left','r: move right'] 2818 2824 Page.keyPress = OnPlotKeyPress 2819 2825 Page.SetFocus() … … 2853 2859 if Ax == 'x': 2854 2860 slab = np.sum(np.sum(rho[:,ix[1]-ib:ix[1]+ib,ix[2]-ib:ix[2]+ib,:],axis=2),axis=1) 2855 Plot.plot( wave[0],tau)2861 Plot.plot(tau,wave[0]) 2856 2862 elif Ax == 'y': 2857 2863 slab = np.sum(np.sum(rho[ix[0]-ib:ix[0]+ib,:,ix[2]-ib:ix[2]+ib,:],axis=2),axis=0) 2858 Plot.plot( wave[1],tau)2864 Plot.plot(tau,wave[1]) 2859 2865 elif Ax == 'z': 2860 2866 slab = np.sum(np.sum(rho[ix[0]-ib:ix[0]+ib,ix[1]-ib:ix[1]+ib,:,:],axis=1),axis=0) 2861 Plot.plot( wave[2],tau)2867 Plot.plot(tau,wave[2]) 2862 2868 Plot.set_title(Title) 2863 2869 Plot.set_xlabel('t') 2864 2870 Plot.set_ylabel(r'$\mathsf{\Delta}$%s'%(Ax)) 2865 Slab = np.concatenate((slab,slab),axis=1).T 2866 Plot.contour(Slab,20,extent=(-.5+Off*.005,.5+Off*.005,0.,2.)) 2867 2871 Slab = np.concatenate((slab,slab),axis=1) 2872 Plot.contour(Slab,20,extent=(0.,2.,-.5+Off*.005,.5+Off*.005)) 2868 2873 Page.canvas.draw() 2869 2874
Note: See TracChangeset
for help on using the changeset viewer.