Changeset 1630
- Timestamp:
- Jan 13, 2015 4:01:13 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r1626 r1630 42 42 atand = lambda x: 180.*np.arctan(x)/np.pi 43 43 atan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi 44 twopi = 2.0*np.pi 45 twopisq = 2.0*np.pi**2 44 46 45 47 ################################################################################ … … 704 706 Xanom[El] = G2el.FPcalc(Orbs, kE) 705 707 return Xanom 708 709 def Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata): 710 import scipy.special as sp 711 for iwt,wt in enumerate(waveTypes): #atom loop! 712 if wt == 'Fourier': 713 A = np.array([[a,b] for a,b in zip(XSSdata[:3],XSSdata[3:])]) 714 HdotA = twopi*np.inner(A.T,SSUniq.T[:3].T) 715 m = SSUniq.T[3] 716 Gp = sp.jn(-m,HdotA) 717 return np.real(Gp),np.imag(Gp) 706 718 707 719 def posFourier(tau,psin,pcos): … … 2885 2897 ''' 2886 2898 2887 twopi = 2.0*np.pi2888 2899 global tsum 2889 2900 tsum = 0. -
trunk/GSASIIplot.py
r1628 r1630 2799 2799 elif event.key == '-': 2800 2800 Off -= 1 2801 elif event.key in ['l','r',] :2801 elif event.key in ['l','r',] and mapData['Flip']: 2802 2802 roll = 1 2803 2803 if event.key == 'l': … … 2820 2820 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2821 2821 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 2822 2823 Page.Choice = ['+: shift up','-: shift down','0: reset shift','l: move left','r: move right'] 2824 Page.keyPress = OnPlotKeyPress 2822 2825 2823 Page.SetFocus() 2826 2824 General = data['General'] 2827 2825 cx,ct,cs,cia = General['AtomPtrs'] 2826 mapData = General['Map'] 2827 if mapData['Flip']: 2828 Page.Choice = ['+: shift up','-: shift down','0: reset shift','l: move left','r: move right'] 2829 else: 2830 Page.Choice = ['+: shift up','-: shift down','0: reset shift'] 2831 Page.keyPress = OnPlotKeyPress 2828 2832 Map = General['4DmapData'] 2829 2833 MapType = Map['MapType'] -
trunk/GSASIIspc.py
r1625 r1630 1456 1456 CSI['Sadp'][0] = [0,0,0,0,0,0, 1,2,3,4,5,6] 1457 1457 return CSI 1458 return CSI #for now1459 1458 # print siteSym,OpText,SSOptext 1460 1459 UniqAx = {'a':'a','b':'b','c':'g'} -
trunk/GSASIIstrIO.py
r1625 r1630 1135 1135 eqv[1] /= coef 1136 1136 G2mv.StoreEquivalence(name,equiv[1:]) 1137 maxSSwave[pfx][Stype] = max(maxSSwave[ Stype],iw+1)1137 maxSSwave[pfx][Stype] = max(maxSSwave[pfx][Stype],iw+1) 1138 1138 textureData = General['SH Texture'] 1139 1139 if textureData['Order']: … … 1447 1447 line += ' Mx My Mz' 1448 1448 elif General['Type'] == 'macromolecular': 1449 line = ' res no residuechain '+line1449 line = ' res no residue chain '+line 1450 1450 cx,ct,cs,cia = General['AtomPtrs'] 1451 1451 print >>pFile,line 1452 if General['Type'] == 'nuclear': 1453 print >>pFile,135*'-' 1454 fmt = {0:'%7s',1:'%7s',3:'%10.5f',4:'%10.5f',5:'%10.5f',6:'%8.3f',10:'%8.5f', 1455 11:'%8.5f',12:'%8.5f',13:'%8.5f',14:'%8.5f',15:'%8.5f',16:'%8.5f'} 1456 noFXsig = {3:[10*' ','%10s'],4:[10*' ','%10s'],5:[10*' ','%10s'],6:[8*' ','%8s']} 1457 for atyp in General['AtomTypes']: #zero composition 1458 General['NoAtoms'][atyp] = 0. 1459 for i,at in enumerate(Atoms): 1460 General['NoAtoms'][at[1]] += at[6]*float(at[8]) #new composition 1461 name = fmt[0]%(at[0])+fmt[1]%(at[1])+':' 1452 print >>pFile,135*'-' 1453 fmt = {0:'%7s',ct:'%7s',cx:'%10.5f',cx+1:'%10.5f',cx+2:'%10.5f',cx+3:'%8.3f',cia+1:'%8.5f', 1454 cia+2:'%8.5f',cia+3:'%8.5f',cia+4:'%8.5f',cia+5:'%8.5f',cia+6:'%8.5f',cia+7:'%8.5f'} 1455 noFXsig = {cx:[10*' ','%10s'],cx+1:[10*' ','%10s'],cx+2:[10*' ','%10s'],cx+3:[8*' ','%8s']} 1456 for atyp in General['AtomTypes']: #zero composition 1457 General['NoAtoms'][atyp] = 0. 1458 for i,at in enumerate(Atoms): 1459 General['NoAtoms'][at[ct]] += at[cx+3]*float(at[cx+5]) #new composition 1460 if General['Type'] == 'macromolecular': 1461 name = ' %s %s %s %s:'%(at[0],at[1],at[2],at[3]) 1462 valstr = ' values: ' 1463 sigstr = ' sig : ' 1464 else: 1465 name = fmt[0]%(at[ct-1])+fmt[1]%(at[ct])+':' 1462 1466 valstr = ' values:' 1463 1467 sigstr = ' sig :' 1464 for ind in [3,4,5,6]: 1468 for ind in range(cx,cx+4): 1469 sigind = str(i)+':'+str(ind) 1470 valstr += fmt[ind]%(at[ind]) 1471 if sigind in atomsSig: 1472 sigstr += fmt[ind]%(atomsSig[sigind]) 1473 else: 1474 sigstr += noFXsig[ind][1]%(noFXsig[ind][0]) 1475 if at[cia] == 'I': 1476 valstr += fmt[cia+1]%(at[cia+1]) 1477 if '%d:%d'%(i,cia+1) in atomsSig: 1478 sigstr += fmt[cia+1]%(atomsSig['%d:%d'%(i,cia+1)]) 1479 else: 1480 sigstr += 8*' ' 1481 else: 1482 valstr += 8*' ' 1483 sigstr += 8*' ' 1484 for ind in range(cia+2,cia+7): 1465 1485 sigind = str(i)+':'+str(ind) 1466 valstr += fmt[ind]%(at[ind]) 1467 if sigind in atomsSig: 1486 valstr += fmt[ind]%(at[ind]) 1487 if sigind in atomsSig: 1468 1488 sigstr += fmt[ind]%(atomsSig[sigind]) 1469 1489 else: 1470 sigstr += noFXsig[ind][1]%(noFXsig[ind][0])1471 if at[9] == 'I':1472 valstr += fmt[10]%(at[10])1473 if str(i)+':10' in atomsSig:1474 sigstr += fmt[10]%(atomsSig[str(i)+':10'])1475 else:1476 1490 sigstr += 8*' ' 1477 else: 1478 valstr += 8*' ' 1479 sigstr += 8*' ' 1480 for ind in [11,12,13,14,15,16]: 1481 sigind = str(i)+':'+str(ind) 1482 valstr += fmt[ind]%(at[ind]) 1483 if sigind in atomsSig: 1484 sigstr += fmt[ind]%(atomsSig[sigind]) 1485 else: 1486 sigstr += 8*' ' 1487 print >>pFile,name 1488 print >>pFile,valstr 1489 print >>pFile,sigstr 1491 print >>pFile,name 1492 print >>pFile,valstr 1493 print >>pFile,sigstr 1494 1495 def PrintWavesAndSig(General,Atoms,wavesSig): 1496 cx,ct,cs,cia = General['AtomPtrs'] 1497 print >>pFile,'\n Modulation waves' 1498 # names = {'Sfrac':['Fsin','Fcos','Fzero','Fwid'],'Spos':['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tzero','Xslope','Yslope','Zslope'], 1499 # 'Sadp':['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin','U11cos','U22cos', 1500 # 'U33cos','U12cos','U13cos','U23cos'],'Smag':['MXsin','MYsin','MZsin','MXcos','MYcos','MZcos']} 1501 # print >>pFile,135*'-' 1502 # for i,at in enumerate(Atoms): 1503 # AtomSS = at[-1]['SS1'] 1504 # for Stype in ['Sfrac','Spos','Sadp','Smag']: 1505 # Waves = AtomSS[Stype] 1506 # if len(Waves): 1507 # print >>pFile,' atom: %s, site sym: %s, type: %s wave type: %s:' \ 1508 # %(at[ct-1],at[cs],Stype,AtomSS['waveType']) 1509 # line = '' 1510 # for item in names[Stype]: 1511 # line += '%8s '%(item) 1512 # print >>pFile,line 1513 # for wave in Waves: 1514 # line = '' 1515 # for item in wave[0]: 1516 # line += '%8.4f '%(item) 1517 # line += ' Refine? '+str(wave[1]) 1518 # print >>pFile,line 1519 1490 1520 1491 1521 def PrintRBObjPOAndSig(rbfx,rbsx): … … 1720 1750 PrintRBObjTorAndSig(rbsx) 1721 1751 atomsSig = {} 1722 if General['Type'] == 'nuclear': #this needs macromolecular variant! 1723 for i,at in enumerate(Atoms): 1724 names = {3:pfx+'Ax:'+str(i),4:pfx+'Ay:'+str(i),5:pfx+'Az:'+str(i),6:pfx+'Afrac:'+str(i), 1725 10:pfx+'AUiso:'+str(i),11:pfx+'AU11:'+str(i),12:pfx+'AU22:'+str(i),13:pfx+'AU33:'+str(i), 1726 14:pfx+'AU12:'+str(i),15:pfx+'AU13:'+str(i),16:pfx+'AU23:'+str(i)} 1727 for ind in [3,4,5,6]: 1752 wavesSig = {} 1753 cx,ct,cs,cia = General['AtomPtrs'] 1754 for i,at in enumerate(Atoms): 1755 names = {cx:pfx+'Ax:'+str(i),cx+1:pfx+'Ay:'+str(i),cx+2:pfx+'Az:'+str(i),cx+3:pfx+'Afrac:'+str(i), 1756 cia+1:pfx+'AUiso:'+str(i),cia+2:pfx+'AU11:'+str(i),cia+3:pfx+'AU22:'+str(i),cia+4:pfx+'AU33:'+str(i), 1757 cia+5:pfx+'AU12:'+str(i),cia+6:pfx+'AU13:'+str(i),cia+7:pfx+'AU23:'+str(i)} 1758 for ind in range(cx,cx+4): 1759 at[ind] = parmDict[names[ind]] 1760 if ind in range(cx,cx+3): 1761 name = names[ind].replace('A','dA') 1762 else: 1763 name = names[ind] 1764 if name in sigDict: 1765 atomsSig[str(i)+':'+str(ind)] = sigDict[name] 1766 if at[cia] == 'I': 1767 at[cia+1] = parmDict[names[cia+1]] 1768 if names[cia+1] in sigDict: 1769 atomsSig['%d:%d'%(i,cia+1)] = sigDict[names[cia+1]] 1770 else: 1771 for ind in range(cia+2,cia+8): 1728 1772 at[ind] = parmDict[names[ind]] 1729 if ind in [3,4,5]: 1730 name = names[ind].replace('A','dA') 1731 else: 1732 name = names[ind] 1733 if name in sigDict: 1734 atomsSig[str(i)+':'+str(ind)] = sigDict[name] 1735 if at[9] == 'I': 1736 at[10] = parmDict[names[10]] 1737 if names[10] in sigDict: 1738 atomsSig[str(i)+':10'] = sigDict[names[10]] 1739 else: 1740 for ind in [11,12,13,14,15,16]: 1741 at[ind] = parmDict[names[ind]] 1742 if names[ind] in sigDict: 1743 atomsSig[str(i)+':'+str(ind)] = sigDict[names[ind]] 1744 ind = General['AtomTypes'].index(at[1]) 1745 General['Mass'] += General['AtomMass'][ind]*at[6]*at[8] 1773 if names[ind] in sigDict: 1774 atomsSig[str(i)+':'+str(ind)] = sigDict[names[ind]] 1775 ind = General['AtomTypes'].index(at[ct]) 1776 General['Mass'] += General['AtomMass'][ind]*at[cx+3]*at[cx+5] 1777 if General['Type'] in ['modulated','magnetic']: 1778 AtomSS = at[-1]['SS1'] 1779 waveType = AtomSS['waveType'] 1780 for Stype in ['Sfrac','Spos','Sadp','Smag']: 1781 Waves = AtomSS[Stype] 1782 for iw,wave in enumerate(Waves): 1783 stiw = str(i)+':'+str(iw) 1784 if Stype == 'Spos': 1785 if waveType in ['ZigZag','Sawtooth'] and not iw: 1786 names = [pfx+'Tzero:'+stiw,pfx+'Xslope:'+stiw,pfx+'Yslope:'+stiw,pfx+'Zslope:'+stiw] 1787 else: 1788 names = [pfx+'Xsin:'+stiw,pfx+'Ysin:'+stiw,pfx+'Zsin:'+stiw, 1789 pfx+'Xcos:'+stiw,pfx+'Ycos:'+stiw,pfx+'Zcos:'+stiw] 1790 elif Stype == 'Sadp': 1791 names = [pfx+'U11sin:'+stiw,pfx+'U22sin:'+stiw,pfx+'U33sin:'+stiw, 1792 pfx+'U12sin:'+stiw,pfx+'U13sin:'+stiw,pfx+'U23sin:'+stiw, 1793 pfx+'U11cos:'+stiw,pfx+'U22cos:'+stiw,pfx+'U33cos:'+stiw, 1794 pfx+'U12cos:'+stiw,pfx+'U13cos:'+stiw,pfx+'U23cos:'+stiw] 1795 elif Stype == 'Sfrac': 1796 if 'Crenel' in waveType and not iw: 1797 names = [pfx+'Fzero:'+stiw,pfx+'Fwid:'+stiw] 1798 else: 1799 names = [pfx+'Fsin:'+stiw,pfx+'Fcos:'+stiw] 1800 elif Stype == 'Smag': 1801 names = [pfx+'MXsin:'+stiw,pfx+'MYsin:'+stiw,pfx+'MZsin:'+stiw, 1802 pfx+'MXcos:'+stiw,pfx+'MYcos:'+stiw,pfx+'MZcos:'+stiw] 1803 for iname,name in enumerate(names): 1804 AtomSS[Stype][iw][0][iname] = parmDict[name] 1805 if name in sigDict: 1806 wavesSig[name] = sigDict[name] 1807 1746 1808 PrintAtomsAndSig(General,Atoms,atomsSig) 1809 if General['Type'] in ['modulated','magnetic']: 1810 PrintWavesAndSig(General,Atoms,wavesSig) 1811 1747 1812 1748 1813 textureData = General['SH Texture'] -
trunk/GSASIIstrMath.py
r1625 r1630 36 36 37 37 ateln2 = 8.0*math.log(2.0) 38 twopi = 2.0*np.pi 39 twopisq = 2.0*np.pi**2 38 40 39 41 ################################################################################ … … 539 541 maxSSwave = calcControls['maxSSwave'][pfx] 540 542 Nwave = {'F':maxSSwave['Sfrac'],'X':maxSSwave['Spos'],'Y':maxSSwave['Spos'],'Z':maxSSwave['Spos'], 541 'U':maxSSwave['Sadp'],'M':maxSSwave['Smag'] }543 'U':maxSSwave['Sadp'],'M':maxSSwave['Smag'],'T':maxSSwave['Spos']} 542 544 XSSdata = np.zeros((6,maxSSwave['Spos'],Natoms)) 543 545 FSSdata = np.zeros((2,maxSSwave['Sfrac'],Natoms)) 544 546 USSdata = np.zeros((12,maxSSwave['Sadp'],Natoms)) 545 547 MSSdata = np.zeros((6,maxSSwave['Smag'],Natoms)) 548 waveTypes = [] 546 549 keys = {'Fsin:':FSSdata[0],'Fcos:':FSSdata[1],'Fzero:':FSSdata[0],'Fwid:':FSSdata[1], 547 550 'Tzero:':XSSdata[0],'Xslope:':XSSdata[1],'Yslope:':XSSdata[2],'Zslope:':XSSdata[3], … … 551 554 'MXsin:':MSSdata[0],'MYsin:':MSSdata[1],'MZsin:':MSSdata[2],'MXcos:':MSSdata[3],'MYcos:':MSSdata[4],'MZcos:':MSSdata[5]} 552 555 for iatm in range(Natoms): 556 waveTypes.append(parmDict[pfx+'waveType:'+str(iatm)]) 553 557 for key in keys: 554 558 for m in range(Nwave[key[0]]): 555 559 parm = pfx+key+str(iatm)+':%d'%(m) 556 560 if parm in parmDict: 557 keys[key][ iatm] = parmDict[parm]558 return FSSdata,XSSdata,USSdata,MSSdata561 keys[key][m][iatm] = parmDict[parm] 562 return waveTypes,FSSdata.squeeze(),XSSdata.squeeze(),USSdata.squeeze(),MSSdata.squeeze() 559 563 560 564 def StructureFactor(refDict,G,hfx,pfx,SGData,calcControls,parmDict): … … 574 578 575 579 ''' 576 twopi = 2.0*np.pi577 twopisq = 2.0*np.pi**2578 580 phfx = pfx.split(':')[0]+hfx 579 581 ast = np.sqrt(np.diag(G)) … … 636 638 refl[10] = atan2d(fbs[0],fas[0]) 637 639 638 def SStructureFactor(refDict,im,G,hfx,pfx,SGData, calcControls,parmDict):640 def SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict): 639 641 ''' 640 642 Compute super structure factors for all h,k,l,m for phase … … 652 654 653 655 ''' 654 twopi = 2.0*np.pi655 twopisq = 2.0*np.pi**2656 656 phfx = pfx.split(':')[0]+hfx 657 657 ast = np.sqrt(np.diag(G)) … … 664 664 BLtables = calcControls['BLtables'] 665 665 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 666 SSFdata,SSXdata,SSUdata,SSMdata = GetAtomSSFXU(pfx,calcControls,parmDict)666 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 667 667 FF = np.zeros(len(Tdata)) 668 668 if 'NC' in calcControls[hfx+'histType']: … … 701 701 Phi = np.inner(H[:3],SGT) 702 702 SSPhi = np.inner(H,SSGT) 703 703 GfpuA,GfpuB = G2mth.Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata) 704 704 phase = twopi*(np.inner(Uniq,(dXdata.T+Xdata.T))+Phi[:,np.newaxis]) 705 705 sinp = np.sin(phase) … … 711 711 Tcorr = Tiso*Tuij*Mdata*Fdata/len(Uniq) 712 712 fa = np.array([(FF+FP-Bab)*cosp*Tcorr,-FPP*sinp*Tcorr]) 713 f as = np.sum(np.sum(fa,axis=1),axis=1) #real713 fb = 0. 714 714 if not SGData['SGInv']: 715 715 fb = np.array([(FF+FP-Bab)*sinp*Tcorr,FPP*cosp*Tcorr]) 716 fbs = np.sum(np.sum(fb,axis=1),axis=1) 716 fa = fa*GfpuA.T-fb*GfpuB.T 717 fb = fb*GfpuA.T+fa*GfpuB.T 718 fas = np.sum(np.sum(fa,axis=1),axis=1) #real 719 fbs = np.sum(np.sum(fb,axis=1),axis=1) 717 720 718 721 fasq = fas**2 … … 736 739 737 740 ''' 738 twopi = 2.0*np.pi739 twopisq = 2.0*np.pi**2740 741 phfx = pfx.split(':')[0]+hfx 741 742 ast = np.sqrt(np.diag(G)) … … 813 814 def StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 814 815 'Needs a doc string' 815 twopi = 2.0*np.pi816 twopisq = 2.0*np.pi**2817 816 phfx = pfx.split(':')[0]+hfx 818 817 ast = np.sqrt(np.diag(G)) … … 911 910 return dFdvDict 912 911 913 def SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData, calcControls,parmDict):912 def SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict): 914 913 'Needs a doc string' 915 twopi = 2.0*np.pi916 twopisq = 2.0*np.pi**2917 914 phfx = pfx.split(':')[0]+hfx 918 915 ast = np.sqrt(np.diag(G)) … … 920 917 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 921 918 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 919 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 920 SSGT = np.array([ops[1] for ops in SSGData['SSGOps']]) 922 921 FFtables = calcControls['FFtables'] 923 922 BLtables = calcControls['BLtables'] 924 923 nRef = len(refDict['RefList']) 925 924 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 925 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 926 926 mSize = len(Mdata) 927 927 FF = np.zeros(len(Tdata)) … … 951 951 Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata]) 952 952 FF = refDict['FF']['FF'][iref].T[Tindx] 953 Uniq = np.inner(H,SGMT) 954 Phi = np.inner(H,SGT) 953 Uniq = np.inner(H[:3],SGMT) 954 SSUniq = np.inner(H,SSGMT) 955 Phi = np.inner(H[:3],SGT) 956 SSPhi = np.inner(H,SSGT) 957 GfpuA,GfpuB = G2mth.Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata) 955 958 phase = twopi*(np.inner((dXdata.T+Xdata.T),Uniq)+Phi[np.newaxis,:]) 956 959 sinp = np.sin(phase) … … 1880 1883 time0 = time.time() 1881 1884 if im: 1882 SStructureFactor(refDict,im,G,hfx,pfx,SGData, calcControls,parmDict)1885 SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) 1883 1886 else: 1884 1887 StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict) … … 2059 2062 time0 = time.time() 2060 2063 if im: 2061 dFdvDict = S tructureFactorDerv(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)2064 dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) 2062 2065 else: 2063 2066 dFdvDict = StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict) … … 2300 2303 refDict = Histogram['Data'] 2301 2304 if im: 2302 dFdvDict = S tructureFactorDerv(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)2305 dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) 2303 2306 else: 2304 2307 dFdvDict = StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict) … … 2573 2576 time0 = time.time() 2574 2577 if im: 2575 SStructureFactor(refDict,im,G,hfx,pfx,SGData, calcControls,parmDict)2578 SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) 2576 2579 else: 2577 2580 StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict) -
trunk/exports/G2export_csv.py
r1261 r1630 161 161 print('Histogram '+str(hist)+' written to file '+str(self.fullpath)) 162 162 163 class ExportMultiPowderCSV(G2IO.ExportBaseclass): 164 '''Used to create a csv file for a stack of powder data sets suitable for display 165 purposes only; no y-calc or weights are exported only x & y-obs 166 :param wx.Frame G2frame: reference to main GSAS-II frame 167 ''' 168 def __init__(self,G2frame): 169 super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__ 170 G2frame=G2frame, 171 formatName = 'stacked CSV file', 172 extension='.csv', 173 longFormatName = 'Export powder data sets as a (csv) file - x,y-o1,y-o2,... only' 174 ) 175 self.exporttype = ['powder'] 176 #self.multiple = False # only allow one histogram to be selected 177 self.multiple = True 178 179 def Exporter(self,event=None): 180 '''Export a set of powder data as a csv file 181 ''' 182 # the export process starts here 183 self.InitExport(event) 184 # load all of the tree into a set of dicts 185 self.loadTree() 186 if self.ExportSelect( # set export parameters 187 AskFile='single' # get a file name/directory to save in 188 ): return 189 filenamelist = [] 190 csvData = [] 191 headList = ["x",] 192 digitList = [] 193 fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(self.histnam[0]),filenamelist) 194 # create an instrument parameter file 195 self.filename = os.path.join(self.dirname,fileroot + self.extension) 196 for ihst,hist in enumerate(self.histnam): 197 histblk = self.Histograms[hist] 198 headList.append('y_obs_'+str(ihst)) 199 if not ihst: 200 digitList = [(13,3),] 201 csvData.append(histblk['Data'][0]) 202 digitList += [(13,3),] 203 csvData.append(histblk['Data'][1]) 204 print('Histogram '+str(hist)+' written to file '+str(self.fullpath)) 205 self.OpenFile() 206 WriteList(self,headList) 207 for vallist in np.array(csvData).T: 208 line = "" 209 for val,digits in zip(vallist,digitList): 210 if line: line += ',' 211 line += G2py3.FormatValue(val,digits) 212 self.Write(line) 213 self.CloseFile() 214 163 215 class ExportPowderReflCSV(G2IO.ExportBaseclass): 164 216 '''Used to create a csv file of reflections from a powder data set
Note: See TracChangeset
for help on using the changeset viewer.