Changeset 2077
- Timestamp:
- Dec 2, 2015 2:02:03 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2075 r2077 2228 2228 self.IfPlot = False 2229 2229 self.DDShowAll = False 2230 self.atmSel = '' 2230 2231 self.PatternId = 0 2231 2232 self.PickId = 0 -
trunk/GSASIImath.py
r2075 r2077 1023 1023 ''' 1024 1024 glTau,glWt = pwd.pygauleg(0.,1.,ngl) #get Gauss-Legendre intervals & weights 1025 dT = 1./ngl1025 dT = 2./ngl 1026 1026 dX = 0.0001 1027 1027 waveShapes = [FSSdata.T.shape,XSSdata.T.shape,USSdata.T.shape] -
trunk/GSASIIphsGUI.py
r2075 r2077 2342 2342 generalData = data['General'] 2343 2343 cx,ct,cs,cia = generalData['AtomPtrs'] 2344 2345 def AtomSizer(SS,atom): 2346 2347 def OnWaveType(event): 2348 atom[-1][SS]['waveType']=waveType.GetValue() 2349 atom[-1][SS]['Spos'] = [] 2350 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2351 2352 def OnShowWave(event): 2353 Obj = event.GetEventObject() 2354 atom = Indx[Obj.GetId()] 2355 Ax = Obj.GetValue() 2356 G2plt.ModulationPlot(G2frame,data,atom,Ax) 2357 2358 atomSizer = wx.BoxSizer(wx.HORIZONTAL) 2359 atomSizer.Add(wx.StaticText(waveData,label= 2360 ' Modulation data for atom: %s Site sym: %s WaveType: '%(atom[0],atom[cs].strip())),0,WACV) 2361 waveType = wx.ComboBox(waveData,value=atom[-1][SS]['waveType'],choices=waveTypes, 2362 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2363 waveType.Bind(wx.EVT_COMBOBOX,OnWaveType) 2364 atomSizer.Add(waveType,0,WACV) 2365 axchoice = ['x','y','z'] 2366 if len(D4Map['rho']): 2367 atomSizer.Add(wx.StaticText(waveData,label=' Show contour map for axis: '),0,WACV) 2368 mapSel = wx.ComboBox(waveData,value=' ',choices=axchoice, 2369 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2370 mapSel.Bind(wx.EVT_COMBOBOX,OnShowWave) 2371 Indx[mapSel.GetId()] = atom 2372 atomSizer.Add(mapSel,0,WACV) 2373 return atomSizer 2374 2375 def WaveSizer(waveType,waveBlk,Stype,typeName,Names): 2376 2377 def OnAddWave(event): 2378 Obj = event.GetEventObject() 2379 iatm,item = Indx[Obj.GetId()] 2380 nt = numVals[Stype] 2381 if not len(atomData[iatm][-1][SS][item]) and waveType in ['ZigZag','Block'] and Stype == 'Spos': 2382 nt = numVals[waveType] 2383 atomData[iatm][-1][SS][item].append([[0.0 for i in range(nt)],False]) 2384 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2385 2386 def OnWaveVal(event): 2387 Obj = event.GetEventObject() 2388 iatm,item,iwave,ival = Indx[Obj.GetId()] 2389 try: 2390 val = float(Obj.GetValue()) 2391 if waveType in ['ZigZag','Block'] and Stype == 'Spos' and ival < 2 and not iwave: 2392 if ival == 1: #Tmax 2393 val = min(1.0,max(0.0,val)) 2394 elif ival == 0: #Tmin 2395 val = max(-1.,min(val,atomData[iatm][-1][SS][item][iwave][0][1])) 2396 except ValueError: 2397 val = atomData[iatm][-1][SS][item][iwave][0][ival] 2398 Obj.SetValue('%.5f'%val) 2399 atomData[iatm][-1][SS][item][iwave][0][ival] = val 2400 2401 def OnRefWave(event): 2402 Obj = event.GetEventObject() 2403 iatm,item,iwave = Indx[Obj.GetId()] 2404 atomData[iatm][-1][SS][item][iwave][1] = not atomData[iatm][-1][SS][item][iwave][1] 2405 2406 def OnDelWave(event): 2407 Obj = event.GetEventObject() 2408 iatm,item,iwave = Indx[Obj.GetId()] 2409 del atomData[iatm][-1][SS][item][iwave] 2410 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2411 2412 waveSizer = wx.BoxSizer(wx.VERTICAL) 2413 waveHead = wx.BoxSizer(wx.HORIZONTAL) 2414 waveHead.Add(wx.StaticText(waveData,label=typeName+' modulation parameters: '),0,WACV) 2415 waveAdd = wx.CheckBox(waveData,label='Add wave?') 2416 waveAdd.Bind(wx.EVT_CHECKBOX, OnAddWave) 2417 Indx[waveAdd.GetId()] = [iatm,Stype] 2418 waveHead.Add(waveAdd,0,WACV) 2419 waveSizer.Add(waveHead) 2420 if len(waveBlk): 2421 nx = 0 2422 for iwave,wave in enumerate(waveBlk): 2423 if not iwave: 2424 if waveType in ['ZigZag','Block']: 2425 nx = 1 2426 CSI = G2spc.GetSSfxuinel(waveType,1,xyz,SGData,SSGData) 2427 else: 2428 CSI = G2spc.GetSSfxuinel('Fourier',iwave+1-nx,xyz,SGData,SSGData) 2429 waveName = 'Fourier' 2430 if Stype == 'Sfrac': 2431 if 'Crenel' in waveType and not iwave: 2432 waveName = 'Crenel' 2433 names = Names[2:] 2434 else: 2435 names = Names[:2] 2436 Waves = wx.FlexGridSizer(0,4,5,5) 2437 elif Stype == 'Spos': 2438 if waveType in ['ZigZag','Block'] and not iwave: 2439 names = Names[6:] 2440 Waves = wx.FlexGridSizer(0,7,5,5) 2441 waveName = waveType 2442 else: 2443 names = Names[:6] 2444 Waves = wx.FlexGridSizer(0,8,5,5) 2445 else: 2446 names = Names 2447 Waves = wx.FlexGridSizer(0,8,5,5) 2448 waveSizer.Add(wx.StaticText(waveData,label=' %s parameters: %s'%(waveName,str(names).rstrip(']').lstrip('[').replace("'",''))),0,WACV) 2449 for ival,val in enumerate(wave[0]): 2450 if np.any(CSI[Stype][0][ival]): 2451 waveVal = wx.TextCtrl(waveData,value='%.5f'%(val),style=wx.TE_PROCESS_ENTER) 2452 waveVal.Bind(wx.EVT_TEXT_ENTER,OnWaveVal) 2453 waveVal.Bind(wx.EVT_KILL_FOCUS,OnWaveVal) 2454 Indx[waveVal.GetId()] = [iatm,Stype,iwave,ival] 2455 else: 2456 waveVal = wx.TextCtrl(waveData,value='%.5f'%(val),style=wx.TE_READONLY) 2457 waveVal.SetBackgroundColour(VERY_LIGHT_GREY) 2458 Waves.Add(waveVal,0,WACV) 2459 if len(wave[0]) > 6 and ival == 5: 2460 Waves.Add((5,5),0) 2461 Waves.Add((5,5),0) 2462 waveRef = wx.CheckBox(waveData,label='Refine?') 2463 waveRef.SetValue(wave[1]) 2464 Indx[waveRef.GetId()] = [iatm,Stype,iwave] 2465 waveRef.Bind(wx.EVT_CHECKBOX, OnRefWave) 2466 Waves.Add(waveRef,0,WACV) 2467 if iwave < len(waveBlk)-1: 2468 Waves.Add((5,5),0) 2469 else: 2470 waveDel = wx.CheckBox(waveData,label='Delete?') 2471 Indx[waveDel.GetId()] = [iatm,Stype,iwave] 2472 waveDel.Bind(wx.EVT_CHECKBOX, OnDelWave) 2473 Waves.Add(waveDel,0,WACV) 2474 waveSizer.Add(Waves) 2475 return waveSizer 2476 2344 typeNames = {'Sfrac':' Site fraction','Spos':' Position','Sadp':' Thermal motion','Smag':' Magnetic moment'} 2345 numVals = {'Sfrac':2,'Spos':6,'Sadp':12,'Smag':6,'ZigZag':5,'Block':5} 2346 posNames = ['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tmin','Tmax','Xmax','Ymax','Zmax'] 2347 adpNames = ['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin', 2348 'U11cos','U22cos','U33cos','U12cos','U13cos','U23cos'] 2349 magNames = ['MXsin','MYsin','MZsin','MXcos','MYcos','MZcos'] 2350 fracNames = ['Fsin','Fcos','Fzero','Fwid'] 2351 waveTypes = ['Fourier','ZigZag','Block','Crenel/Fourier'] 2352 Labels = {'Spos':posNames,'Sfrac':fracNames,'Sadp':adpNames,'Smag':magNames} 2477 2353 Indx = {} 2478 2354 waveData = G2frame.waveData … … 2488 2364 waveData.GetSizer().Clear(True) 2489 2365 mainSizer = wx.BoxSizer(wx.VERTICAL) 2490 typeNames = {'Sfrac':' Site fraction','Spos':' Position','Sadp':' Thermal motion','Smag':' Magnetic moment'} 2491 numVals = {'Sfrac':2,'Spos':6,'Sadp':12,'Smag':6,'ZigZag':5,'Block':5} 2492 posNames = ['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tmin','Tmax','Xmax','Ymax','Zmax'] 2493 adpNames = ['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin', 2494 'U11cos','U22cos','U33cos','U12cos','U13cos','U23cos'] 2495 magNames = ['MXsin','MYsin','MZsin','MXcos','MYcos','MZcos'] 2496 fracNames = ['Fsin','Fcos','Fzero','Fwid'] 2497 waveTypes = ['Fourier','ZigZag','Block','Crenel/Fourier'] 2498 Labels = {'Spos':posNames,'Sfrac':fracNames,'Sadp':adpNames,'Smag':magNames} 2499 mainSizer.Add(wx.StaticText(waveData,label=' Incommensurate propagation wave data:'),0,WACV) 2500 if generalData['Type'] in ['modulated','magnetic']: 2501 for iatm,atm in enumerate(atomData): 2502 xyz = atm[cx:cx+3] 2503 uij = atm[cia+2:cia+8] 2504 for SS in ['SS1',]: #future SS2 & SS3 - I doubt it! 2505 G2G.HorizontalLine(mainSizer,waveData) 2506 mainSizer.Add(AtomSizer(SS,atm)) 2507 for Stype in ['Sfrac','Spos','Sadp','Smag']: 2508 if atm[cia] != 'A' and Stype == 'Sadp': #Uiso can't have modulations! (why not?) 2509 continue 2510 if generalData['Type'] != 'magnetic' and Stype == 'Smag': 2511 break 2512 mainSizer.Add(WaveSizer(atm[-1][SS]['waveType'],atm[-1][SS][Stype],Stype,typeNames[Stype],Labels[Stype])) 2366 topSizer = wx.BoxSizer(wx.HORIZONTAL) 2367 topSizer.Add(wx.StaticText(waveData,label=' Incommensurate propagation wave data: Select atom to edit: '),0,WACV) 2368 atNames = [] 2369 for atm in atomData: 2370 atNames.append(atm[ct-1]) 2371 if G2frame.atmSel not in atNames: 2372 G2frame.atmSel = atNames[0] 2373 2374 def OnAtmSel(event): 2375 Obj = event.GetEventObject() 2376 G2frame.atmSel = Obj.GetValue() 2377 RepaintAtomInfo() 2378 2379 def RepaintAtomInfo(Scroll=0): 2380 # mainSizer.Detach(G2frame.bottomSizer) 2381 G2frame.bottomSizer.Clear(True) 2382 G2frame.bottomSizer = ShowAtomInfo() 2383 mainSizer.Add(G2frame.bottomSizer) 2384 Indx = {} 2385 mainSizer.Layout() 2386 G2frame.dataFrame.Refresh() 2387 waveData.SetVirtualSize(mainSizer.GetMinSize()) 2388 waveData.Scroll(0,Scroll) 2389 G2frame.dataFrame.SendSizeEvent() 2390 2391 def ShowAtomInfo(): 2392 2393 def AtomSizer(atom): 2394 2395 def OnWaveType(event): 2396 atom[-1]['SS1']['waveType'] = waveType.GetValue() 2397 atom[-1]['SS1']['Spos'] = [] 2398 RepaintAtomInfo(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2399 2400 def OnShowWave(event): 2401 Obj = event.GetEventObject() 2402 atom = Indx[Obj.GetId()] 2403 Ax = Obj.GetValue() 2404 G2plt.ModulationPlot(G2frame,data,atom,Ax) 2405 2406 atomSizer = wx.BoxSizer(wx.HORIZONTAL) 2407 atomSizer.Add(wx.StaticText(waveData,label= 2408 ' Modulation data for atom: %s Site sym: %s WaveType: '%(atom[0],atom[cs].strip())),0,WACV) 2409 waveType = wx.ComboBox(waveData,value=atom[-1]['SS1']['waveType'],choices=waveTypes, 2410 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2411 waveType.Bind(wx.EVT_COMBOBOX,OnWaveType) 2412 atomSizer.Add(waveType,0,WACV) 2413 axchoice = ['x','y','z'] 2414 if len(D4Map['rho']): 2415 atomSizer.Add(wx.StaticText(waveData,label=' Show contour map for axis: '),0,WACV) 2416 mapSel = wx.ComboBox(waveData,value=' ',choices=axchoice, 2417 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2418 mapSel.Bind(wx.EVT_COMBOBOX,OnShowWave) 2419 Indx[mapSel.GetId()] = atom 2420 atomSizer.Add(mapSel,0,WACV) 2421 return atomSizer 2422 2423 def WaveSizer(iatm,waveType,waveBlk,Stype,typeName,Names): 2424 2425 def OnAddWave(event): 2426 Obj = event.GetEventObject() 2427 iatm,item = Indx[Obj.GetId()] 2428 nt = numVals[Stype] 2429 if not len(atomData[iatm][-1]['SS1'][item]) and waveType in ['ZigZag','Block'] and Stype == 'Spos': 2430 nt = numVals[waveType] 2431 atomData[iatm][-1]['SS1'][item].append([[0.0 for i in range(nt)],False]) 2432 RepaintAtomInfo(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2433 2434 def OnWaveVal(event): 2435 Obj = event.GetEventObject() 2436 iatm,item,iwave,ival = Indx[Obj.GetId()] 2437 try: 2438 val = float(Obj.GetValue()) 2439 if waveType in ['ZigZag','Block'] and Stype == 'Spos' and ival < 2 and not iwave: 2440 if ival == 1: #Tmax 2441 val = min(1.0,max(0.0,val)) 2442 elif ival == 0: #Tmin 2443 val = max(-1.,min(val,atomData[iatm][-1]['SS1'][item][iwave][0][1])) 2444 except ValueError: 2445 val = atomData[iatm][-1]['SS1'][item][iwave][0][ival] 2446 Obj.SetValue('%.5f'%val) 2447 atomData[iatm][-1]['SS1'][item][iwave][0][ival] = val 2448 2449 def OnRefWave(event): 2450 Obj = event.GetEventObject() 2451 iatm,item,iwave = Indx[Obj.GetId()] 2452 atomData[iatm][-1]['SS1'][item][iwave][1] = not atomData[iatm][-1]['SS1'][item][iwave][1] 2453 2454 def OnDelWave(event): 2455 Obj = event.GetEventObject() 2456 iatm,item,iwave = Indx[Obj.GetId()] 2457 del atomData[iatm][-1]['SS1'][item][iwave] 2458 RepaintAtomInfo(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2459 2460 waveSizer = wx.BoxSizer(wx.VERTICAL) 2461 waveHead = wx.BoxSizer(wx.HORIZONTAL) 2462 waveHead.Add(wx.StaticText(waveData,label=typeName+' modulation parameters: '),0,WACV) 2463 waveAdd = wx.CheckBox(waveData,label='Add wave?') 2464 waveAdd.Bind(wx.EVT_CHECKBOX, OnAddWave) 2465 Indx[waveAdd.GetId()] = [iatm,Stype] 2466 waveHead.Add(waveAdd,0,WACV) 2467 waveSizer.Add(waveHead) 2468 if len(waveBlk): 2469 nx = 0 2470 for iwave,wave in enumerate(waveBlk): 2471 if not iwave: 2472 if waveType in ['ZigZag','Block']: 2473 nx = 1 2474 CSI = G2spc.GetSSfxuinel(waveType,1,xyz,SGData,SSGData) 2475 else: 2476 CSI = G2spc.GetSSfxuinel('Fourier',iwave+1-nx,xyz,SGData,SSGData) 2477 waveName = 'Fourier' 2478 if Stype == 'Sfrac': 2479 if 'Crenel' in waveType and not iwave: 2480 waveName = 'Crenel' 2481 names = Names[2:] 2482 else: 2483 names = Names[:2] 2484 Waves = wx.FlexGridSizer(0,4,5,5) 2485 elif Stype == 'Spos': 2486 if waveType in ['ZigZag','Block'] and not iwave: 2487 names = Names[6:] 2488 Waves = wx.FlexGridSizer(0,7,5,5) 2489 waveName = waveType 2490 else: 2491 names = Names[:6] 2492 Waves = wx.FlexGridSizer(0,8,5,5) 2493 else: 2494 names = Names 2495 Waves = wx.FlexGridSizer(0,8,5,5) 2496 waveSizer.Add(wx.StaticText(waveData,label=' %s parameters: %s'%(waveName,str(names).rstrip(']').lstrip('[').replace("'",''))),0,WACV) 2497 for ival,val in enumerate(wave[0]): 2498 if np.any(CSI[Stype][0][ival]): 2499 waveVal = wx.TextCtrl(waveData,value='%.5f'%(val),style=wx.TE_PROCESS_ENTER) 2500 waveVal.Bind(wx.EVT_TEXT_ENTER,OnWaveVal) 2501 waveVal.Bind(wx.EVT_KILL_FOCUS,OnWaveVal) 2502 Indx[waveVal.GetId()] = [iatm,Stype,iwave,ival] 2503 else: 2504 waveVal = wx.TextCtrl(waveData,value='%.5f'%(val),style=wx.TE_READONLY) 2505 waveVal.SetBackgroundColour(VERY_LIGHT_GREY) 2506 Waves.Add(waveVal,0,WACV) 2507 if len(wave[0]) > 6 and ival == 5: 2508 Waves.Add((5,5),0) 2509 Waves.Add((5,5),0) 2510 waveRef = wx.CheckBox(waveData,label='Refine?') 2511 waveRef.SetValue(wave[1]) 2512 Indx[waveRef.GetId()] = [iatm,Stype,iwave] 2513 waveRef.Bind(wx.EVT_CHECKBOX, OnRefWave) 2514 Waves.Add(waveRef,0,WACV) 2515 if iwave < len(waveBlk)-1: 2516 Waves.Add((5,5),0) 2517 else: 2518 waveDel = wx.CheckBox(waveData,label='Delete?') 2519 Indx[waveDel.GetId()] = [iatm,Stype,iwave] 2520 waveDel.Bind(wx.EVT_CHECKBOX, OnDelWave) 2521 Waves.Add(waveDel,0,WACV) 2522 waveSizer.Add(Waves) 2523 return waveSizer 2524 2525 iatm = atNames.index(G2frame.atmSel) 2526 atm = atomData[iatm] 2527 xyz = atm[cx:cx+3] 2528 uij = atm[cia+2:cia+8] 2529 atomSizer = wx.BoxSizer(wx.VERTICAL) 2530 G2G.HorizontalLine(atomSizer,waveData) 2531 atomSizer.Add(AtomSizer(atm)) 2532 for Stype in ['Sfrac','Spos','Sadp','Smag']: 2533 if atm[cia] != 'A' and Stype == 'Sadp': #Uiso can't have modulations! (why not?) 2534 continue 2535 if generalData['Type'] != 'magnetic' and Stype == 'Smag': 2536 break 2537 atomSizer.Add(WaveSizer(iatm,atm[-1]['SS1']['waveType'],atm[-1]['SS1'][Stype],Stype,typeNames[Stype],Labels[Stype])) 2538 return atomSizer 2539 2540 2541 atms = wx.ComboBox(waveData,value=G2frame.atmSel,choices=atNames, 2542 style=wx.CB_READONLY|wx.CB_DROPDOWN) 2543 atms.Bind(wx.EVT_COMBOBOX,OnAtmSel) 2544 topSizer.Add(atms,0,WACV) 2545 mainSizer.Add(topSizer,0,WACV) 2546 G2frame.bottomSizer = ShowAtomInfo() 2547 mainSizer.Add(G2frame.bottomSizer) 2513 2548 2514 2549 SetPhaseWindow(G2frame.dataFrame,G2frame.waveData,mainSizer,Scroll)
Note: See TracChangeset
for help on using the changeset viewer.