Changeset 3286
- Timestamp:
- Feb 15, 2018 4:30:05 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3275 r3286 6114 6114 SetMapPeaksText(mapPeaks) 6115 6115 elif key in ['M',]and generalData['Modulated']: #make a movie file 6116 G2frame.tau = 0. 6117 for i in range(100): 6118 G2frame.tau += 0.02 6119 G2frame.tau %= 1. 6120 G2frame.G2plotNB.status.SetStatusText('Modulation tau = %.2f'%(G2frame.tau),1) 6121 data['Drawing']['Atoms'],Fade = G2mth.ApplyModulation(data,G2frame.tau) #modifies drawing atom array! 6122 SetDrawAtomsText(data['Drawing']['Atoms']) 6123 G2phG.FindBondsDraw(data) #rebuild bonds & polygons 6124 # if not np.any(Fade): 6125 # Fade += 1 6126 Draw('key down',Fade) 6127 return 6116 import imageio 6117 from PIL import Image as Im 6118 Fname = generalData['Name']+'.gif' 6119 size = Page.canvas.GetSize() 6120 G2frame.tau = 0.0 6121 data['Drawing']['Atoms'],Fade = G2mth.ApplyModulation(data,G2frame.tau) #modifies drawing atom array! 6122 SetDrawAtomsText(data['Drawing']['Atoms']) 6123 G2phG.FindBondsDraw(data) #rebuild bonds & polygons 6124 Draw('key down',Fade) 6125 fps = GSASIIpath.GetConfigValue('Movie_fps',10) 6126 duration = GSASIIpath.GetConfigValue('Movie_time',5) #sec 6127 steps = duration*fps 6128 delt = 1./steps 6129 with imageio.get_writer(Fname, mode='I',fps=fps) as writer: 6130 G2frame.tau = 0. 6131 for i in range(steps): 6132 G2frame.G2plotNB.status.SetStatusText('Modulation tau = %.2f'%(G2frame.tau),1) 6133 data['Drawing']['Atoms'],Fade = G2mth.ApplyModulation(data,G2frame.tau) #modifies drawing atom array! 6134 SetDrawAtomsText(data['Drawing']['Atoms']) 6135 G2phG.FindBondsDraw(data) #rebuild bonds & polygons 6136 Draw('key down',Fade) 6137 GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) 6138 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE) 6139 im = Im.new("RGB", (size[0],size[1])) 6140 try: 6141 im.frombytes(Pix) 6142 except AttributeError: 6143 im.fromstring(Pix) 6144 im = im.transpose(Im.FLIP_TOP_BOTTOM) 6145 writer.append_data(np.array(im)) 6146 G2frame.tau += delt 6147 return 6128 6148 elif key in ['+','-','=','0']: 6129 6149 if keyBox: … … 7062 7082 choice = [' save as/key:','jpeg','tiff','bmp','c: center on 1/2,1/2,1/2','n: next','p: previous'] 7063 7083 if generalData['Modulated'] and len(drawAtoms): 7064 choice += ['+: increase tau','-: decrease tau','0: set tau = 0'] #add 'm: make modulation movie'7084 choice += ['+: increase tau','-: decrease tau','0: set tau = 0'] 7065 7085 7066 7086 Tx,Ty,Tz = drawingData['viewPoint'][0] -
trunk/GSASIIspc.py
r3285 r3286 2204 2204 dFTP = None 2205 2205 if siteSym == '1': 2206 CSI = [[1,0],[2,0]], [2*[1.,0.]]2206 CSI = [[1,0],[2,0]],2*[[1.,0.],] 2207 2207 elif siteSym == '-1': 2208 CSI = [[1,0],[0,0]], [2*[1.,0.]]2208 CSI = [[1,0],[0,0]],2*[[1.,0.],] 2209 2209 else: 2210 2210 delt2 = np.eye(2)*0.001 … … 2261 2261 dX,dXTP = None,None 2262 2262 if siteSym == '1': 2263 CSI = [[1,0,0],[2,0,0],[3,0,0], [4,0,0],[5,0,0],[6,0,0]], [6*[1.,0.,0.]]2263 CSI = [[1,0,0],[2,0,0],[3,0,0], [4,0,0],[5,0,0],[6,0,0]],6*[[1.,0.,0.],] 2264 2264 elif siteSym == '-1': 2265 CSI = [[1,0,0],[2,0,0],[3,0,0], [0,0,0],[0,0,0],[0,0,0]], [3*[1.,0.,0.],3*[0.,0.,0.]]2265 CSI = [[1,0,0],[2,0,0],[3,0,0], [0,0,0],[0,0,0],[0,0,0]],3*[[1.,0.,0.],]+3*[[0.,0.,0.],] 2266 2266 else: 2267 2267 delt4 = np.ones(4)*0.001 … … 2364 2364 if siteSym == '1': 2365 2365 CSI = [[1,0,0],[2,0,0],[3,0,0],[4,0,0],[5,0,0],[6,0,0], 2366 [7,0,0],[8,0,0],[9,0,0],[10,0,0],[11,0,0],[12,0,0]],12*[[1.,0.,0.] ]2366 [7,0,0],[8,0,0],[9,0,0],[10,0,0],[11,0,0],[12,0,0]],12*[[1.,0.,0.],] 2367 2367 elif siteSym == '-1': 2368 CSI = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0], 2369 [1,0,0],[2,0,0],[3,0,0],[4,0,0],[5,0,0],[6,0,0]], 2370 [[0.,0.,0.],[0.,0.,0.],[0.,0.,0.],[0.,0.,0.],[0.,0.,0.],[0.,0.,0.], 2371 [1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],] 2368 CSI = 6*[[0,0,0],]+[[1,0,0],[2,0,0],[3,0,0],[4,0,0],[5,0,0],[6,0,0]], \ 2369 6*[[0.,0.,0.],]+[[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.]] 2372 2370 else: 2373 2371 tau = np.linspace(0,1,49,True) … … 2476 2474 2477 2475 def DoMag(): 2478 CSI = [[1,0,0],[2,0,0],[3,0,0], [4,0,0],[5,0,0],[6,0,0]], \ 2479 [[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.]] 2476 CSI = [[1,0,0],[2,0,0],[3,0,0], [4,0,0],[5,0,0],[6,0,0]],6*[[1.,0.,0.],] 2480 2477 if siteSym == '1': 2481 CSI = [[1,0,0],[2,0,0],[3,0,0], [4,0,0],[5,0,0],[6,0,0]], \ 2482 [[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.]] 2478 CSI = [[1,0,0],[2,0,0],[3,0,0],[4,0,0],[5,0,0],[6,0,0]],6*[[1.,0.,0.],] 2483 2479 elif siteSym in ['-1','mmm','2/m(x)','2/m(y)','2/m(z)','4/mmm001']: 2484 CSI = [[0,0,0],[0,0,0],[0,0,0], [1,0,0],[2,0,0],[3,0,0]], \ 2485 [[0.,0.,0.],[0.,0.,0.],[0.,0.,0.],[1.,0.,0.],[1.,0.,0.],[1.,0.,0.]] 2480 CSI = 3*[[0,0,0],]+[[1,0,0],[2,0,0],[3,0,0]],3*[[0.,0.,0.],]+3*[[1.,0.,0.],] 2481 else: 2482 delt6 = np.eye(6)*0.001 2483 dM = posFourier(tau,nH,delt6[:3],delt6[3:]) #+np.array(Mxyz)[:,np.newaxis,np.newaxis] 2484 #3x6x12 modulated moment array (M,Spos,tau)& force positive 2485 CSI = [np.zeros((6,3),dtype='i'),np.zeros((6,3))] 2486 MSC = np.ones(6,dtype='i') 2487 dMTP = [] 2488 for i in SdIndx: 2489 sop = Sop[i] 2490 ssop = SSop[i] 2491 sdet,ssdet,dtau,dT,tauT = getTauT(tau,sop,ssop,XYZ) 2492 msc = np.ones(6,dtype='i') 2493 dMT = posFourier(np.sort(tauT),nH,delt6[:3],delt6[3:]) #+np.array(XYZ)[:,np.newaxis,np.newaxis] 2494 dMT = np.inner(sop[0],dMT.T) # X modulations array(3x6x49) -> array(3x49x6) 2495 dMT = np.swapaxes(dMT,1,2) # back to array(3x6x49) 2496 dMT[:,:3,:] *= (ssdet*sdet) # modify the sin component 2497 dMTP.append(dMT) 2498 for i in range(3): 2499 if not np.allclose(dM[i,i,:],dMT[i,i,:]): 2500 msc[i] = 0 2501 if not np.allclose(dM[i,i+3,:],dMT[i,i+3,:]): 2502 msc[i+3] = 0 2503 if np.any(dtau%.5) and ('1/2' in SSGData['modSymb'] or '1' in SSGData['modSymb']): 2504 msc[3:6] = 0 2505 CSI = [[[1,0,0],[2,0,0],[3,0,0], [1,0,0],[2,0,0],[3,0,0]], 2506 [[1.,0.,0.],[1.,0.,0.],[1.,0.,0.], [1.,0.,0.],[1.,0.,0.],[1.,0.,0.]]] 2507 if dT: 2508 if '(x)' in siteSym: 2509 CSI[1][3:] = [1./dT,0.,0.],[-dT,0.,0.],[-dT,0.,0.] 2510 if 'm' in siteSym and len(SdIndx) == 1: 2511 CSI[1][3:] = [-dT,0.,0.],[1./dT,0.,0.],[1./dT,0.,0.] 2512 elif '(y)' in siteSym: 2513 CSI[1][3:] = [-dT,0.,0.],[1./dT,0.,0.],[-dT,0.,0.] 2514 if 'm' in siteSym and len(SdIndx) == 1: 2515 CSI[1][3:] = [1./dT,0.,0.],[-dT,0.,0.],[1./dT,0.,0.] 2516 elif '(z)' in siteSym: 2517 CSI[1][3:] = [-dT,0.,0.],[-dT,0.,0.],[1./dT,0.,0.] 2518 if 'm' in siteSym and len(SdIndx) == 1: 2519 CSI[1][3:] = [1./dT,0.,0.],[1./dT,0.,0.],[-dT,0.,0.] 2520 else: 2521 CSI[1][3:] = [0.,0.,0.],[0.,0.,0.],[0.,0.,0.] 2522 if '4/mmm' in laue: 2523 if np.any(dtau%.5) and '1/2' in SSGData['modSymb']: 2524 if '(xy)' in siteSym: 2525 CSI[0] = [[1,0,0],[1,0,0],[2,0,0], [1,0,0],[1,0,0],[2,0,0]] 2526 if dT: 2527 CSI[1][3:] = [[1./dT,0.,0.],[1./dT,0.,0.],[-dT,0.,0.]] 2528 else: 2529 CSI[1][3:] = [0.,0.,0.],[0.,0.,0.],[0.,0.,0.] 2530 if '(xy)' in siteSym or '(+-0)' in siteSym: 2531 mul = 1 2532 if '(+-0)' in siteSym: 2533 mul = -1 2534 if np.allclose(dM[0,0,:],dMT[1,0,:]): 2535 CSI[0][3:5] = [[11,0,0],[11,0,0]] 2536 CSI[1][3:5] = [[1.,0,0],[mul,0,0]] 2537 msc[3:5] = 0 2538 if np.allclose(dM[0,3,:],dMT[0,4,:]): 2539 CSI[0][:2] = [[12,0,0],[12,0,0]] 2540 CSI[1][:2] = [[1.,0,0],[mul,0,0]] 2541 msc[:2] = 0 2542 MSC &= msc 2543 if debug: print (SSMT2text(ssop).replace(' ',''),sdet,ssdet,epsinv,msc) 2544 n = -1 2545 if debug: print (MSC) 2546 for i,M in enumerate(MSC): 2547 if M: 2548 n += 1 2549 CSI[0][i][0] = n+1 2550 CSI[1][i][0] = 1.0 2551 2486 2552 return CSI,None,None 2487 2553 -
trunk/GSASIIstrIO.py
r3266 r3286 1261 1261 else: 1262 1262 CSI = G2spc.GetSSfxuinel('Fourier',Stype,iw+1-nx,at[cx:cx+3],SGData,SSGData) 1263 uId,uCoef = CSI [Stype]1263 uId,uCoef = CSI 1264 1264 stiw = str(i)+':'+str(iw) 1265 1265 if Stype == 'Spos': -
trunk/config_example.py
r3195 r3286 161 161 ''' 162 162 163 Movie_fps = 10 164 ''' Specifies movie frames-per-second; larger number will make smoother modulation movies but larger files. 165 ''' 166 167 Movie_time = 5 168 ''' Specifices time in sec for one modulation loop; larger number will give more frames for same fps' 169 ''' 170 163 171 Multiprocessing_cores = 0 164 172 ''' Specifies the number of cores to use when performing multicore computing. A number less
Note: See TracChangeset
for help on using the changeset viewer.