Changeset 4553 for trunk/GSASIImath.py


Ignore:
Timestamp:
Aug 21, 2020 10:17:41 AM (3 years ago)
Author:
vondreele
Message:

reimplement new PeaksUnique? code & make more general. Now finds unique peaks closest to x=0, y=0, z=0, origin or center.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r4547 r4553  
    39033903    return Ind
    39043904               
    3905 def PeaksUnique(data,Ind):
     3905def PeaksUnique(data,Ind,Sel):
    39063906    '''Finds the symmetry unique set of peaks from those selected. Selects
    39073907    the one closest to the center of the unit cell.
     
    39113911    :param data: the phase data structure
    39123912    :param list Ind: list of selected peak indices
     3913    :param int Sel: selected column to find peaks closest to
    39133914
    39143915    :returns: the list of symmetry unique peaks from among those given in Ind
     
    39243925    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    39253926    SGData = generalData['SGData']
    3926     mapPeaks = data['Map Peaks']
    3927    
    3928    
    3929     Indx = {}
    3930     XYZ = {}
    3931     for ind in Ind:
    3932         XYZ[ind] = np.array(mapPeaks[ind][1:4])
    3933         Indx[ind] = True
     3927    mapPeaks = data['Map Peaks']   
     3928    XYZ = {ind:np.array(mapPeaks[ind][1:4]) for ind in Ind}
     3929    Indx = [True for ind in Ind]
     3930    Unique = []
     3931    # scan through peaks, finding all peaks equivalent to peak ind
    39343932    for ind in Ind:
    39353933        if Indx[ind]:
    39363934            xyz = XYZ[ind]
     3935            dups = []
    39373936            for jnd in Ind:
    3938                 if ind != jnd and Indx[jnd]:                       
     3937                # only consider peaks we have not looked at before
     3938                # and were not already found to be equivalent
     3939                if jnd > ind and Indx[jnd]:                       
    39393940                    Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True)
    39403941                    xyzs = np.array([equiv[0] for equiv in Equiv])
    3941                     Indx[jnd] = noDuplicate(xyz,xyzs,Amat)
    3942     Ind = []
    3943     for ind in Indx:
    3944         if Indx[ind]:
    3945             Ind.append(ind)
    3946     return Ind
    3947    
    3948    
    3949    
    3950    
    3951    
    3952    
    3953     # XYZ = {ind:np.array(mapPeaks[ind][1:4]) for ind in Ind}
    3954     # Indx = [True for ind in Ind]
    3955     # Unique = []
    3956     # # scan through peaks, finding all peaks equivalent to peak ind
    3957     # for ind in Ind:
    3958     #     if Indx[ind]:
    3959     #         xyz = XYZ[ind]
    3960     #         dups = []
    3961     #         for jnd in Ind:
    3962     #             # only consider peaks we have not looked at before
    3963     #             # and were not already found to be equivalent
    3964     #             if jnd > ind and Indx[jnd]:                       
    3965     #                 Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True)
    3966     #                 xyzs = np.array([equiv[0] for equiv in Equiv])
    3967     #                 if not noDuplicate(xyz,xyzs,Amat):
    3968     #                     Indx[jnd] = False
    3969     #                     dups.append(jnd)
    3970     #                 Indx[jnd] = noDuplicate(xyz,xyzs,Amat)
    3971     # #        # select the unique peak closest to cell center
    3972     # #         cntr = mapPeaks[ind][-1]
    3973     # #         icntr = ind
    3974     # #         for jnd in dups:
    3975     # #             if mapPeaks[jnd][-1] < cntr:
    3976     # #                 cntr = mapPeaks[jnd][-1]
    3977     # #                 icntr = jnd
    3978     # #         Unique.append(icntr)
    3979     # # return Unique
    3980     # Ind = []
    3981     # for ind in Indx:
    3982     #     if Indx[ind]:
    3983     #         Ind.append(ind)
    3984     # return Ind
     3942                    if not noDuplicate(xyz,xyzs,Amat):
     3943                        Indx[jnd] = False
     3944                        dups.append(jnd)
     3945            # select the unique peak closest to cell center
     3946            cntr = mapPeaks[ind][Sel]
     3947            icntr = ind
     3948            for jnd in dups:
     3949                if mapPeaks[jnd][Sel] < cntr:
     3950                    cntr = mapPeaks[jnd][Sel]
     3951                    icntr = jnd
     3952            Unique.append(icntr)
     3953    return Unique
     3954
    39853955################################################################################
    39863956##### Dysnomia setup & return stuff
Note: See TracChangeset for help on using the changeset viewer.