Changeset 1630


Ignore:
Timestamp:
Jan 13, 2015 4:01:13 PM (8 years ago)
Author:
vondreele
Message:

add export routine for tables of x,y0,y1,y2,... for multiple powder data sets - apparently useful for plotting in Excel, etc.
implement SS structure factor calcs for position modulation - Fourier only
working on printing wave results

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r1626 r1630  
    4242atand = lambda x: 180.*np.arctan(x)/np.pi
    4343atan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi
     44twopi = 2.0*np.pi
     45twopisq = 2.0*np.pi**2
    4446   
    4547################################################################################
     
    704706        Xanom[El] = G2el.FPcalc(Orbs, kE)
    705707    return Xanom
     708   
     709def 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)
    706718   
    707719def posFourier(tau,psin,pcos):
     
    28852897    '''
    28862898   
    2887     twopi = 2.0*np.pi
    28882899    global tsum
    28892900    tsum = 0.
  • trunk/GSASIIplot.py

    r1628 r1630  
    27992799        elif event.key == '-':
    28002800            Off -= 1
    2801         elif event.key in ['l','r',]:
     2801        elif event.key in ['l','r',] and mapData['Flip']:
    28022802            roll = 1
    28032803            if  event.key == 'l':
     
    28202820        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    28212821        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   
    28252823    Page.SetFocus()
    28262824    General = data['General']
    28272825    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
    28282832    Map = General['4DmapData']
    28292833    MapType = Map['MapType']
  • trunk/GSASIIspc.py

    r1625 r1630  
    14561456        CSI['Sadp'][0] = [0,0,0,0,0,0, 1,2,3,4,5,6]
    14571457        return CSI
    1458     return CSI  #for now       
    14591458#    print siteSym,OpText,SSOptext   
    14601459    UniqAx = {'a':'a','b':'b','c':'g'}
  • trunk/GSASIIstrIO.py

    r1625 r1630  
    11351135                                            eqv[1] /= coef
    11361136                                        G2mv.StoreEquivalence(name,equiv[1:])
    1137                             maxSSwave[pfx][Stype] = max(maxSSwave[Stype],iw+1)
     1137                            maxSSwave[pfx][Stype] = max(maxSSwave[pfx][Stype],iw+1)
    11381138            textureData = General['SH Texture']
    11391139            if textureData['Order']:
     
    14471447            line += '   Mx     My     Mz'
    14481448        elif General['Type'] == 'macromolecular':
    1449             line = ' res no  residue chain '+line
     1449            line = ' res no residue chain '+line
    14501450        cx,ct,cs,cia = General['AtomPtrs']
    14511451        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])+':'
    14621466                valstr = ' values:'
    14631467                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):
    14651485                    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:                       
    14681488                        sigstr += fmt[ind]%(atomsSig[sigind])
    14691489                    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:
    14761490                        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       
    14901520               
    14911521    def PrintRBObjPOAndSig(rbfx,rbsx):
     
    17201750                PrintRBObjTorAndSig(rbsx)
    17211751            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):
    17281772                        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                   
    17461808            PrintAtomsAndSig(General,Atoms,atomsSig)
     1809            if General['Type'] in ['modulated','magnetic']:
     1810                PrintWavesAndSig(General,Atoms,wavesSig)
     1811           
    17471812       
    17481813        textureData = General['SH Texture']   
  • trunk/GSASIIstrMath.py

    r1625 r1630  
    3636   
    3737ateln2 = 8.0*math.log(2.0)
     38twopi = 2.0*np.pi
     39twopisq = 2.0*np.pi**2
    3840
    3941################################################################################
     
    539541    maxSSwave = calcControls['maxSSwave'][pfx]
    540542    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']}
    542544    XSSdata = np.zeros((6,maxSSwave['Spos'],Natoms))
    543545    FSSdata = np.zeros((2,maxSSwave['Sfrac'],Natoms))
    544546    USSdata = np.zeros((12,maxSSwave['Sadp'],Natoms))
    545547    MSSdata = np.zeros((6,maxSSwave['Smag'],Natoms))
     548    waveTypes = []
    546549    keys = {'Fsin:':FSSdata[0],'Fcos:':FSSdata[1],'Fzero:':FSSdata[0],'Fwid:':FSSdata[1],
    547550        'Tzero:':XSSdata[0],'Xslope:':XSSdata[1],'Yslope:':XSSdata[2],'Zslope:':XSSdata[3],
     
    551554        'MXsin:':MSSdata[0],'MYsin:':MSSdata[1],'MZsin:':MSSdata[2],'MXcos:':MSSdata[3],'MYcos:':MSSdata[4],'MZcos:':MSSdata[5]}
    552555    for iatm in range(Natoms):
     556        waveTypes.append(parmDict[pfx+'waveType:'+str(iatm)])
    553557        for key in keys:
    554558            for m in range(Nwave[key[0]]):
    555559                parm = pfx+key+str(iatm)+':%d'%(m)
    556560                if parm in parmDict:
    557                     keys[key][iatm] = parmDict[parm]
    558     return FSSdata,XSSdata,USSdata,MSSdata   
     561                    keys[key][m][iatm] = parmDict[parm]
     562    return waveTypes,FSSdata.squeeze(),XSSdata.squeeze(),USSdata.squeeze(),MSSdata.squeeze()   
    559563   
    560564def StructureFactor(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
     
    574578
    575579    '''       
    576     twopi = 2.0*np.pi
    577     twopisq = 2.0*np.pi**2
    578580    phfx = pfx.split(':')[0]+hfx
    579581    ast = np.sqrt(np.diag(G))
     
    636638        refl[10] = atan2d(fbs[0],fas[0])
    637639   
    638 def SStructureFactor(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict):
     640def SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict):
    639641    '''
    640642    Compute super structure factors for all h,k,l,m for phase
     
    652654
    653655    '''       
    654     twopi = 2.0*np.pi
    655     twopisq = 2.0*np.pi**2
    656656    phfx = pfx.split(':')[0]+hfx
    657657    ast = np.sqrt(np.diag(G))
     
    664664    BLtables = calcControls['BLtables']
    665665    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)
    667667    FF = np.zeros(len(Tdata))
    668668    if 'NC' in calcControls[hfx+'histType']:
     
    701701        Phi = np.inner(H[:3],SGT)
    702702        SSPhi = np.inner(H,SSGT)
    703        
     703        GfpuA,GfpuB = G2mth.Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata)       
    704704        phase = twopi*(np.inner(Uniq,(dXdata.T+Xdata.T))+Phi[:,np.newaxis])
    705705        sinp = np.sin(phase)
     
    711711        Tcorr = Tiso*Tuij*Mdata*Fdata/len(Uniq)
    712712        fa = np.array([(FF+FP-Bab)*cosp*Tcorr,-FPP*sinp*Tcorr])
    713         fas = np.sum(np.sum(fa,axis=1),axis=1)        #real
     713        fb = 0.
    714714        if not SGData['SGInv']:
    715715            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)
    717720           
    718721        fasq = fas**2
     
    736739
    737740    '''       
    738     twopi = 2.0*np.pi
    739     twopisq = 2.0*np.pi**2
    740741    phfx = pfx.split(':')[0]+hfx
    741742    ast = np.sqrt(np.diag(G))
     
    813814def StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
    814815    'Needs a doc string'
    815     twopi = 2.0*np.pi
    816     twopisq = 2.0*np.pi**2
    817816    phfx = pfx.split(':')[0]+hfx
    818817    ast = np.sqrt(np.diag(G))
     
    911910    return dFdvDict
    912911   
    913 def SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict):
     912def SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict):
    914913    'Needs a doc string'
    915     twopi = 2.0*np.pi
    916     twopisq = 2.0*np.pi**2
    917914    phfx = pfx.split(':')[0]+hfx
    918915    ast = np.sqrt(np.diag(G))
     
    920917    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    921918    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']])
    922921    FFtables = calcControls['FFtables']
    923922    BLtables = calcControls['BLtables']
    924923    nRef = len(refDict['RefList'])
    925924    Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict)
     925    waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict)
    926926    mSize = len(Mdata)
    927927    FF = np.zeros(len(Tdata))
     
    951951        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
    952952        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)       
    955958        phase = twopi*(np.inner((dXdata.T+Xdata.T),Uniq)+Phi[np.newaxis,:])
    956959        sinp = np.sin(phase)
     
    18801883            time0 = time.time()
    18811884            if im:
    1882                 SStructureFactor(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)
     1885                SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
    18831886            else:
    18841887                StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
     
    20592062            time0 = time.time()
    20602063            if im:
    2061                 dFdvDict = StructureFactorDerv(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)
     2064                dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
    20622065            else:
    20632066                dFdvDict = StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
     
    23002303    refDict = Histogram['Data']
    23012304    if im:
    2302         dFdvDict = StructureFactorDerv(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)
     2305        dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
    23032306    else:
    23042307        dFdvDict = StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
     
    25732576            time0 = time.time()
    25742577            if im:
    2575                 SStructureFactor(refDict,im,G,hfx,pfx,SGData,calcControls,parmDict)
     2578                SStructureFactor(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
    25762579            else:
    25772580                StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
  • trunk/exports/G2export_csv.py

    r1261 r1630  
    161161            print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
    162162
     163class 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
    163215class ExportPowderReflCSV(G2IO.ExportBaseclass):
    164216    '''Used to create a csv file of reflections from a powder data set
Note: See TracChangeset for help on using the changeset viewer.