Changeset 2546


Ignore:
Timestamp:
Nov 22, 2016 1:08:48 PM (7 years ago)
Author:
vondreele
Message:

cleanup of all GSASII main routines - remove unused variables, dead code, etc.

Location:
trunk
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r2492 r2546  
    1515
    1616import math
     17import sys
    1718import os.path
    1819import GSASIIpath
  • trunk/GSASIIElemGUI.py

    r2486 r2546  
    5959    def ElButton(self, name, pos, tip, color):
    6060        'Creates an element button widget'
    61         Black = wx.Colour(0,0,0)
    6261        if not self.ifNone and name[0] == 'None':
    6362            return
  • trunk/GSASIIIO.py

    r2544 r2546  
    602602    fileSize = os.stat(filename).st_size
    603603    Npix = (fileSize-6000)/2
    604     Head = File.read(6000)
     604    File.read(6000)
    605605    head = ['Rigaku R-Axis IV detector data',]
    606606    image = np.array(ar.array('H',File.read(fileSize-6000)),dtype=np.int32)
     
    24982498    trans = False
    24992499    Trans = []
    2500     instr = False
    25012500    for diff in lines:
    25022501        diff = diff[:-1].lower()
     
    25132512            continue
    25142513        if diff.strip() == 'instrumental':
    2515             instr = True
    25162514            continue
    25172515        if diff.strip() == 'structural':
    2518             instr = False
    25192516            struct = True
    25202517            continue
  • trunk/GSASIIconstrGUI.py

    r2544 r2546  
    1818import wx
    1919import wx.grid as wg
    20 import wx.lib.scrolledpanel as wxscroll
    21 import time
    2220import random as ran
    2321import numpy as np
     
    10881086        else: # called directly, get current page
    10891087            page = G2frame.dataDisplay.GetSelection()
    1090         oldPage = G2frame.dataDisplay.ChangeSelection(page)
     1088        G2frame.dataDisplay.ChangeSelection(page)
    10911089        text = G2frame.dataDisplay.GetPageText(page)
    10921090        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,False)
     
    12101208    opId = oldPhase['pId']
    12111209    npId = newPhase['pId']
    1212     oph = '%d::'%(opId)
    1213     nph = '%d::'%(npId)
    12141210    cx,ct,cs,cia = newPhase['General']['AtomPtrs']
    12151211    nAtoms = newPhase['Atoms']
    1216     oAtoms = oldPhase['Atoms']
    12171212    oSGData = oldPhase['General']['SGData']
    12181213    nSGData = newPhase['General']['SGData']
    12191214    oAcof = G2lat.cell2A(oldPhase['General']['Cell'][1:7])
    12201215    nAcof = G2lat.cell2A(newPhase['General']['Cell'][1:7])
    1221     oGmat = G2lat.cell2Gmat(oldPhase['General']['Cell'][1:7])[1]
    1222     nGmat = G2lat.cell2Gmat(newPhase['General']['Cell'][1:7])[1]
    12231216    item = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Constraints')
    12241217    constraints = G2frame.PatternTree.GetItemPyData(item)
     
    13311324        else:
    13321325            page = G2frame.dataDisplay.GetSelection()
    1333         oldPage = G2frame.dataDisplay.ChangeSelection(page)
     1326        G2frame.dataDisplay.ChangeSelection(page)
    13341327        text = G2frame.dataDisplay.GetPageText(page)
    13351328        if text == 'Vector rigid bodies':
     
    13671360       
    13681361    def getTextFile():
    1369         defDir = os.path.join(os.path.split(__file__)[0],'GSASIImacros')
    13701362        dlg = wx.FileDialog(G2frame,'Choose rigid body text file', '.', '',
    13711363            "GSAS-II text file (*.txt)|*.txt|XYZ file (*.xyz)|*.xyz|"
     
    18821874                    try:
    18831875                        val = float(vecGrid.GetCellValue(r,c))
    1884                         rbData['rbVect'][imag][r][c] = val
     1876                        rbData['rbXYZ'][r][c] = val
    18851877                    except ValueError:
    18861878                        pass
  • trunk/GSASIIctrls.py

    r2541 r2546  
    3535import GSASIIpath
    3636GSASIIpath.SetVersionNumber("$Revision$")
     37import GSASIIgrid as G2gd
    3738# import GSASIImath as G2mth
    3839# import GSASIIIO as G2IO
     
    681682        try:
    682683            val = self.typ(tc.GetValue())
    683         except (ValueError, SyntaxError) as e:
     684        except (ValueError, SyntaxError):
    684685            if self.typ is float: # for float values, see if an expression can be evaluated
    685686                val = G2py3.FormulaEval(tc.GetValue())
     
    16211622    else:
    16221623        refdictlst = None
    1623     Id = GetPatternTreeItemId(G2frame,G2frame.root,hst)
    1624     hstData = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,Id,'Instrument Parameters'))[0]
     1624    Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,hst)
     1625    hstData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Instrument Parameters'))[0]
    16251626    for h in copyList:
    1626         Id = GetPatternTreeItemId(G2frame,G2frame.root,h)
    1627         instData = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,Id,'Instrument Parameters'))[0]
     1627        Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,h)
     1628        instData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Instrument Parameters'))[0]
    16281629        if len(hstData) != len(instData) or hstData['Type'][0] != instData['Type'][0]:  #don't mix data types or lam & lam1/lam2 parms!
    16291630            print h+' not copied - instrument parameters not commensurate'
    16301631            continue
    1631         hData = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,Id,TreeItemType))
     1632        hData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,TreeItemType))
    16321633        if TreeItemType == 'Instrument Parameters':
    16331634            hData = hData[0]
     
    24712472    dlg.SetSizer(sizer)
    24722473    sizer.Fit(dlg)
    2473     val = dlg.ShowModal()
     2474    dlg.ShowModal()
    24742475
    24752476################################################################################
     
    29532954        self._tc.SetInsertionPointEnd()
    29542955
    2955     def Clone(self):
     2956    def Clone(self,grid):
    29562957        return GridFractionEditor(grid)
    29572958
     
    38193820def ShowHelp(helpType,frame):
    38203821    '''Called to bring up a web page for documentation.'''
    3821     global htmlFirstUse
     3822    global htmlFirstUse,htmlPanel,htmlFrame
    38223823    # look up a definition for help info from dict
    38233824    #helplink = helpLocDict.get(helpType)
     
    38613862    '''Called to show a tutorial web page.
    38623863    '''
    3863     global htmlFirstUse
     3864    global htmlFirstUse,htmlPanel,htmlFrame
    38643865    # determine if a web browser or the internal viewer should be used for help info
    38653866    if GSASIIpath.GetConfigValue('Help_mode'):
     
    41504151                GSASIIpath.svnUpdateDir(os.path.join(self.tutorialPath,i[0]))
    41514152            else:
    4152                 fullpath = os.path.join(self.tutorialPath,i[0],i[1])
    41534153                fulldir = os.path.join(self.tutorialPath,i[0])
    41544154                URL = G2BaseURL+'/Tutorials/'+i[0]+'/'
     
    42124212        print "Cancel"
    42134213    dlg.Destroy()
    4214     import sys; sys.exit()
     4214    sys.exit()
    42154215    #======================================================================
    42164216    # test ScrolledMultiEditor
  • trunk/GSASIIddataGUI.py

    r2495 r2546  
    2222import GSASIIlattice as G2lat
    2323import GSASIIspc as G2spc
    24 import GSASIIElem as G2elem
    25 import GSASIIElemGUI as G2elemGUI
    2624import GSASIIplot as G2plt
    2725import GSASIIgrid as G2gd
    28 import GSASIIIO as G2IO
    29 import GSASIImath as G2mth
    3026import GSASIIpwd as G2pwd
    3127import GSASIIphsGUI as G2phsGUI
     
    293289    def OnHstrainVal(event):
    294290        event.Skip()
    295         Snames = G2spc.HStrainNames(SGData)
    296291        Obj = event.GetEventObject()
    297292        hist,pid = Indx[Obj.GetId()]
     
    987982            h,k,l = hkl
    988983            Obj.SetValue('%3d %3d %3d'%(h,k,l))
    989                        
    990         try:
    991             histData = UseList[G2frame.hist]
    992         except KeyError:
     984
     985        if G2frame.hist not in UseList:               
    993986            G2frame.ErrorDialog('Missing data error',
    994987                    G2frame.hist+' not in GSAS-II data tree')
  • trunk/GSASIIexprGUI.py

    r2326 r2546  
    2424'''
    2525import re
    26 import sys
    2726import wx
    28 import os.path
    2927import wx.lib.scrolledpanel as wxscroll
    3028import numpy as np
     
    400398                try:
    401399                    float(val)
    402                 except ValueError,TypeError:
     400                except (ValueError,TypeError):
    403401                    invalid += 1
    404402                    if msg: msg += "; "
     
    953951    newobj = dlg.Show(True)
    954952    print dlg.GetDepVar()
    955     import sys
    956     #sys.exit()
    957953
    958954    #app.MainLoop()
  • trunk/GSASIIgrid.py

    r2544 r2546  
    2020import time
    2121import copy
    22 import cPickle
    2322import sys
    2423import os
    2524import random as ran
    2625import numpy as np
    27 import numpy.ma as ma
    2826import scipy.optimize as so
    2927import GSASIIpath
     
    252250        for line in text:
    253251            mainSizer.Add(wx.StaticText(self.panel,label='     %s     '%(line)),0,WACV)
    254         try:
    255             nops = self.names.index(' 1bar ')
    256         except ValueError:
    257             nops = len(self.names)
    258252        ncol = self.table[0].count(',')+2
    259253        for ic,cent in enumerate(cents):
     
    27022696            data['F**2'] = fsqRef.GetValue()
    27032697           
    2704         def OnHatomFix(event):
    2705             data['HatomFix'] = Hfix.GetValue()
     2698#        def OnHatomFix(event):
     2699#            data['HatomFix'] = Hfix.GetValue()
    27062700       
    27072701        def OnUsrRej(event):
     
    33793373        UseFlags = G2frame.SeqTable.GetColValues(0)         
    33803374        for obj in eqObjList:
    3381             expr = obj.expression
    33823375            # assemble refined vars for this equation
    33833376            varyValueDict.update({var:val for var,val in obj.GetVariedVarVal()})
     
    34903483            newobj = dlg.Show(True)
    34913484            if newobj:
    3492                 calcobj = G2obj.ExpressionCalcObj(newobj)
    34933485                Controls['SeqParFitEqList'][selected] = newobj
    34943486                EnableParFitEqMenus()
     
    35453537            newobj = dlg.Show(True)
    35463538            if newobj:
    3547                 calcobj = G2obj.ExpressionCalcObj(newobj)
    35483539                Controls['SeqParFitEqList'].append(newobj)
    35493540                EnableParFitEqMenus()
     
    38883879            G2mv.InitVars()
    38893880            parmDict = data[name].get('parmDict')
    3890             badVary = data[name].get('badVary',[])
    38913881            constraintInfo = data[name].get('constraintInfo',[[],[],{},[],seqnum])
    38923882            groups,parmlist,constrDict,fixedList,ihst = constraintInfo
     
    39713961    G2frame.dataDisplay = G2G.GSGrid(parent=G2frame.dataFrame)
    39723962    G2frame.SeqTable = G2G.Table(
    3973         [list(c) for c in zip(*colList)],     # convert from columns to rows
     3963        [list(cl) for cl in zip(*colList)],     # convert from columns to rows
    39743964        colLabels=colLabels,rowLabels=histNames,types=Types)
    39753965    G2frame.dataDisplay.SetTable(G2frame.SeqTable, True)
     
    40204010        inp[2] = (inp[1] - inp[0])/(len(data[1][0])-1.)
    40214011        names = ('start angle', 'end angle', 'step size')
    4022         dictlst = [inp] * len(inp)
    4023         elemlst = range(len(inp))
    40244012        dlg = G2G.ScrolledMultiEditor(
    40254013            G2frame,[inp] * len(inp), range(len(inp)), names,
     
    41164104        Comments.append(" Transformation M*H = H' applied; M=")
    41174105        Comments.append(str(Trans))
    4118         SG = 'P '+Laue
    4119         SGData = G2spc.SpcGroup(SG)[1]
    41204106        refList = G2lat.LaueUnique(Laue,refList)
    41214107        dlg = wx.ProgressDialog('Build HKL dictonary','',len(refList)+1,
     
    41974183        wtval.SetValue('%.3f'%(val))
    41984184       
    4199     def OnCompression(event):
    4200         data[0] = int(comp.GetValue())
     4185#    def OnCompression(event):
     4186#        data[0] = int(comp.GetValue())
    42014187       
    42024188    def onCopyPlotCtrls(event):
     
    43314317            tab = G2frame.G2plotNB.nb.GetPageText(page)
    43324318        if '3D' in tab:
    4333             Hmin = np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))])
    4334             Hmax = np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))])
    4335             Vpoint = [int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))]
    43364319            Page = G2frame.G2plotNB.nb.GetPage(page)
    43374320            controls = Page.controls
     
    44714454            data = G2frame.PatternTree.GetItemPyData(item)
    44724455            Phases = G2frame.GetPhaseData()
    4473             phase = ''
    44744456            phaseName = ''
    44754457            if Phases:
  • trunk/GSASIIimage.py

    r2522 r2546  
    2121import numpy.linalg as nl
    2222import numpy.ma as ma
    23 import numpy.fft as fft
    24 import scipy.signal as signal
    2523import polymask as pm
    2624from scipy.optimize import leastsq
     
    3230import GSASIIpwd as G2pwd
    3331import GSASIIspc as G2spc
    34 import fellipse as fel
    3532
    3633# trig functions in degrees
     
    9188        ''' gives ellipse center coordinates
    9289        '''
    93         b,c,d,f,g,a = p[1]/2, p[2], p[3]/2, p[4]/2, p[5], p[0]
     90        b,c,d,f,a = p[1]/2, p[2], p[3]/2, p[4]/2, p[0]
    9491        num = b*b-a*c
    9592        x0=(c*d-b*f)/num
     
    10198        range will be -90 to 90 deg
    10299        '''
    103         b,c,d,f,g,a = p[1]/2, p[2], p[3]/2, p[4]/2, p[5], p[0]
     100        b,c,a = p[1]/2, p[2], p[0]
    104101        return 0.5*npatand(2*b/(a-c))
    105102   
     
    170167        phi0 = npatan2d(y-parms['det-Y'],x-parms['det-X'])
    171168        dxy = peneCorr(tth,parms['dep'],parms['tilt'],phi0)
    172         ttth = nptand(tth)
    173169        stth = npsind(tth)
    174170        cosb = npcosd(parms['tilt'])
     
    176172        tbm = nptand((tth-parms['tilt'])/2.)
    177173        tbp = nptand((tth+parms['tilt'])/2.)
    178         sinb = npsind(parms['tilt'])
    179174        d = parms['dist']+dxy
    180175        fplus = d*tanb*stth/(cosb+stth)
     
    277272    '''
    278273    radii = [0,0]
    279     ttth = tand(tth)
    280274    stth = sind(tth)
    281     ctth = cosd(tth)
    282275    cosb = cosd(tilt)
    283276    tanb = tand(tilt)
     
    332325    cent = data['center']
    333326    tth = 2.0*asind(data['wavelength']/(2.*dsp))
    334     ttth = tand(tth)
    335327    stth = sind(tth)
    336     ctth = cosd(tth)
    337328    cosb = cosd(tilt)
    338329    if radii[0] > 0.:
     
    680671    Ring0 = makeRing(dsp,ellipse,3,cutoff,scalex,scaley,G2frame.ImageZ)[0]
    681672    ttth = nptand(tth)
    682     stth = npsind(tth)
    683673    ctth = npcosd(tth)
    684674#1st estimate of tilt; assume ellipse - don't know sign though
     
    879869    numAzms = data['outAzimuths']
    880870    numChans = data['outChannels']
    881     azmOff = data['azmthOff']
    882871    Dazm = (LRazm[1]-LRazm[0])/numAzms
    883872    if '2-theta' in data.get('binType','2-theta'):
     
    893882    NST = np.zeros(shape=(numAzms,numChans),order='F',dtype=np.float32)
    894883    H0 = np.zeros(shape=(numAzms,numChans),order='F',dtype=np.float32)
    895     imageN = len(image)
    896884    Nx,Ny = data['size']
    897885    nXBlks = (Nx-1)/blkSize+1
  • trunk/GSASIIindex.py

    r2500 r2546  
    2020import time
    2121import numpy as np
    22 import numpy.linalg as nl
    2322import GSASIIpath
    2423GSASIIpath.SetVersionNumber("$Revision$")
     
    191190        if hkl[3] < d20:
    192191            break               
    193     eta = diff/Nobs20
    194192    Q20 = 1.0/d20**2
    195193    if diff:
     
    221219        if hkl[4] < d20:
    222220            break               
    223     eta = diff/Nobs20
    224221    Q20 = 1.0/d20**2
    225222    if diff:
     
    10311028def TestData():
    10321029    'needs a doc string'
    1033     array = np.array
    10341030    global NeedTestData
    10351031    NeedTestData = False
     
    10991095def test0():
    11001096    if NeedTestData: TestData()
    1101     msg = 'test FitHKL'
    11021097    ibrav,cell,bestcell,Pwr,peaks = TestData
    11031098    print 'best cell:',bestcell
     
    11231118def test1():
    11241119    if NeedTestData: TestData()
    1125     msg = 'test FitHKL'
    11261120    ibrav,A,Pwr,peaks = TestData2
    11271121    print 'bad cell:',G2lat.A2cell(A)
  • trunk/GSASIIlattice.py

    r2512 r2546  
    317317    if Phase['General']['Type'] == 'magnetic':
    318318        cm = cx+4
    319     unit = np.zeros(3)
    320319    for iat,atom in enumerate(Atoms):
    321320        XYZ = np.array(atom[cx:cx+3])
     
    931930           
    932931    """
    933     import math
    934932    if Bravais in [9,11]:
    935933        Cent = 'C'
     
    12281226    matd3q = np.array([[0,0,-1],[-1,0,0],[0,1,0]])  #hkl -> -l,-h,k
    12291227    matd3t = np.array([[0,0,-1],[1,0,0],[0,-1,0]])  #hkl -> -l,h,-k
    1230     matd3p = np.array([[0,1,0],[0,0,-1],[-1,0,0]])  #hkl -> k,-l,-h
    12311228    mat6 = np.array([[1,1,0],[-1,0,0],[0,0,1]])     #hkl -> h+k,-h,l really 65
    12321229    matdm = np.array([[0,1,0],[1,0,0],[0,0,1]])     #hkl -> k,h,l
    1233     matdmt = np.array([[0,-1,0],[-1,0,0],[0,0,1]])    #hkl -> -k,-h,l
    12341230    matdmp = np.array([[-1,-1,0],[0,1,0],[0,0,1]])  #hkl -> -h-k,k,l
    1235     matdmq = np.array([[-1,0,0],[1,1,0],[0,0,1]])   #hkl -> -h,h+k,l
    12361231    matkm = np.array([[-1,0,0],[1,1,0],[0,0,1]])    #hkl -> -h,h+k,l
    1237     matkmp = np.array([[1,0,0],[-1,-1,0],[0,0,1]])  #hkl -> h,-h-k,l
    12381232    matd2 = np.array([[0,1,0],[1,0,0],[0,0,-1]])    #hkl -> k,h,-l
    1239     matd2p = np.array([[-1,-1,0],[0,1,0],[0,0,-1]]) #hkl -> -h-k,k,-l
    12401233    matdm3 = np.array([[1,0,0],[0,0,1],[0,1,0]])    #hkl -> h,l,k
    12411234    mat2d43 = np.array([[0,1,0],[1,0,0],[0,0,1]])   #hkl -> k,-h,l
    1242     math2 = np.array([[0,-1,0],[-1,0,0],[0,0,-1]])  #hkl -> -k,-h,-l
    12431235    matk2 = np.array([[-1,0,0],[1,1,0],[0,0,-1]])   #hkl -> -h,-i,-l
    12441236    #triclinic
     
    22312223        spdict = spc.SpcGroup(key)[1]
    22322224        cell = sgtbxlattinp.sgtbx8[key][0]
    2233         center = spdict['SGLatt']
    2234         Laue = spdict['SGLaue']
    22352225        Axis = spdict['SGUniq']
    22362226        system = spdict['SGSys']
  • trunk/GSASIImapvars.py

    r2519 r2546  
    210210
    211211import numpy as np
     212import sys
    212213import GSASIIpath
    213214GSASIIpath.SetVersionNumber("$Revision$")
     
    238239    fixedDict = {} # a dictionary containing the fixed values corresponding to defined parameter equations
    239240    consNum = 0 # number of the next constraint to be created
    240     fixedVarList = []
    241241
    242242def VarKeys(constr):
     
    816816    if len(printlist) == 0: return
    817817    s1 = ''
     818    s2 = ''
     819    s3 = ''
    818820    print >>pFile,130*'-'
    819821    print >>pFile,"Variables generated by constraints"
     
    845847    for varlist,mapvars,invmultarr in zip(dependentParmList,indParmList,invarrayList):
    846848        #if invmultarr is None: continue # probably not needed
    847         try:
    848             valuelist = [parmDict[var] for var in mapvars]
    849         except KeyError:
    850             continue
     849#        try:
     850#            valuelist = [parmDict[var] for var in mapvars]
     851#        except KeyError:
     852#            continue
    851853        # get the v-covar matrix for independent parameters
    852854        vcov = np.zeros((len(mapvars),len(mapvars)))
     
    11141116    the first m rows are not linearly independent
    11151117    '''
    1116     n = len(collist)
    11171118    for i in range(m):
    11181119        if np.allclose(arr[i,i],0):
  • trunk/GSASIImath.py

    r2544 r2546  
    376376    return XYZ
    377377   
    378 def TransformAtoms(Atoms,cx,cia,Trans,Vec):
    379     for Atom in Atoms:
    380         XYZ = Atom[cx:cx+3]
    381         if 'A' in Atom[cia]:
    382             U6 = Atom[cia+2:cia+8]
     378#def TransformAtoms(Atoms,cx,cia,Trans,Vec):
     379#    for Atom in Atoms:
     380#        XYZ = Atom[cx:cx+3]
     381#        if 'A' in Atom[cia]:
     382#            U6 = Atom[cia+2:cia+8]
    383383   
    384384
     
    564564    return [],[]
    565565       
    566 def AtomUij2TLS(atomData,atPtrs,Amat,Bmat,rbObj):   #unfinished & not used
    567     '''default doc string
    568    
    569     :param type name: description
    570    
    571     :returns: type name: description
    572    
    573     '''
    574     for atom in atomData:
    575         XYZ = np.inner(Amat,atom[cx:cx+3])
    576         if atom[cia] == 'A':
    577             UIJ = atom[cia+2:cia+8]
     566#def AtomUij2TLS(atomData,atPtrs,Amat,Bmat,rbObj):   #unfinished & not used
     567#    '''default doc string
     568#   
     569#    :param type name: description
     570#   
     571#    :returns: type name: description
     572#   
     573#    '''
     574#    for atom in atomData:
     575#        XYZ = np.inner(Amat,atom[cx:cx+3])
     576#        if atom[cia] == 'A':
     577#            UIJ = atom[cia+2:cia+8]
    578578               
    579579def TLS2Uij(xyz,g,Amat,rbObj):    #not used anywhere, but could be?
     
    11591159#    GSASIIpath.IPyBreak()
    11601160    if nWaves[0]:
    1161         tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau  #Fwaves x ngl
     1161        tauF = np.arange(1.,nWaves[0]+1)[:,nxs]*glTau  #Fwaves x ngl
    11621162        StauF = np.ones_like(Af)[:,:,nxs]*np.sin(twopi*tauF)[nxs,:,:] #also dFmod/dAf
    11631163        CtauF = np.ones_like(Bf)[:,:,nxs]*np.cos(twopi*tauF)[nxs,:,:] #also dFmod/dBf
     
    28982898                phasep = complex(a,b)
    28992899                phasem = complex(a,-b)
    2900                 h,k,l = hkl+Hmax
    2901                 Ehkl[h,k,l] = E*phasep
    2902                 h,k,l = -hkl+Hmax       #Friedel pair refl.
    2903                 Ehkl[h,k,l] = E*phasem
     2900                Ehkl[hkl+Hmax] = E*phasep
     2901                Ehkl[-hkl+Hmax] = E*phasem
    29042902#    Ehkl[Hmax] = 0.00001           #this to preserve F[0,0,0]
    29052903    testHKL = np.array(flipData['testHKL'])+Hmax
     
    35153513            ins[x] = Parms[x][ind]
    35163514        if ifQ:                              #qplot - convert back to 2-theta
    3517             pos = 2.0*asind(pos*wave/(4*math.pi))
     3515            pos = 2.0*asind(pos*getWave(Parms)/(4*math.pi))
    35183516        sig = getCWsig(ins,pos)
    35193517        gam = getCWgam(ins,pos)           
     
    43444342        lower=lower, upper=upper, slope=MCSA['log slope'],ranStart=MCSA.get('ranStart',False),
    43454343        ranRange=MCSA.get('ranRange',0.10),autoRan=MCSA.get('autoRan',False),dlg=pgbar)
    4346     M = mcsaCalc(results[0],refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict)
     4344    mcsaCalc(results[0],refs,rcov,cosTable,ifInv,allFF,RBdata,varyList,parmDict)
    43474345#    for ref in refs.T:
    43484346#        print ' %4d %4d %4d %10.3f %10.3f %10.3f'%(int(ref[0]),int(ref[1]),int(ref[2]),ref[4],ref[5],ref[6])
  • trunk/GSASIIobj.py

    r2504 r2546  
    18771877        try:
    18781878            exprast = ast.parse(expr)
    1879         except SyntaxError as err:
     1879        except SyntaxError:
    18801880            s = ''
    18811881            import traceback
  • trunk/GSASIIphsGUI.py

    r2544 r2546  
    45214521            SGData = generalData['SGData']
    45224522            SpnFlp = SGData.get('SpnFlp',[])
    4523             MagMom = SGData.get('MagMom',[])
     4523#            MagMom = SGData.get('MagMom',[])
    45244524            wx.BeginBusyCursor()
    45254525            try:
  • trunk/GSASIIplot.py

    r2544 r2546  
    19521952        Parms = ParmList[N]
    19531953        Sample = SampleList[N]
    1954         if 'C' in Parms['Type'][0]:
    1955             wave = G2mth.getWave(Parms)
    1956         else:
    1957             difC = Parms['difC'][1]
    19581954        ifpicked = False
    19591955        LimitId = 0
     
    23912387        PlotISFG(G2frame,newPlot=newPlot,type=type)
    23922388       
    2393     def OnKeyBox(event):
    2394         if G2frame.G2plotNB.nb.GetSelection() == G2frame.G2plotNB.plotList.index(type):
    2395             event.key = cb.GetValue()[0]
    2396             cb.SetValue(' key press')
    2397             wx.CallAfter(OnPlotKeyPress,event)
    2398         Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
    2399                        
    24002389    def OnMotion(event):
    24012390        xpos = event.xdata
     
    27722761        wx.CallAfter(PlotXYZ,G2frame,XY,Z,labelX,labelY,False,Title)
    27732762   
    2774     def OnKeyBox(event):
    2775         if G2frame.G2plotNB.nb.GetSelection() == G2frame.G2plotNB.plotList.index(type):
    2776             event.key = cb.GetValue()[0]
    2777             cb.SetValue(' key press')
    2778             wx.CallAfter(OnKeyPress,event)
    2779         Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
    2780 
    27812763    def OnMotion(event):
    27822764        xpos = event.xdata
     
    30393021        Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=14)
    30403022        Plot.set_ylabel(r'$\Delta Q/Q, \Delta d/d$',fontsize=14)
    3041         try:
    3042             Xmin,Xmax = limits[1]
    3043             X = np.linspace(Xmin,Xmax,num=101,endpoint=True)
    3044             Q = 4.*np.pi*npsind(X/2.)/lam
    3045             Z = np.ones_like(X)
    3046             data = G2mth.setPeakparms(Parms,Parms2,X,Z)
    3047             s = np.sqrt(data[4])*np.pi/18000.   #var -> sig(radians)
    3048             g = data[6]*np.pi/18000.    #centideg -> radians
    3049             G = G2pwd.getgamFW(g,s)/2.  #delt-theta
    3050             Y = s/nptand(X/2.)
    3051             Z = g/nptand(X/2.)
    3052             W = G/nptand(X/2.)
    3053             Plot.plot(Q,Y,color='r',label='Gaussian')
    3054             Plot.plot(Q,Z,color='g',label='Lorentzian')
    3055             Plot.plot(Q,W,color='b',label='G+L')
    3056            
    3057             fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True)
    3058             sf = np.sqrt(fit[4])*np.pi/18000.
    3059             gf = fit[6]*np.pi/18000.
    3060             Gf = G2pwd.getgamFW(gf,sf)/2.
    3061             Yf = sf/nptand(X/2.)
    3062             Zf = gf/nptand(X/2.)
    3063             Wf = Gf/nptand(X/2.)
    3064             Plot.plot(Q,Yf,color='r',dashes=(5,5),label='Gaussian fit')
    3065             Plot.plot(Q,Zf,color='g',dashes=(5,5),label='Lorentzian fit')
    3066             Plot.plot(Q,Wf,color='b',dashes=(5,5),label='G+L fit')
    3067            
    3068             X = []
    3069             Y = []
    3070             Z = []
    3071             W = []
    3072             for peak in peaks:
    3073                 X.append(4.0*math.pi*sind(peak[0]/2.0)/lam)
    3074                 try:
    3075                     s = math.sqrt(peak[4])*math.pi/18000.
    3076                 except ValueError:
    3077                     s = 0.01
    3078                 g = peak[6]*math.pi/18000.
    3079                 G = G2pwd.getgamFW(g,s)/2.
    3080                 Y.append(s/tand(peak[0]/2.))
    3081                 Z.append(g/tand(peak[0]/2.))
    3082                 W.append(G/tand(peak[0]/2.))
    3083             if len(peaks):
    3084                 Plot.plot(X,Y,'+',color='r',label='G peak')
    3085                 Plot.plot(X,Z,'+',color='g',label='L peak')
    3086                 Plot.plot(X,W,'+',color='b',label='G+L peak')
    3087             Plot.legend(loc='best')
    3088             Page.canvas.draw()
    3089         except ValueError:
    3090             print '**** ERROR - default U,V,W profile coefficients yield sqrt of negative value at 2theta =', \
    3091                 '%.3f'%(2*theta)
    3092             G2frame.G2plotNB.Delete('Peak Widths')
     3023        Xmin,Xmax = limits[1]
     3024        X = np.linspace(Xmin,Xmax,num=101,endpoint=True)
     3025        Q = 4.*np.pi*npsind(X/2.)/lam
     3026        Z = np.ones_like(X)
     3027        data = G2mth.setPeakparms(Parms,Parms2,X,Z)
     3028        s = np.sqrt(data[4])*np.pi/18000.   #var -> sig(radians)
     3029        g = data[6]*np.pi/18000.    #centideg -> radians
     3030        G = G2pwd.getgamFW(g,s)/2.  #delt-theta
     3031        Y = s/nptand(X/2.)
     3032        Z = g/nptand(X/2.)
     3033        W = G/nptand(X/2.)
     3034        Plot.plot(Q,Y,color='r',label='Gaussian')
     3035        Plot.plot(Q,Z,color='g',label='Lorentzian')
     3036        Plot.plot(Q,W,color='b',label='G+L')
     3037       
     3038        fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True)
     3039        sf = np.sqrt(fit[4])*np.pi/18000.
     3040        gf = fit[6]*np.pi/18000.
     3041        Gf = G2pwd.getgamFW(gf,sf)/2.
     3042        Yf = sf/nptand(X/2.)
     3043        Zf = gf/nptand(X/2.)
     3044        Wf = Gf/nptand(X/2.)
     3045        Plot.plot(Q,Yf,color='r',dashes=(5,5),label='Gaussian fit')
     3046        Plot.plot(Q,Zf,color='g',dashes=(5,5),label='Lorentzian fit')
     3047        Plot.plot(Q,Wf,color='b',dashes=(5,5),label='G+L fit')
     3048       
     3049        X = []
     3050        Y = []
     3051        Z = []
     3052        W = []
     3053        for peak in peaks:
     3054            X.append(4.0*math.pi*sind(peak[0]/2.0)/lam)
     3055            try:
     3056                s = math.sqrt(peak[4])*math.pi/18000.
     3057            except ValueError:
     3058                s = 0.01
     3059            g = peak[6]*math.pi/18000.
     3060            G = G2pwd.getgamFW(g,s)/2.
     3061            Y.append(s/tand(peak[0]/2.))
     3062            Z.append(g/tand(peak[0]/2.))
     3063            W.append(G/tand(peak[0]/2.))
     3064        if len(peaks):
     3065            Plot.plot(X,Y,'+',color='r',label='G peak')
     3066            Plot.plot(X,Z,'+',color='g',label='L peak')
     3067            Plot.plot(X,W,'+',color='b',label='G+L peak')
     3068        Plot.legend(loc='best')
     3069        Page.canvas.draw()
    30933070    else:   #'T'OF
    30943071        Plot.set_title('Instrument and sample peak coefficients')
     
    33973374                except ValueError:
    33983375                    sfac *= 1.05
    3399             Z = [lut(r*np.pi/180.,p*np.pi/180.) for r,p in zip(list(R),list(P))]
     3376            Z = [lut(ri*np.pi/180.,p*np.pi/180.) for ri,p in zip(list(R),list(P))]
    34003377            print 'IVP for histogramn: %s: interpolate sfactor: %.2f'%(hist,sfac)
    34013378        except AttributeError:
     
    42414218            wx.CallAfter(PlotImage,G2frame,newPlot=True)
    42424219           
    4243     def OnKeyBox(event):
    4244         if G2frame.G2plotNB.nb.GetSelection() == G2frame.G2plotNB.plotList.index('2D Powder Image'):
    4245             event.key = cb.GetValue()[0]
    4246             cb.SetValue(' key press')
    4247             if event.key in ['l','s','a','r','p','x','y']:
    4248                 wx.CallAfter(OnImPlotKeyPress,event)
    4249         Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
    4250                        
    42514220    def OnImPick(event):
    42524221        if G2frame.PatternTree.GetItemText(G2frame.PickId) not in ['Image Controls','Masks']:
     
    48624831    drawAtoms = drawingData.get('Atoms',[])
    48634832    mapData = {}
    4864     flipData = {}
    48654833    showBonds = False
    48664834    if 'Map' in generalData:
    48674835        mapData = generalData['Map']
    48684836        showBonds = mapData.get('Show bonds',False)
    4869     if 'Flip' in generalData:
    4870         flipData = generalData['Flip']                       
    48714837    Wt = np.array([255,255,255])
    48724838    Rd = np.array([255,0,0])
  • trunk/GSASIIpwd.py

    r2522 r2546  
    2020
    2121import numpy as np
    22 import scipy as sp
    2322import numpy.linalg as nl
    2423import numpy.ma as ma
     
    3433import GSASIIspc as G2spc
    3534import GSASIIElem as G2elem
    36 import GSASIIgrid as G2gd
    37 import GSASIIIO as G2IO
    3835import GSASIImath as G2mth
    3936import pypowder as pyd
     
    180177       
    181178    Sth2 = npsind(Tth/2.0)**2
    182     Cth2 = 1.-Sth2
    183179    if 'Cylinder' in Geometry:      #Lobanov & Alte da Veiga for 2-theta = 0; beam fully illuminates sample
    184180        if 'array' in str(type(MuR)):
     
    308304    #Apply angle dependent corrections
    309305    Tth = xydata['IofQ'][1][0]
    310     dt = (Tth[1]-Tth[0])
    311306    MuR = Abs*data['Diam']/20.0
    312307    xydata['IofQ'][1][1] /= Absorb(data['Geometry'],MuR,Tth)
     
    318313    #convert to Q
    319314    if 'C' in inst['Type'][0]:
    320         hc = 12.397639
    321315        wave = G2mth.getWave(inst)
    322         keV = hc/wave
    323316        minQ = npT2q(Tth[0],wave)
    324317        maxQ = npT2q(Tth[-1],wave)   
     
    559552    extended by exponential coeff.
    560553    '''
    561     lnf = 3.3      # =log(0.001/2)
    562554    widths = [np.sqrt(sig),gam]
    563555    fwhm = 2.355*widths[0]+2.*widths[1]
     
    887879    Df,dFdp,dFds,dFdg,dFdsh = pyd.pydpsvfcj(len(xdata),xdata-pos,pos,sig,gam,shl)
    888880#    Df,dFdp,dFds,dFdg,dFdsh = pyd.pydpsvfcjo(len(xdata),xdata-pos,pos,sig,gam,shl)
    889     sumDf = np.sum(Df)
    890881    return Df,dFdp,dFds,dFdg,dFdsh
    891882
     
    901892   
    902893    Df,dFdp,dFds,dFdg = pyd.pydpsvoigt(len(xdata),xdata-pos,sig,gam)
    903     sumDf = np.sum(Df)
    904894    return Df,dFdp,dFds,dFdg
    905895
     
    913903    'needs a doc string'
    914904    Df,dFdp,dFda,dFdb,dFds,dFdg = pyd.pydepsvoigt(len(xdata),xdata-pos,alp,bet,sig,gam)
    915     sumDf = np.sum(Df)
    916905    return Df,dFdp,dFda,dFdb,dFds,dFdg   
    917906
     
    16881677    if controls:
    16891678        Ftol = controls['min dM/M']
    1690         derivType = controls['deriv type']
    16911679    else:
    16921680        Ftol = 0.0001
    1693         derivType = 'analytic'
    16941681    if oneCycle:
    16951682        Ftol = 1.0
     
    18251812    Parms = []
    18261813#cell parms
    1827     cell = Layers['Cell']
    18281814    if Layers['Laue'] in ['-3','-3m','4/m','4/mmm','6/m','6/mmm']:
    18291815        Parms.append('cellA')
     
    18361822            Parms.append('cellG')
    18371823#Transition parms
    1838     Trans = Layers['Transitions']
    18391824    for iY in range(len(Layers['Layers'])):
    18401825        for iX in range(len(Layers['Layers'])):
     
    20442029    SFdat = []
    20452030    for atType in atTypes:
    2046         if atType == 'H':
    2047             blen = -.3741
    2048         else:
    2049             blen = Layers['AtInfo'][atType]['Isotopes']['Nat. Abund.']['SL'][0]
    20502031        Adat = atmdata.XrayFF[atType]
    20512032        SF = np.zeros(9)
     
    22062187    SetStackingTrans(Layers,Nlayers)
    22072188# result as Sadp
    2208     mirror = laueId in [-1,2,3,7,8,9,10]
    22092189    Nspec = 20001       
    22102190    spec = np.zeros(Nspec,dtype='double')   
     
    22372217    'needs a doc string'
    22382218#    global NeedTestData
    2239     NeedTestData = False
    22402219    global bakType
    22412220    bakType = 'chebyschev'
     
    22752254def test0():
    22762255    if NeedTestData: TestData()
    2277     msg = 'test '
    22782256    gplot = plotter.add('FCJ-Voigt, 11BM').gca()
    22792257    gplot.plot(xdata,getBackground('',parmDict0,bakType,'PXC',xdata)[0])   
     
    22872265    time0 = time.time()
    22882266    for i in range(100):
    2289         y = getPeakProfile(parmDict1,xdata,varyList,bakType)
     2267        getPeakProfile(parmDict1,xdata,varyList,bakType)
    22902268    print '100+6*Ka1-2 peaks=1200 peaks',time.time()-time0
    22912269   
  • trunk/GSASIIpwdGUI.py

    r2544 r2546  
    2424import numpy.ma as ma
    2525import math
    26 import time
    2726import copy
    2827import random as ran
     
    557556        prevVaryList = []
    558557        Names = []
     558        peaks = None
     559        varyList = None
    559560        if Reverse:
    560561            names.reverse()
     
    12381239    G2frame.dataFrame.SetLabel('Background')
    12391240    if not G2frame.dataFrame.GetStatusBar():
    1240         Status = G2frame.dataFrame.CreateStatusBar()
     1241        G2frame.dataFrame.CreateStatusBar()
    12411242    G2frame.Bind(wx.EVT_MENU,OnBackCopy,id=G2gd.wxID_BACKCOPY)
    12421243    G2frame.Bind(wx.EVT_MENU,OnBackFlagCopy,id=G2gd.wxID_BACKFLAGCOPY)
     
    14341435    G2frame.dataFrame.SetLabel('Limits')
    14351436    if not G2frame.dataFrame.GetStatusBar():
    1436         Status = G2frame.dataFrame.CreateStatusBar()
     1437        G2frame.dataFrame.CreateStatusBar()
    14371438    G2frame.Bind(wx.EVT_MENU,OnLimitCopy,id=G2gd.wxID_LIMITCOPY)
    14381439    G2frame.Bind(wx.EVT_MENU,OnAddExcl,id=G2gd.wxID_ADDEXCLREGION)
     
    19241925                        continue
    19251926                    nDig = (10,3)
    1926                     fmt = '%10.3f'
    19271927                    if 'beta' in item:
    1928                         fmt = '%12.6g'
    19291928                        nDig = (12,6)
    19301929                    instSizer.Add(
     
    20442043    Inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,
    20452044            G2frame.PatternId,'Instrument Parameters'))[1]       
    2046     try:
    2047         histoName = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)[-1]
    2048         ifHisto = IsHistogramInAnyPhase(G2frame,histoName)
    2049     except TypeError:       #PKS data never used in a phase as data
    2050         ifhisto = False
    20512045    G2gd.SetDataMenuBar(G2frame)
    20522046    #patch
     
    24192413        G2frame.dataFrame.SetScale.Enable(True)
    24202414    if not G2frame.dataFrame.GetStatusBar():
    2421         Status = G2frame.dataFrame.CreateStatusBar()   
     2415        G2frame.dataFrame.CreateStatusBar()   
    24222416    G2frame.dataDisplay = wx.Panel(G2frame.dataFrame)
    24232417    Controls = G2frame.PatternTree.GetItemPyData(
     
    26432637        G2frame.dataFrame.Clear()
    26442638    if not G2frame.dataFrame.GetStatusBar():
    2645         Status = G2frame.dataFrame.CreateStatusBar()
     2639        G2frame.dataFrame.CreateStatusBar()
    26462640    if 'PWD' in G2frame.PatternTree.GetItemText(G2frame.PatternId):
    26472641        G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.IndPeaksMenu)
     
    35343528            General = G2frame.PatternTree.GetItemPyData(phaseId)['General']
    35353529            Super = General.get('Super',0)
    3536             SuperVec = General.get('SuperVec',[])
    35373530        else:
    35383531            Super = 0
     
    39883981    G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.SubstanceMenu)
    39893982    if not G2frame.dataFrame.GetStatusBar():
    3990         Status = G2frame.dataFrame.CreateStatusBar()
     3983        G2frame.dataFrame.CreateStatusBar()
    39913984    G2frame.dataDisplay = wxscroll.ScrolledPanel(G2frame.dataFrame)
    39923985    G2frame.dataFrame.SetLabel('Substances')
     
    41624155        if Reverse:
    41634156            names.reverse()
     4157        JModel = None
    41644158        try:
    41654159            for i,name in enumerate(names):
     
    47984792            Obj.SetValue(fmt%(value))
    47994793            data[fileKey][itemKey] = value
    4800             auxPlot = ComputePDF(data)
    4801             G2plt.PlotISFG(G2frame,newPlot=True)
     4794            OnComputePDF(None)
    48024795                       
    48034796        item = data[key]
     
    48294822            sumVol += Avol*ElList[El]['FormulaNo']
    48304823        return sumVol
    4831         auxPlot = ComputePDF(data)
    4832         G2plt.PlotISFG(G2frame,newPlot=True)       
     4824        OnComputePDF(None)
    48334825       
    48344826    def FillElemSizer(elemSizer,ElData):
     
    48454837            formVol.SetValue('%.2f'%(data['Form Vol']))
    48464838            wx.CallAfter(UpdatePDFGrid,G2frame,data)
    4847             auxPlot = ComputePDF(data)
    4848             G2plt.PlotISFG(G2frame,newPlot=True)       
     4839            OnComputePDF(None)
    48494840       
    48504841        elemSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,
     
    48614852        data['Geometry'] = geometry.GetValue()
    48624853        UpdatePDFGrid(G2frame,data)
    4863         auxPlot = ComputePDF(data)
    4864         G2plt.PlotISFG(G2frame,newPlot=True)       
     4854        OnComputePDF(None)
    48654855       
    48664856    def OnDetType(event):
    48674857        data['DetType'] = detType.GetValue()
    48684858        UpdatePDFGrid(G2frame,data)
    4869         auxPlot = ComputePDF(data)
    4870         G2plt.PlotISFG(G2frame,newPlot=True)       
     4859        OnComputePDF(None)
    48714860       
    48724861    def OnFormVol(event):
     
    48804869        data['Form Vol'] = value
    48814870        UpdatePDFGrid(G2frame,data)
    4882         auxPlot = ComputePDF(data)
    4883         G2plt.PlotISFG(G2frame,newPlot=False)       
     4871        OnComputePDF(None)
    48844872       
    48854873    def OnDiameter(event):
     
    48934881        data['Diam'] = value
    48944882        UpdatePDFGrid(G2frame,data)
    4895         auxPlot = ComputePDF(data)
    4896         G2plt.PlotISFG(G2frame,newPlot=False)
     4883        OnComputePDF(None)
    48974884       
    48984885#    def OnPolaVal(event):
     
    49364923        data['ObliqCoeff'] = value
    49374924        obliqCoeff.SetValue('%.3f'%(value))
    4938         auxPlot = ComputePDF(data)
    4939         G2plt.PlotISFG(G2frame,newPlot=False)
     4925        OnComputePDF(None)
    49404926       
    49414927    def OnBackVal(event):
     
    49484934        data['BackRatio'] = value
    49494935        backVal.SetValue('%.3f'%(value))
    4950         auxPlot = ComputePDF(data)
    4951         G2plt.PlotISFG(G2frame,newPlot=False)
     4936        OnComputePDF(None)
    49524937       
    49534938    def OnBackSlider(event):
     
    49554940        data['BackRatio'] = value
    49564941        backVal.SetValue('%.3f'%(data['BackRatio']))
    4957         auxPlot = ComputePDF(data)
    4958         G2plt.PlotISFG(G2frame,newPlot=False)
     4942        OnComputePDF(None)
    49594943       
    49604944    def OnRulandWdt(event):
     
    49704954        data['Ruland'] = value
    49714955        rulandWdt.SetValue('%.3f'%(value))
    4972         auxPlot = ComputePDF(data)
    4973         G2plt.PlotISFG(G2frame,newPlot=False)
     4956        OnComputePDF(None)
    49744957       
    49754958    def OnRulSlider(event):
     
    49774960        data['Ruland'] = max(0.001,value)
    49784961        rulandWdt.SetValue('%.3f'%(data['Ruland']))
    4979         auxPlot = ComputePDF(data)
    4980         G2plt.PlotISFG(G2frame,newPlot=False)
     4962        OnComputePDF(None)
    49814963       
    49824964    def OnLorch(event):
    49834965        data['Lorch'] = lorch.GetValue()
    4984         auxPlot = ComputePDF(data)
    4985         G2plt.PlotISFG(G2frame,newPlot=False)       
     4966        OnComputePDF(None)
    49864967                       
    49874968    def OnPacking(event):
     
    49954976        data['Pack'] = value
    49964977        UpdatePDFGrid(G2frame,data)
    4997         auxPlot = ComputePDF(data)
    4998         G2plt.PlotISFG(G2frame,newPlot=False)       
     4978        OnComputePDF(None)
    49994979               
    50004980    def OnSQmin(event):
     
    50084988        data['QScaleLim'][0] = value
    50094989        SQmin.SetValue('%.1f'%(value))
    5010         auxPlot = ComputePDF(data)
    5011         G2plt.PlotISFG(G2frame,newPlot=True)       
     4990        OnComputePDF(None)
    50124991       
    50134992    def OnSQmax(event):
     
    50245003            SQmin.SetValue('%.1f'%(data['QScaleLim'][0]))
    50255004        SQmax.SetValue('%.1f'%(value))
    5026         auxPlot = ComputePDF(data)
    5027         G2plt.PlotISFG(G2frame,newPlot=True)
     5005        OnComputePDF(None)
    50285006       
    50295007    def OnResetQ(event):
     
    50335011        data['QScaleLim'][0] = 0.9*qLimits[1]
    50345012        SQmin.SetValue('%.1f'%(data['QScaleLim'][0]))
    5035         auxPlot = ComputePDF(data)
    5036         G2plt.PlotISFG(G2frame,newPlot=True)
     5013        OnComputePDF(None)
    50375014       
    50385015    def OnNoRing(event):
    50395016        data['noRing'] = not data['noRing']
    5040         auxPlot = ComputePDF(data)
    5041         G2plt.PlotISFG(G2frame,newPlot=True)
    5042                
     5017        OnComputePDF(None)               
    50435018
    50445019    def GetFileList(fileType):
     
    51325107       
    51335108    def OnComputePDF(event):
    5134         print 'Calculating PDF:'
     5109#        print 'Calculating PDF:'
    51355110        auxPlot = ComputePDF(data)
    5136         print 'Done calculating PDF:'
     5111#        print 'Done calculating PDF:'
    51375112        Status.SetStatusText('PDF computed')
    51385113        for plot in auxPlot:
    51395114            XY = np.array(plot[:2])
    51405115            G2plt.PlotXY(G2frame,[XY,],Title=plot[2])
    5141        
    5142         G2plt.PlotISFG(G2frame,newPlot=True,type='I(Q)')
    5143         G2plt.PlotISFG(G2frame,newPlot=True,type='S(Q)')
    5144         G2plt.PlotISFG(G2frame,newPlot=True,type='F(Q)')
     5116        if event is not None:
     5117            G2plt.PlotISFG(G2frame,newPlot=True,type='I(Q)')
     5118            G2plt.PlotISFG(G2frame,newPlot=True,type='S(Q)')
     5119            G2plt.PlotISFG(G2frame,newPlot=True,type='F(Q)')
    51455120        G2plt.PlotISFG(G2frame,newPlot=True,type='G(R)')
    51465121       
     
    51535128                if 'PDF' in Name.split()[0]:
    51545129                    Data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,id,'PDF Controls'))
    5155                     auxPlot = ComputePDF(Data)                   
     5130                    ComputePDF(Data)                   
    51565131                id, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
    51575132            Status.SetStatusText('All PDFs computed')
  • trunk/GSASIIpy3.py

    r2065 r2546  
    111111    try:
    112112        return fmt.format(float(val)).strip()
    113     except ValueError as err:
     113    except ValueError:
    114114        print 'FormatValue Error with val,maxdigits,fmt=',val,maxdigits,fmt
    115115        return str(val)
     
    162162    try:
    163163        return fmt.format(float(val)).strip()
    164     except ValueError as err:
     164    except ValueError:
    165165        print 'FormatValue Error with val,maxdigits, sigfigs, fmt=',val, maxdigits,sigfigs, fmt
    166166        return str(val)
  • trunk/GSASIIrestrGUI.py

    r2530 r2546  
    1717import wx
    1818import wx.grid as wg
    19 import time
    2019import numpy as np
    2120import numpy.ma as ma
     
    129128                    print '**** ERROR - wrong restraint macro file selected, try again ****'
    130129                    macro = []
    131             else: # cancel was pressed
    132                 macxro = []
    133130        finally:
    134131            dlg.Destroy()
     
    280277
    281278    def AddAABondRestraint(bondRestData):
    282         Radii = dict(zip(General['AtomTypes'],General['BondRadii']))
    283279        macro = getMacroFile('bond')
    284280        if not macro:
     
    389385                        ids = [vecta[4],vecta[0],vectb[4]]
    390386                        ops = [vecta[5],vecta[1],vectb[5]]
    391                         XYZ = np.array([vecta[6],vecta[2],vectb[6]])
    392387                        angle = [ids,ops,value,1.0]
    393388                        if angle not in angleRestData['Angles']:
     
    551546    def makeChains(Names,Ids):
    552547        Chains = {}
    553         chain = ''
    554548        atoms = zip(Names,Ids)
    555549        for name,id in atoms:
     
    837831        def OnCellChange(event):
    838832            r,c =  event.GetRow(),event.GetCol()
    839             val = bondRestData['Bonds'][r][c]
    840833            try:
    841834                new = float(bondTable.GetValue(r,c))
     
    889882        if BondRestr.GetSizer():
    890883            BondRestr.GetSizer().Clear(True)
    891         dataDisplay = wx.Panel(BondRestr)
    892884        mainSizer = wx.BoxSizer(wx.VERTICAL)
    893885        mainSizer.Add((5,5),0)
     
    969961        def OnCellChange(event):
    970962            r,c =  event.GetRow(),event.GetCol()
    971             val = angleRestData['Angles'][r][c]
    972963            try:
    973964                new = float(angleTable.GetValue(r,c))
     
    10201011        if AngleRestr.GetSizer():
    10211012            AngleRestr.GetSizer().Clear(True)
    1022         dataDisplay = wx.Panel(AngleRestr)
    10231013        mainSizer = wx.BoxSizer(wx.VERTICAL)
    10241014        mainSizer.Add((5,5),0)
     
    11051095        def OnCellChange(event):
    11061096            r,c =  event.GetRow(),event.GetCol()
    1107             val = planeRestData['Planes'][r][c]
    11081097            try:
    11091098                new = float(planeTable.GetValue(r,c))
     
    11421131        if PlaneRestr.GetSizer():
    11431132            PlaneRestr.GetSizer().Clear(True)
    1144         dataDisplay = wx.Panel(PlaneRestr)
    11451133        mainSizer = wx.BoxSizer(wx.VERTICAL)
    11461134        mainSizer.Add((5,5),0)
     
    12271215        def OnCellChange(event):
    12281216            r,c =  event.GetRow(),event.GetCol()
    1229             val = chiralRestData['Volumes'][r][c]
    12301217            try:
    12311218                new = float(volumeTable.GetValue(r,c))
     
    12781265        if ChiralRestr.GetSizer():
    12791266            ChiralRestr.GetSizer().Clear(True)
    1280         dataDisplay = wx.Panel(ChiralRestr)
    12811267        mainSizer = wx.BoxSizer(wx.VERTICAL)
    12821268        mainSizer.Add((5,5),0)
     
    13581344        def OnCellChange(event):
    13591345            r,c =  event.GetRow(),event.GetCol()
    1360             val = torsionRestData['Torsions'][r][c]
    13611346            try:
    13621347                new = float(torsionTable.GetValue(r,c))
     
    13691354           
    13701355        def OnDeleteRestraint(event):
    1371             rows = GetSelectedRows(Torsions)
     1356            rows = GetSelectedRows(TorsionRestr.Torsions)
    13721357            if not rows:
    13731358                return
     
    13791364           
    13801365        def OnChangeEsd(event):
    1381             rows = GetSelectedRows(Torsions)
     1366            rows = GetSelectedRows(TorsionRestr.Torsions)
    13821367            if not rows:
    13831368                return
    1384             Torsions.ClearSelection()
     1369            TorsionRestr.Torsions.ClearSelection()
    13851370            val = torsionList[rows[0]][4]
    13861371            dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for torsion restraints',val,[0.,5.],'%.2f')
     
    13951380        if TorsionRestr.GetSizer():
    13961381            TorsionRestr.GetSizer().Clear(True)
    1397         dataDisplay = wx.Panel(TorsionRestr)
    13981382        mainSizer = wx.BoxSizer(wx.VERTICAL)
    13991383        mainSizer.Add((5,5),0)
     
    14791463        def OnCellChange(event):
    14801464            r,c =  event.GetRow(),event.GetCol()
    1481             val = ramaRestData['Ramas'][r][c]
    14821465            try:
    14831466                new = float(ramaTable.GetValue(r,c))
     
    14901473           
    14911474        def OnDeleteRestraint(event):
    1492             rows = GetSelectedRows(Ramas)
     1475            rows = GetSelectedRows(RamaRestr.Ramas)
    14931476            if not rows:
    14941477                return
     
    15001483           
    15011484        def OnChangeEsd(event):
    1502             rows = GetSelectedRows(Ramas)
     1485            rows = GetSelectedRows(RamaRestr.Ramas)
    15031486            if not rows:
    15041487                return
    1505             Ramas.ClearSelection()
     1488            RamaRestr.Ramas.ClearSelection()
    15061489            val = ramaList[rows[0]][4]
    15071490            dlg = G2G.SingleFloatDialog(G2frame,'New value','Enter new esd for energy',val,[0.,5.],'%.2f')
     
    15161499        if RamaRestr.GetSizer():
    15171500            RamaRestr.GetSizer().Clear(True)
    1518         dataDisplay = wx.Panel(RamaRestr)
    15191501        mainSizer = wx.BoxSizer(wx.VERTICAL)
    15201502        mainSizer.Add((5,5),0)
     
    16541636        if ChemCompRestr.GetSizer():
    16551637            ChemCompRestr.GetSizer().Clear(True)
    1656         dataDisplay = wx.Panel(ChemCompRestr)
    16571638        mainSizer = wx.BoxSizer(wx.VERTICAL)
    16581639        mainSizer.Add((5,5),0)
     
    17451726        def OnCellChange(event):
    17461727            r,c = event.GetRow(),event.GetCol()
    1747             val = textureRestData['HKLs'][r][c]
    17481728            try:
    17491729                if c == 1:  #grid size
    17501730                    new = int(textureTable.GetValue(r,c))
    17511731                    if new < 6 or new > 24:
    1752                         raise valueError
     1732                        raise ValueError
    17531733                elif c in [2,4]:   #esds
    17541734                    new = float(textureTable.GetValue(r,c))
     
    17651745        if TextureRestr.GetSizer():
    17661746            TextureRestr.GetSizer().Clear(True)
    1767         dataDisplay = wx.Panel(TextureRestr)
    17681747        mainSizer = wx.BoxSizer(wx.VERTICAL)
    17691748        mainSizer.Add((5,5),0)
     
    17751754
    17761755        textureList = textureRestData['HKLs']
    1777         textureData = General['SH Texture']
    17781756        if len(textureList):
    17791757            table = []
  • trunk/GSASIIsasd.py

    r2308 r2546  
    564564    lam2 = (-1.0*qb+np.sqrt(radic))/(2.0*qa)
    565565    lam = min(lam1,lam2)
    566     test = 1.0 + 2.0*eta
    567566    mu = lam*eta*etam1
    568567    alp = (1.0 + 2.0*eta - mu)/(etam1*etam1)
     
    939938            print " MaxEnt trial/max: %3d/%3d" % ((iter+1), IterMax)
    940939            print " Residual: %5.2lf%% Entropy: %8lg" % (100*test, S)
    941             if iter > 0:
    942                 value = 100*( math.sqrt(chisq/chtarg)-1)
    943             else:
    944                 value = 0
    945       #      print " %12.5lg %10.4lf" % ( math.sqrt(chtarg/npt), value )
    946940            print " Function sum: %.6lg Change from last: %.2lf%%\n" % (fSum,100*fChange/fSum)
    947941
     
    10571051        'Spherical shell': [SphericalShellFF, SphericalShellVol]}
    10581052    Shape = data['Size']['Shape'][0]
    1059     SlitLen = Sample.get('SlitLen',0.0)
    10601053    Parms = data['Size']['Shape'][1:]
    10611054    if data['Size']['logBins']:
     
    10921085    Ic[Ibeg:Ifin] += Back[0]
    10931086    print ' Final chi^2: %.3f'%(chisq)
    1094     Vols = shapes[Shape][1](Bins,Parms)
    10951087    data['Size']['Distribution'] = [Bins,Dbins,BinMag/(2.*Dbins)]
    10961088       
     
    12691261        result = so.leastsq(calcSASD,values,full_output=True,epsfcn=1.e-8,   #ftol=Ftol,
    12701262            args=(Q[Ibeg:Ifin],Io[Ibeg:Ifin],wtFactor*wt[Ibeg:Ifin],Ifb[Ibeg:Ifin],levelTypes,parmDict,varyList))
    1271         ncyc = int(result[2]['nfev']/2)
    12721263        parmDict.update(zip(varyList,result[0]))
    12731264        chisq = np.sum(result[2]['fvec']**2)
     
    13231314#    pdb.set_trace()
    13241315    partData = sasdData['Particle']
    1325     matFrac = partData['Matrix']['VolFrac'] #[value,flag]       
    1326     Scale = Sample['Scale']     #[value,flag]
    1327     SlitLen = Sample.get('SlitLen',0.0)
    13281316    Back = sasdData['Back']
    13291317    Q,Io,wt,Ic,Ib,Ifb = Profile[:6]
    13301318    Qmin = Limits[1][0]
    13311319    Qmax = Limits[1][1]
    1332     wtFactor = ProfDict['wtFactor']
    13331320    Ibeg = np.searchsorted(Q,Qmin)
    13341321    Ifin = np.searchsorted(Q,Qmax)+1    #include last point
     
    14161403        distFxn = 'LogNormalDist'
    14171404        cumeFxn = 'LogNormalCume'
    1418         pos = distDict['MinSize']
    1419         args = [distDict['Mean'],distDict['StdDev']]
    1420         step = 4.*np.sqrt(np.exp(distDict['StdDev']**2)*(np.exp(distDict['StdDev']**2)-1.))
    1421         mode = distDict['MinSize']+distDict['Mean']/np.exp(distDict['StdDev']**2)
    1422         minX = 1. #pos
    1423         maxX = 1.e4 #np.min([mode+nPoints*step*40,1.e5])
    14241405    elif 'Gauss' in DistName:
    14251406        distFxn = 'GaussDist'
    14261407        cumeFxn = 'GaussCume'
    1427         pos = distDict['Mean']
    1428         args = [distDict['StdDev']]
    1429         step = 0.02*distDict['StdDev']
    1430         mode = distDict['Mean']
    1431         minX = np.max([mode-4.*distDict['StdDev'],1.])
    1432         maxX = np.min([mode+4.*distDict['StdDev'],1.e5])
    14331408    elif 'LSW' in DistName:
    14341409        distFxn = 'LSWDist'
    14351410        cumeFxn = 'LSWCume'
    1436         pos = distDict['Mean']
    1437         args = []
    1438         minX,maxX = [0.,2.*pos]
    14391411    elif 'Schulz' in DistName:
    14401412        distFxn = 'SchulzZimmDist'
    14411413        cumeFxn = 'SchulzZimmCume'
    1442         pos = distDict['Mean']
    1443         args = [distDict['StdDev']]
    1444         minX = np.max([1.,pos-4.*distDict['StdDev']])
    1445         maxX = np.min([pos+4.*distDict['StdDev'],1.e5])
    14461414    nP = 500
    14471415    Diam = np.logspace(0.,5.,nP,True)
     
    14831451            raise Exception("file not found: " + filename)
    14841452        buf = [line.split() for line in open(filename, 'r').readlines()]
    1485         M = len(buf)
    14861453        buf = zip(*buf)         # transpose rows and columns
    14871454        q  = np.array(buf[0], dtype=np.float64)
  • trunk/GSASIIspc.py

    r2544 r2546  
    515515    UsymOp = []
    516516    OprFlg = [] 
    517     if Nsyms in [1,3]: NunqOp = 0       #Triclinic acentric OR trigonal 3
    518     elif Nsyms == 2:                    #Centric triclinic or acentric monoclinic
    519         NunqOp = 1
     517    if Nsyms == 2:                    #Centric triclinic or acentric monoclinic
    520518        UsymOp.append(OprNames[1])
    521519        OprFlg.append(SGData['SGGen'][1])
    522520    elif Nsyms == 4:                    #Point symmetry 2/m, 222, 22m, or 4
    523521        if '4z' in OprNames[1]:          #Point symmetry 4 or -4
    524             NunqOp = 1
    525522            UsymOp.append(OprNames[1])
    526523            OprFlg.append(SGData['SGGen'][1])
    527524        elif not SGData['SGInv']:       #Acentric Orthorhombic
    528525            if 'm' in OprNames[1:4]:    #22m, 2m2 or m22
    529                 NunqOp = 2
    530526                if '2' in OprNames[1]:      #Acentric orthorhombic, 2mm
    531527                    UsymOp.append(OprNames[2])
     
    544540                    OprFlg.append(SGData['SGGen'][2])
    545541            else:                           #Acentric orthorhombic, 222
    546                 NunqOp = -3
    547542                SGData['SGGen'][1:] = [4,2,1]
    548543                UsymOp.append(OprNames[1])
     
    553548                OprFlg.append(SGData['SGGen'][3])
    554549        else:                               #Centric Monoclinic
    555             NunqOp = 2
    556550            UsymOp.append(OprNames[1])
    557551            OprFlg.append(SGData['SGGen'][1])
     
    559553            OprFlg.append(SGData['SGGen'][3])
    560554    elif Nsyms == 6:                    #Point symmetry 32, 3m or 6
    561             NunqOp = 1
    562555            if '6' in OprNames[1]:      #Hexagonal 6/m Laue symmetry
    563556                UsymOp.append(OprNames[1])
     
    569562    elif Nsyms == 8:                    #Point symmetry mmm, 4/m, or 422, etc
    570563        if '4' in OprNames[1]:           #Tetragonal
    571             NunqOp = 2
    572564            if SGData['SGInv']:         #4/m
    573565                UsymOp.append(OprNames[1])
     
    587579                    OprFlg.append(19)
    588580        else:                               #Orthorhombic, mmm
    589             NunqOp = 3
    590581            UsymOp.append(OprNames[1])
    591582            OprFlg.append(SGData['SGGen'][1])
     
    595586            OprFlg.append(SGData['SGGen'][7])
    596587    elif Nsyms == 12 and '3' in OprNames[1] and SGData['SGSys'] != 'cubic':        #Trigonal
    597         NunqOp = 2
    598588        UsymOp.append(OprNames[3])
    599589        OprFlg.append(SGData['SGGen'][3])
     
    601591        OprFlg.append(SGData['SGGen'][9])
    602592    elif Nsyms == 12 and '6' in OprNames[1]:        #Hexagonal
    603         NunqOp = 2
    604593        if 'mz' in OprNames[9]:                     #6/m
    605594            UsymOp.append(OprNames[1])
     
    615604    elif Nsyms in [16,24]:
    616605        if '3' in OprNames[1]:
    617             NunqOp = 1
    618606            UsymOp.append('')
    619607            OprFlg.append(SGData['SGGen'][3])
     
    627615                    OprFlg[-1] = 24
    628616        else:                                     #4/mmm or 6/mmm
    629             NunqOp = 3
    630617            UsymOp.append('  mz  ')
    631618            OprFlg.append(1)
     
    642629    else:                                           #System is cubic
    643630        if Nsyms == 48:
    644             NunqOp = 2
    645631            UsymOp.append('  mx  ')
    646632            OprFlg.append(4)
    647633            UsymOp.append(' m110 ')
    648634            OprFlg.append(24)
    649         else:
    650             NunqOp = 0
    651635    ncv = len(SGData['SGCen'])
    652636    if ncv > 1:
  • trunk/GSASIIstrIO.py

    r2520 r2546  
    1212
    1313'''
    14 import sys
    1514import os
    1615import os.path as ospath
     
    1817import math
    1918import copy
    20 import random
    2119import cPickle
    2220import numpy as np
    2321import numpy.ma as ma
    24 import numpy.linalg as nl
    25 import scipy.optimize as so
    2622import GSASIIpath
    2723GSASIIpath.SetVersionNumber("$Revision$")
    2824import GSASIIElem as G2el
    29 import GSASIIgrid as G2gd
    3025import GSASIIlattice as G2lat
    3126import GSASIIspc as G2spc
     
    312307    '''       
    313308    fl = open(GPXfile,'rb')
    314     General = {}
    315     Atoms = []
    316309    while True:
    317310        try:
     
    787780            for i,mag in enumerate(RBmags):
    788781                name = '::RBV;'+str(i)+':'+str(irb)
    789                 mag = parmDict[name]
    790782                if name in sigDict:
    791783                    VectSig.append(sigDict[name])
     
    10781070    phaseVary = []
    10791071    phaseDict = {}
    1080     phaseConstr = {}
    10811072    pawleyLookup = {}
    10821073    FFtables = {}                   #scattering factors - xrays
     
    10841075    BLtables = {}                   # neutrons
    10851076    Natoms = {}
    1086     AtMults = {}
    1087     AtIA = {}
    10881077    maxSSwave = {}
    10891078    shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
     
    15161505                    print '    HKL  grid  neg esd  sum neg  num neg use unit?  unit esd  '
    15171506                    for hkl,grid,esd1,ifesd2,esd2 in itemRest[rest]:
    1518                         PH = np.array(hkl)
    15191507                        phi,beta = G2lat.CrsAng(np.array(hkl),cell,SGData)
    15201508                        ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)
     
    16861674                    print >>pFile,' atom: %s, site sym: %s, type: %s wave type: %s:'    \
    16871675                        %(at[ct-1],at[cs],Stype,waveType)
    1688                     line = ''
    16891676                    for iw,wave in enumerate(Waves):
    16901677                        stiw = ':'+str(i)+':'+str(iw)
     
    21762163    hapVary = []
    21772164    controlDict = {}
    2178     poType = {}
    2179     poAxes = {}
    2180     spAxes = {}
    2181     spType = {}
    21822165   
    21832166    for phase in Phases:
     
    22032186                limits = Histogram['Limits'][1]
    22042187                inst = Histogram['Instrument Parameters'][0]
    2205                 Zero = inst['Zero'][0]
    22062188                if 'C' in inst['Type'][1]:
    22072189                    try:
     
    22262208                    if hapData['HStrain'][1][i]:
    22272209                        hapVary.append(pfx+name)
    2228                 DIJS = G2spc.HStrainVals(HSvals,SGData)
    22292210                controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0]
    22302211                if hapData['Pref.Ori.'][0] == 'MD':
     
    30823063        Back = Background[0]
    30833064        DebyePeaks = Background[1]
    3084         lenBack = len(Back[3:])
    30853065        valstr = ' value : '
    30863066        sigstr = ' sig   : '
  • trunk/GSASIIstrMain.py

    r2500 r2546  
    1313########### SVN repository information ###################
    1414import sys
    15 import os
    1615import os.path as ospath
    1716import time
    1817import math
    1918import copy
    20 import random
    21 import cPickle
    2219import numpy as np
    23 import numpy.ma as ma
    2420import numpy.linalg as nl
    2521import scipy.optimize as so
     
    108104#            for item in table: print item,table[item]               #useful debug - are things shifting?
    109105            break                   #refinement succeeded - finish up!
    110         except TypeError,FloatingPointError:          #result[1] is None on singular matrix
     106        except TypeError:          #result[1] is None on singular matrix
    111107            IfOK = False
    112108            if not len(varyList):
     
    316312                saveVaryList[i] = item
    317313            SeqResult['varyList'] = saveVaryList
    318         origvaryList = varyList[:]
    319314        parmDict = {}
    320315        parmDict.update(phaseDict)
     
    493488        varyList = covData['varyList']
    494489        pfx = str(DisAglData['pId'])+'::'
    495         A = G2lat.cell2A(Cell[:6])
    496         cellSig = G2stIO.getCellEsd(pfx,SGData,A,covData)
    497         names = [' a = ',' b = ',' c = ',' alpha = ',' beta = ',' gamma = ',' Volume = ']
    498         valEsd = [G2mth.ValEsd(Cell[i],cellSig[i],True) for i in range(7)]
    499490       
    500491    Factor = DisAglCtls['Factors']
     
    579570    :param file out: file object for output. Defaults to sys.stdout.   
    580571    '''
    581     import numpy.ma as ma
    582572    def MyPrint(s):
    583573        out.write(s+'\n')
     
    608598    if 'covData' in DisAglData:   
    609599        covData = DisAglData['covData']
    610         covMatrix = covData['covMatrix']
    611         varyList = covData['varyList']
    612600        pfx = str(DisAglData['pId'])+'::'
    613601        A = G2lat.cell2A(Cell[:6])
     
    626614    AtomLabels,DistArray,AngArray = RetDistAngle(DisAglCtls,DisAglData)
    627615    origAtoms = DisAglData['OrigAtoms']
    628     targAtoms = DisAglData['TargAtoms']
    629616    for Oatom in origAtoms:
    630617        i = Oatom[0]
     
    673660    if 'covData' in DATData:   
    674661        covData = DATData['covData']
    675         covMatrix = covData['covMatrix']
    676         varyList = covData['varyList']
    677662        pfx = str(DATData['pId'])+'::'
    678663    Datoms = []
     
    752737            print 'ERROR - ',GPXfile," doesn't exist!"
    753738            exit()
    754         GPXpath = ospath.dirname(arg[1])
    755739        Refine(GPXfile,None)
    756740    else:
  • trunk/GSASIIstrMath.py

    r2539 r2546  
    1616import numpy.ma as ma
    1717import numpy.linalg as nl
    18 import scipy.optimize as so
    1918import scipy.stats as st
    2019import GSASIIpath
     
    148147    atxIds = ['dAx:','dAy:','dAz:']
    149148    atuIds = ['AU11:','AU22:','AU33:','AU12:','AU13:','AU23:']
    150     TIds = ['T11:','T22:','T33:','T12:','T13:','T23:']
    151     LIds = ['L11:','L22:','L33:','L12:','L13:','L23:']
    152     SIds = ['S12:','S13:','S21:','S23:','S31:','S32:','SAA:','SBB:']
    153     PIds = ['Px:','Py:','Pz:']
    154149    OIds = ['Oa:','Oi:','Oj:','Ok:']
    155150    RBIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})  #these are lists of rbIds
     
    177172        VModel = RBData['Vector'][RBObj['RBId']]
    178173        Q = RBObj['Orient'][0]
    179         Pos = RBObj['Orig'][0]
    180174        jrb = VRBIds.index(RBObj['RBId'])
    181175        rbsx = str(irb)+':'+str(jrb)
     
    238232    for irb,RBObj in enumerate(RBModels.get('Residue',[])):
    239233        Q = RBObj['Orient'][0]
    240         Pos = RBObj['Orig'][0]
    241234        jrb = RRBIds.index(RBObj['RBId'])
    242235        torData = RBData['Residue'][RBObj['RBId']]['rbSeq']
     
    521514                    hkl = np.array(hkl)
    522515                    if np.any(lasthkl-hkl):
    523                         PH = np.array(hkl)
    524516                        phi,beta = G2lat.CrsAng(np.array(hkl),cell,SGData)
    525517                        ODFln = G2lat.Flnh(False,SHCoef,phi,beta,SGData)
     
    556548                hkl = np.array(HKLs[int(pnames[3])])     
    557549                if np.any(lasthkl-hkl):
    558                     PH = np.array(hkl)
    559550                    phi,beta = G2lat.CrsAng(np.array(hkl),cell,SGData)
    560551                    SH3Coef = {}
     
    589580    IAdata = Natoms*[' ',]
    590581    Fdata = np.zeros(Natoms)
    591     FFdata = []
    592     BLdata = []
    593582    Xdata = np.zeros((3,Natoms))
    594583    dXdata = np.zeros((3,Natoms))
     
    718707#reflection processing begins here - big arrays!
    719708    iBeg = 0
    720     time0 = time.time()
    721709    while iBeg < nRef:
    722710        iFin = min(iBeg+blkSize,nRef)
     
    833821    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    834822    SGT = np.array([ops[1] for ops in SGData['SGOps']])
    835     Ncen = len(SGData['SGCen'])
    836     Nops = len(SGMT)
    837823    FFtables = calcControls['FFtables']
    838824    BLtables = calcControls['BLtables']
    839     MFtables = calcControls['MFtables']
    840825    Amat,Bmat = G2lat.Gmat2AB(G)
    841826    nRef = len(refDict['RefList'])
     
    862847        Flack = 1.-2.*parmDict[phfx+'Flack']
    863848    time0 = time.time()
    864     nref = len(refDict['RefList'])/100   
    865849#reflection processing begins here - big arrays!
    866850    iBeg = 0
     
    896880        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/len(SGMT)
    897881        Hij = np.array([Mast*np.multiply.outer(U,U) for U in np.reshape(Uniq,(-1,3))])
    898         Hij = np.reshape(np.array([G2lat.UijtoU6(Uij) for Uij in Hij]),(-1,len(SGT),6))
     882        Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(-1,len(SGT),6))
    899883        fot = np.reshape(((FF+FP).T-Bab).T,cosp.shape)*Tcorr
    900884        if len(FPP.shape) > 1:
     
    989973    :returns: dict dFdvDict: dictionary of derivatives
    990974    '''
    991     phfx = pfx.split(':')[0]+hfx
    992975    ast = np.sqrt(np.diag(G))
    993976    Mast = twopisq*np.multiply.outer(ast,ast)
     
    996979    Ncen = len(SGData['SGCen'])
    997980    Nops = len(SGMT)*Ncen*(1+SGData['SGInv'])
    998     MFtables = calcControls['MFtables']
    999981    Amat,Bmat = G2lat.Gmat2AB(G)
    1000982    nRef = len(refDict['RefList'])
     
    10291011    dFdua = np.zeros((nRef,mSize,6))
    10301012    time0 = time.time()
    1031     nref = len(refDict['RefList'])/100   
    10321013#reflection processing begins here - big arrays!
    10331014    iBeg = 0
     
    10481029        Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T
    10491030        Hij = np.array([Mast*np.multiply.outer(U,U) for U in np.reshape(Uniq,(-1,3))])
    1050         Hij = np.reshape(np.array([G2lat.UijtoU6(Uij) for Uij in Hij]),(-1,len(SGT),6))
     1031        Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(-1,len(SGT),6))
    10511032        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
    10521033        MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
     
    12121193        HbH = -np.sum(Uniq.T*np.swapaxes(np.inner(bij,Uniq),2,-1),axis=1)
    12131194        Hij = np.array([Mast*np.multiply.outer(U,U) for U in np.reshape(Uniq,(-1,3))])
    1214         Hij = np.reshape(np.array([G2lat.UijtoU6(Uij) for Uij in Hij]),(-1,nTwin,len(SGT),6))
     1195        Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(-1,nTwin,len(SGT),6))
    12151196        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)
    12161197        Tcorr = (np.reshape(Tiso,Tuij.shape)*Tuij).T*Mdata*Fdata/len(SGMT)
     
    12391220            dfbdfr = np.sum(np.sum(fb/occ,axis=-2),axis=0)        #Fdata != 0 avoids /0. problem
    12401221            dfadba /= 2.
    1241             dfbdba = np.sum(-sinp*Tcorr[:,nxs],axis=1)/2.
     1222#            dfbdba = np.sum(-sinp*Tcorr[:,nxs],axis=1)/2.
    12421223            dfbdui = np.sum(np.sum(-SQfactor[nxs,:,nxs,nxs,nxs]*fb,axis=-2),axis=0)
    12431224            dfbdx = np.sum(np.sum(twopi*Uniq[nxs,:,:,:,nxs,:]*fbx[:,:,:,:,:,nxs],axis=-3),axis=0)
     
    12481229            dfbdui = np.zeros_like(dfadui)
    12491230            dfbdua = np.zeros_like(dfadua)
    1250             dfbdba = np.zeros_like(dfadba)
     1231#            dfbdba = np.zeros_like(dfadba)
    12511232        SA = fas[0]+fas[1]
    12521233        SB = fbs[0]+fbs[1]
     
    13061287    SGInv = SGData['SGInv']
    13071288    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    1308     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    13091289    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    13101290    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
    13111291    FFtables = calcControls['FFtables']
    13121292    BLtables = calcControls['BLtables']
     1293    MFtables = calcControls['MFtables']
    13131294    Flack = 1.0
    13141295    if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict:
     
    14251406    SGInv = SGData['SGInv']
    14261407    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    1427     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    14281408    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    14291409    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
    14301410    FFtables = calcControls['FFtables']
    14311411    BLtables = calcControls['BLtables']
     1412    MFtables = calcControls['MFtables']
    14321413    Flack = 1.0
    14331414    if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict:
     
    15651546    SGInv = SGData['SGInv']
    15661547    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    1567     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    15681548    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    15691549    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
     
    16001580    dFdbab = np.zeros((nRef,2))
    16011581    dFdfl = np.zeros((nRef))
    1602     dFdtw = np.zeros((nRef))
    16031582    dFdGf = np.zeros((nRef,mSize,FSSdata.shape[1],2))
    16041583    dFdGx = np.zeros((nRef,mSize,XSSdata.shape[1],6))
     
    16361615        HbH = -np.sum(UniqP[:,nxs,:3]*np.inner(UniqP[:,:3],bij),axis=-1)  #ops x atoms
    16371616        Hij = np.array([Mast*np.multiply.outer(U[:3],U[:3]) for U in UniqP]) #atoms x 3x3
    1638         Hij = np.array([G2lat.UijtoU6(Uij) for Uij in Hij])                     #atoms x 6
     1617        Hij = np.array([G2lat.UijtoU6(uij) for uij in Hij])                     #atoms x 6
    16391618        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)     #ops x atoms
    16401619        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[0]  #ops x atoms
     
    18131792    dFdbab = np.zeros((nRef,2))
    18141793    dFdfl = np.zeros((nRef))
    1815     dFdtw = np.zeros((nRef))
    18161794    dFdGf = np.zeros((nRef,mSize,FSSdata.shape[1],2))
    18171795    dFdGx = np.zeros((nRef,mSize,XSSdata.shape[1],6))
     
    18381816            FP = np.repeat(FP.T,len(SGT),axis=0)
    18391817            FPP = np.repeat(FPP.T,len(SGT),axis=0)
    1840         dBabdA = np.exp(-parmDict[phfx+'BabU']*SQfactor)
     1818#        dBabdA = np.exp(-parmDict[phfx+'BabU']*SQfactor)
    18411819        Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT))
    18421820        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
     
    18591837        HbH = -np.sum(UniqP[:,:,nxs,:3]*np.inner(UniqP[:,:,:3],bij),axis=-1)  #ops x atoms
    18601838        Hij = np.array([Mast*np.multiply.outer(U[:3],U[:3]) for U in np.reshape(UniqP,(-1,3))]) #atoms x 3x3
    1861         Hij = np.reshape(np.array([G2lat.UijtoU6(Uij) for Uij in Hij]),(iFin-iBeg,-1,6))                     #atoms x 6
     1839        Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(iFin-iBeg,-1,6))                     #atoms x 6
    18621840        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)     #ops x atoms
    18631841#        GSASIIpath.IPyBreak()
     
    18831861        dfadfr = np.sum(fag/occ,axis=-2)        #Fdata != 0 ever avoids /0. problem
    18841862        dfbdfr = np.sum(fbg/occ,axis=-2)        #Fdata != 0 avoids /0. problem
    1885         dfadba = np.sum(-cosp*Tcorr,axis=-2)
    1886         dfbdba = np.sum(-sinp*Tcorr,axis=-2)
     1863#        dfadba = np.sum(-cosp*Tcorr,axis=-2)
     1864#        dfbdba = np.sum(-sinp*Tcorr,axis=-2)
    18871865        dfadui = np.sum(-SQfactor[nxs,:,nxs,nxs]*fag,axis=-2)
    18881866        dfbdui = np.sum(-SQfactor[nxs,:,nxs,nxs]*fbg,axis=-2)
     
    20001978    SGInv = SGData['SGInv']
    20011979    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    2002     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    20031980    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    20041981    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
     
    20111988        NM = calcControls[phfx+'TwinNMN']+1
    20121989        TwinLaw = calcControls[phfx+'TwinLaw']
    2013         TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))])
    20141990        TwinInv = list(np.where(calcControls[phfx+'TwinInv'],-1,1))
    20151991    nTwin = len(TwinLaw)       
     
    20432019    dFdua = np.zeros((nRef,nTwin,mSize,6))
    20442020    dFdbab = np.zeros((nRef,nTwin,2))
    2045     dFdfl = np.zeros((nRef,nTwin))
    20462021    dFdtw = np.zeros((nRef,nTwin))
    20472022    dFdGf = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1]))
     
    20882063        HbH = -np.sum(UniqP[:,nxs,:3]*np.inner(UniqP[:,:3],bij),axis=-1)  #ops x atoms
    20892064        Hij = np.array([Mast*np.multiply.outer(U[:3],U[:3]) for U in UniqP]) #atoms x 3x3
    2090         Hij = np.squeeze(np.reshape(np.array([G2lat.UijtoU6(Uij) for Uij in Hij]),(nTwin,-1,6)))
     2065        Hij = np.squeeze(np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(nTwin,-1,6)))
    20912066        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)     #ops x atoms
    20922067        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[0]  #ops x atoms
     
    21292104        dfbdGu = np.sum(fb[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
    21302105#        GSASIIpath.IPyBreak()
    2131         if not SGData['SGInv'] and len(TwinLaw) == 1:   #Flack derivative
    2132             dfadfl = np.sum(-FPP*Tcorr*sinp)
    2133             dfbdfl = np.sum(FPP*Tcorr*cosp)
    2134         else:
    2135             dfadfl = 1.0
    2136             dfbdfl = 1.0
    21372106        #NB: the above have been checked against PA(1:10,1:2) in strfctr.for for Al2O3!   
    21382107        SA = fas[0]+fas[1]      #float = A+A' (might be array[nTwin])
     
    27802749            sigDict[phfx+'Mustrain;a'] = 2*(Mgam/Sa+dsa)*Mgam*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2       
    27812750        else:       #generalized - P.W. Stephens model OK
    2782             pwrs = calcControls[phfx+'MuPwrs']
    27832751            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
    27842752            const = 1.e-6*parmDict[hfx+'difC']*refl[4+im]**3
     
    31023070        if Phase['General'].get('Modulated',False):
    31033071            SSGData = Phase['General']['SSGData']
    3104             SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    31053072            im = 1  #offset in SS reflection list
    31063073            #??
     
    31133080        Vst = np.sqrt(nl.det(G))    #V*
    31143081        if not Phase['General'].get('doPawley'):
    3115             time0 = time.time()
    31163082            if im:
    31173083                SStructureFactor(refDict,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
     
    31193085                StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
    31203086#            print 'sf calc time: %.3fs'%(time.time()-time0)
    3121         time0 = time.time()
    31223087        badPeak = False
    31233088        for iref,refl in enumerate(refDict['RefList']):
     
    32343199        depDerivDict[j] = np.zeros(shape=(len(x)))
    32353200    #print 'dependent vars',dependentVars
    3236     lenX = len(x)               
    32373201    hId = Histogram['hId']
    32383202    hfx = ':%d:'%(hId)
     
    32813245        if Phase['General'].get('Modulated',False):
    32823246            SSGData = Phase['General']['SSGData']
    3283             SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    32843247            im = 1  #offset in SS reflection list
    32853248            #??
     
    32923255        GA,GB = G2lat.Gmat2AB(G)    #Orthogonalization matricies
    32933256        if not Phase['General'].get('doPawley'):
    3294             time0 = time.time()
    32953257            if im:
    32963258                dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict)
     
    33023264#            print 'sf-derv time %.3fs'%(time.time()-time0)
    33033265            ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase)
    3304         time0 = time.time()
    33053266        for iref,refl in enumerate(refDict['RefList']):
    33063267            if im:
     
    35373498    :returns:
    35383499    '''
    3539     nobs = Histogram['Residuals']['Nobs']
    35403500    hId = Histogram['hId']
    35413501    hfx = ':%d:'%(hId)
     
    35463506    if Phase['General'].get('Modulated',False):
    35473507        SSGData = Phase['General']['SSGData']
    3548         SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    35493508        im = 1  #offset in SS reflection list
    35503509    A = [parmDict[pfx+'A%d'%(i)] for i in range(6)]
     
    36473606    G2mv.Dict2Map(parmDict,varylist)
    36483607    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
    3649     nvar = len(varylist)
    36503608    dMdv = np.empty(0)
    36513609    histoList = Histograms.keys()
     
    37023660    #fixup H atom positions here?
    37033661    ApplyRBModels(parmDict,Phases,rigidbodyDict)        #,Update=True??
    3704     nvar = len(varylist)
    37053662    Hess = np.empty(0)
     3663    Vec = np.empty(0)
    37063664    histoList = Histograms.keys()
    37073665    histoList.sort()
     
    38403798            if Phase['General'].get('Modulated',False):
    38413799                SSGData = Phase['General']['SSGData']
    3842                 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    38433800                im = 1  #offset in SS reflection list
    38443801            A = [parmDict[pfx+'A%d'%(i)] for i in range(6)]
    38453802            G,g = G2lat.A2Gmat(A)       #recip & real metric tensors
    38463803            refDict = Histogram['Data']
    3847             time0 = time.time()
    38483804            if im:
    38493805                if len(TwinLaw) > 1:
  • trunk/imports/G2img_1TIF.py

    r2539 r2546  
    134134        elif Type == 3:
    135135            Value = st.unpack(byteOrd+nVal*'h',File.read(nVal*2))
     136            st.unpack(byteOrd+nVal*'h',File.read(nVal*2))
    136137        elif Type == 4:
    137138            if Tag in [273,279]:
Note: See TracChangeset for help on using the changeset viewer.