Changeset 4792


Ignore:
Timestamp:
Feb 2, 2021 11:01:51 AM (9 months ago)
Author:
toby
Message:

check in changes to allow cctbx to use DoIndexPeaks and !refinePeaks

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIindex.py

    r4791 r4792  
    787787    return len(HKL),M20,X20,Aref,Vref,Z
    788788   
    789 def refinePeaks(peaks,ibrav,A,ifX20=True,sg_type=None):
     789def refinePeaks(peaks,ibrav,A,ifX20=True,cctbx_args=None):
    790790    'needs a doc string'
    791791    dmin = getDmin(peaks)
     
    795795    OK = False
    796796    tries = 0
    797     sg_type = G2lat.make_sgtype(ibrav)
    798     HKL = G2lat.GenHBravais(dmin,ibrav,A,sg_type)
     797    HKL = G2lat.GenHBravais(dmin,ibrav,A,cctbx_args)
    799798    while len(HKL) > 2 and IndexPeaks(peaks,HKL)[0]:
    800799        Pwr = pwr - (tries % 2)
     
    811810            continue
    812811        try:
    813             HKL = G2lat.GenHBravais(dmin,ibrav,A,sg_type)
     812            HKL = G2lat.GenHBravais(dmin,ibrav,A,cctbx_args)
    814813        except FloatingPointError:
    815814            A = oldA
  • trunk/GSASIIlattice.py

    r4791 r4792  
    11141114    raise ValueError('non-standard Bravais lattice center=%s, cell=%s' % (center,system))
    11151115
    1116 def GenHBravais(dmin,Bravais,A, sg_type=None):
     1116def _GenHBravais_cctbx(dmin, Bravais, A, sg_type, uctbx_unit_cell, miller_index_generator):
     1117    '''Alternate form of :func:`GenHBravais` that uses CCTBX internals
     1118    '''
     1119    g_inv = np.array([[A[0],   A[3]/2, A[4]/2],
     1120                      [A[3]/2, A[1],   A[5]/2],
     1121                      [A[4]/2, A[5]/2, A[2]]])
     1122    g = np.linalg.inv(g_inv)
     1123    g_elems = (g[0][0], g[1][1], g[2][2], g[0][1], g[0][2], g[1][2])
     1124    try:
     1125        uc = uctbx_unit_cell(metrical_matrix=g_elems)
     1126    except ValueError: # this function sometimes receives an A matrix that gives
     1127                           # numbers <0 in the diagonal elems of g. Not sure why.
     1128        return []
     1129    #if sg_type is None:
     1130    #    sg_type = make_sgtype(Bravais)
     1131    mig = miller_index_generator(uc, sg_type, 0, dmin)
     1132    result = []
     1133    for h,k,l in mig:
     1134        d = uc.d((h,k,l))
     1135        result.append([h, k, l, d, -1])
     1136    result.sort(key=lambda l: l[3], reverse=True)
     1137    return result
     1138
     1139def GenHBravais(dmin, Bravais, A, cctbx_args=None):
    11171140    """Generate the positionally unique powder diffraction reflections
    11181141     
     
    11391162           
    11401163    :param A: reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
    1141     :param sg_type: alternate specification for Bravais lattice used in CCTBX
    1142     :return: HKL unique d list of [h,k,l,d,-1] sorted with largest d first
     1164    :param dict cctbx_args: items defined in CCTBX:
     1165
     1166         * 'sg_type': value from cctbx.sgtbx.space_group_type(symmorphic_sgs[ibrav])
     1167         * 'uctbx_unit_cell': pointer to :meth:`cctbx.uctbx.unit_cell`
     1168         * 'miller_index_generator':  pointer to :meth:`cctbx.miller.index_generator`
     1169
     1170    :returns: HKL unique d list of [h,k,l,d,-1] sorted with largest d first
    11431171           
    11441172    """
     1173    if cctbx_args:
     1174        return _GenHBravais_cctbx(dmin, Bravais, A,
     1175                    cctbx_args['sg_type'], cctbx_args['uctbx_unit_cell'], cctbx_args['miller_index_generator'])
     1176   
    11451177    if Bravais in [9,]:
    11461178        Cent = 'A'
Note: See TracChangeset for help on using the changeset viewer.