Changeset 4763 for trunk/GSASIImath.py


Ignore:
Timestamp:
Jan 13, 2021 4:34:34 PM (11 months ago)
Author:
vondreele
Message:

cleanup tif import for PIL use - remove commented lines
move getAtomPtrs from G2phsGUI to G2math & correct all ses; add a few new ones as well
Add new Atoms/Edit? Atoms/Collect? atoms - it moves atoms to equivalents closest to x, y, z axes, origin or cell center

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r4761 r4763  
    558558################################################################################
    559559
     560def getAtomPtrs(data,draw=False):
     561    ''' get atom data pointers cx,ct,cs,cia in Atoms or Draw Atoms lists
     562    NB:may not match column numbers in displayed table
     563   
     564        param: dict: data phase data structure
     565        draw: boolean True if Draw Atoms list pointers are required
     566        return: cx,ct,cs,cia pointers to atom xyz, type, site sym, uiso/aniso flag
     567    '''
     568    if draw:
     569        return data['Drawing']['atomPtrs']
     570    else:
     571        return data['General']['AtomPtrs']
     572
    560573def FindMolecule(ind,generalData,atomData):                    #uses numpy & masks - very fast even for proteins!
    561574
     
    752765    generalData = data['General']
    753766    SGData = generalData['SGData']
    754     cx,ct,cs,cia = generalData['AtomPtrs']
     767    cx,ct,cs,cia = getAtomPtrs(data)
    755768    drawingData = data['Drawing']
    756     dcx,dct,dcs,dci = drawingData['atomPtrs']
     769    dcx,dct,dcs,dci = getAtomPtrs(data,True)
    757770    atoms = data['Atoms']
    758771    drawAtoms = drawingData['Atoms']
     
    785798def FindNeighbors(phase,FrstName,AtNames,notName=''):
    786799    General = phase['General']
    787     cx,ct,cs,cia = General['AtomPtrs']
     800    cx,ct,cs,cia = getAtomPtrs(phase)
    788801    Atoms = phase['Atoms']
    789802    atNames = [atom[ct-1] for atom in Atoms]
     
    873886def FindAllNeighbors(phase,FrstName,AtNames,notName='',Orig=None,Short=False):
    874887    General = phase['General']
    875     cx,ct,cs,cia = General['AtomPtrs']
     888    cx,ct,cs,cia = getAtomPtrs(phase)
    876889    Atoms = phase['Atoms']
    877890    atNames = [atom[ct-1] for atom in Atoms]
     
    18851898    SGData = generalData['SGData']
    18861899    SSGData = generalData['SSGData']
    1887     cx,ct,cs,cia = generalData['AtomPtrs']
     1900    cx,ct,cs,cia = getAtomPtrs(data)
    18881901    drawingData = data['Drawing']
    18891902    modul = generalData['SuperVec'][0]
    1890     dcx,dct,dcs,dci = drawingData['atomPtrs']
     1903    dcx,dct,dcs,dci = getAtomPtrs(data,True)
    18911904    atoms = data['Atoms']
    18921905    drawAtoms = drawingData['Atoms']
     
    29432956    General = Phase['General']
    29442957    Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7])
    2945     cx,ct,cs,cia = General['AtomPtrs']
     2958    cx,ct,cs,cia = getAtomPtrs(data)
    29462959    Atoms = Phase['Atoms']
    29472960    cartAtoms = []
     
    41474160            Unique.append(icntr)
    41484161    return Unique
     4162
     4163def AtomsCollect(data,Ind,Sel):
     4164    '''Finds the symmetry set of atoms for those selected. Selects
     4165    the one closest to the selected part of the unit cell.
     4166    Works on the contents of data['Map Peaks']. Called from OnPeaksUnique in
     4167    GSASIIphsGUI.py,
     4168
     4169    :param data: the phase data structure
     4170    :param list Ind: list of selected peak indices
     4171    :param int Sel: selected part of unit to find atoms closest to
     4172
     4173    :returns: the list of symmetry unique peaks from among those given in Ind
     4174    '''       
     4175    cx,ct,cs,ci = getAtomPtrs(data)
     4176    cent = np.ones(3)*.5     
     4177    generalData = data['General']
     4178    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     4179    SGData = generalData['SGData']
     4180    Atoms = copy.deepcopy(data['Atoms'])
     4181    Indx = [True for ind in Ind]
     4182    # scan through peaks, finding all peaks equivalent to peak ind
     4183    for ind in Ind:
     4184        if Indx[ind]:
     4185            xyz = Atoms[ind][cx:cx+3]
     4186            uij = Atoms[ind][ci+2:ci+8]
     4187            if Atoms[ind][ci] == 'A':
     4188                Equiv = list(G2spc.GenAtom(xyz,SGData,Uij=uij))
     4189                Uijs = np.array([x[1] for x in Equiv])
     4190            else:
     4191                Equiv = G2spc.GenAtom(xyz,SGData)
     4192            xyzs = np.array([x[0] for x in Equiv])
     4193            dzeros = np.sqrt(np.sum(np.inner(Amat,xyzs)**2,axis=0))
     4194            dcent = np.sqrt(np.sum(np.inner(Amat,xyzs-cent)**2,axis=0))
     4195            xyzs = np.hstack((xyzs,dzeros[:,nxs],dcent[:,nxs]))
     4196            cind = np.argmin(xyzs.T[Sel-1])
     4197            Atoms[ind][cx:cx+3] = xyzs[cind][:3]
     4198            if Atoms[ind][ci] == 'A':
     4199                Atoms[ind][ci+2:ci+8] = Uijs[cind]
     4200    return Atoms
    41494201
    41504202################################################################################
     
    50615113    SGT = np.array([SGData['SGOps'][i][1] for i in range(len(SGData['SGOps']))])
    50625114    fixAtoms = data['Atoms']                       #if any
    5063     cx,ct,cs = generalData['AtomPtrs'][:3]
     5115    cx,ct,cs = getAtomPtrs(data)[:3]
    50645116    aTypes = set([])
    50655117    parmDict = {'Bmat':Bmat,'Gmat':Gmat}
Note: See TracChangeset for help on using the changeset viewer.