Changeset 3806 for trunk/GSASIIobj.py
- Timestamp:
- Jan 30, 2019 5:15:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIobj.py
r3802 r3806 1012 1012 ''' 1013 1013 1014 VarDesc = {} 1015 ''' This dictionary lists descriptions for GSAS-II variables, 1016 as set in :func:`CompileVarDesc`. See that function for a description 1017 for how keys and values are written. 1014 #VarDesc = {} # removed 1/30/19 BHT as no longer needed (I think) 1015 #''' This dictionary lists descriptions for GSAS-II variables, 1016 #as set in :func:`CompileVarDesc`. See that function for a description 1017 #for how keys and values are written. 1018 #''' 1019 1020 reVarDesc = {} 1021 ''' This dictionary lists descriptions for GSAS-II variables where 1022 keys are compiled regular expressions that will match the name portion 1023 of a parameter name. Initialized in :func:`CompileVarDesc`. 1018 1024 ''' 1019 1025 1020 reVarDesc = {} 1021 ''' This dictionary lists descriptions for GSAS-II variables with 1022 the same values as :attr:`VarDesc` except that keys have been compiled as 1023 regular expressions. Initialized in :func:`CompileVarDesc`. 1026 reVarStep = {} 1027 ''' This dictionary lists the preferred step size for numerical 1028 derivative computation w/r to a GSAS-II variable. Keys are compiled 1029 regular expressions and values are the step size for that parameter. 1030 Initialized in :func:`CompileVarDesc`. 1024 1031 ''' 1025 1032 # create a default space group object for P1; N.B. fails when building documentation … … 1309 1316 ''' 1310 1317 1311 # special handling for parameter names without a colon s1318 # special handling for parameter names without a colon 1312 1319 # for now, assume self-defining 1313 1320 if varname.find(':') == -1: … … 1412 1419 1413 1420 def CompileVarDesc(): 1414 '''Set the values in the variable description lookup table (:attr:`VarDesc`) 1415 into :attr:`reVarDesc`. This is called in :func:`getDescr` so the initialization 1416 is always done before use. 1421 '''Set the values in the variable lookup tables 1422 (:attr:`reVarDesc` and :attr:`reVarStep`). 1423 This is called in :func:`getDescr` and :func:`getVarStep` so this 1424 initialization is always done before use. 1417 1425 1418 1426 Note that keys may contain regular expressions, where '[xyz]' 1419 matches 'x' 'y' or 'z' (equivalently '[x-z]' describes this as range of values).1420 '.*' matches any string. For example::1427 matches 'x' 'y' or 'z' (equivalently '[x-z]' describes this as range 1428 of values). '.*' matches any string. For example:: 1421 1429 1422 1430 'AUiso':'Atomic isotropic displacement parameter', … … 1442 1450 'Scale' : 'Phase or Histogram scale factor', 1443 1451 # Phase vars (p::<var>) 1444 'A([0-5])' : 'Reciprocal metric tensor component \\1',1452 'A([0-5])' : ('Reciprocal metric tensor component \\1',1e-5), 1445 1453 '[vV]ol' : 'Unit cell volume', # probably an error that both upper and lower case are used 1446 1454 # Atom vars (p::<var>:a) 1447 'dA([xyz])$' : 'change to atomic coordinate, \\1',1455 'dA([xyz])$' : ('change to atomic coordinate, \\1',1e-6), 1448 1456 'A([xyz])$' : '\\1 fractional atomic coordinate', 1449 'AUiso': 'Atomic isotropic displacement parameter',1450 'AU([123][123])': 'Atomic anisotropic displacement parameter U\\1',1451 'Afrac': 'Atomic site fraction parameter',1457 'AUiso':('Atomic isotropic displacement parameter',1e-4), 1458 'AU([123][123])':('Atomic anisotropic displacement parameter U\\1',1e-4), 1459 'Afrac': ('Atomic site fraction parameter',1e-5), 1452 1460 'Amul': 'Atomic site multiplicity value', 1453 1461 'AM([xyz])$' : 'Atomic magnetic moment parameter, \\1', … … 1472 1480 #Histogram vars (:h:<var>) 1473 1481 'Absorption' : 'Absorption coef.', 1474 'Displace([XY])' : 'Debye-Scherrer sample displacement \\1',1475 'Lam' : 'Wavelength',1476 'I\(L2\)\/I\(L1\)' : 'Ka2/Ka1 intensity ratio',1477 'Polariz\.' : 'Polarization correction',1478 'SH/L' : 'FCJ peak asymmetry correction',1479 '([UVW])$' : 'Gaussian instrument broadening \\1',1480 '([XYZ])$' : 'Cauchy instrument broadening \\1',1482 'Displace([XY])' : ('Debye-Scherrer sample displacement \\1',0.1), 1483 'Lam' : ('Wavelength',1e-6), 1484 'I\(L2\)\/I\(L1\)' : ('Ka2/Ka1 intensity ratio',0.001), 1485 'Polariz\.' : ('Polarization correction',1e-3), 1486 'SH/L' : ('FCJ peak asymmetry correction',1e-4), 1487 '([UVW])$' : ('Gaussian instrument broadening \\1',1e-5), 1488 '([XYZ])$' : ('Cauchy instrument broadening \\1',1e-5), 1481 1489 'Zero' : 'Debye-Scherrer zero correction', 1482 1490 'Shift' : 'Bragg-Brentano sample displ.', … … 1550 1558 'C\([0-9]*,[0-9]*\)' : 'spherical harmonics preferred orientation coef.', 1551 1559 }.items(): 1552 VarDesc[key] = value 1553 reVarDesc[re.compile(key)] = value 1560 if len(value) == 2: 1561 #VarDesc[key] = value[0] 1562 reVarDesc[re.compile(key)] = value[0] 1563 reVarStep[re.compile(key)] = value[1] 1564 else: 1565 #VarDesc[key] = value 1566 reVarDesc[re.compile(key)] = value 1554 1567 1555 1568 def removeNonRefined(parmList): … … 1586 1599 return m.expand(reVarDesc[key]) 1587 1600 return None 1601 1602 def getVarStep(name,parmDict=None): 1603 '''Return a step size for computing the derivative of a GSAS-II variable 1604 1605 :param str name: A complete variable name (with colons, :) 1606 :param dict parmDict: A dict with parameter values or None (default) 1607 1608 :returns: a float that should be an appropriate step size, either from 1609 the value supplied in :func:`CompileVarDesc` or based on the value for 1610 name in parmDict, if supplied. If not found or the value is zero, 1611 a default value of 1e-5 is used. If parmDict is None (default) and 1612 no value is provided in :func:`CompileVarDesc`, then None is returned. 1613 ''' 1614 CompileVarDesc() # compile the regular expressions, if needed 1615 for key in reVarStep: 1616 m = key.match(name) 1617 if m: 1618 return reVarStep[key] 1619 if parmDict is None: return None 1620 val = parmDict.get(key,0.0) 1621 if abs(val) > 0.05: 1622 return abs(val)/1000. 1623 else: 1624 return 1e-5 1588 1625 1589 1626 def GenWildCard(varlist): … … 2744 2781 print (70*'*') 2745 2782 2783 # Note that this is GUI code and should be moved at somepoint 2746 2784 def CreatePDFitems(G2frame,PWDRtree,ElList,Qlimits,numAtm=1,FltBkg=0,PDFnames=[]): 2747 2785 '''Create and initialize a new set of PDF tree entries … … 2828 2866 2829 2867 if __name__ == "__main__": 2868 # test variable descriptions 2869 for var in '0::Afrac:*',':1:Scale','1::dAx:0','::undefined': 2870 v = var.split(':')[2] 2871 print(var+':\t', getDescr(v),getVarStep(v)) 2872 import sys; sys.exit() 2830 2873 # test equation evaluation 2831 2874 def showEQ(calcobj):
Note: See TracChangeset
for help on using the changeset viewer.