- Timestamp:
- Feb 19, 2021 2:24:19 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwd.py
r4800 r4821 72 72 nxs = np.newaxis 73 73 74 ################################################################################ 75 #### Powder utilities 76 ################################################################################ 77 74 #### Powder utilities ################################################################################ 78 75 def PhaseWtSum(G2frame,histo): 79 76 ''' … … 95 92 return wtSum 96 93 97 ################################################################################ 98 #### GSASII pwdr & pdf calculation routines 99 ################################################################################ 100 94 #### GSASII pwdr & pdf calculation routines ################################################################################ 101 95 def Transmission(Geometry,Abs,Diam): 102 96 ''' … … 628 622 return EvalLowPDF,GetCurrentVals,SetFinalVals 629 623 630 ################################################################################ 631 #### GSASII peak fitting routines: Finger, Cox & Jephcoat model 632 ################################################################################ 633 624 #### GSASII peak fitting routines: Finger, Cox & Jephcoat model ################################################################################ 634 625 def factorize(num): 635 626 ''' Provide prime number factors for integer num … … 1279 1270 return G2lat.sortHKLd(HKLs,True,True,True) 1280 1271 1272 peakInstPrmMode = True 1273 '''Determines the mode used for peak fitting. When peakInstPrmMode=True peak 1274 width parameters are computed from the instrument parameters (UVW,... or 1275 alpha,... etc) unless the individual parameter is refined. This allows the 1276 instrument parameters to be refined. When peakInstPrmMode=False, the instrument 1277 parameters are not used and cannot be refined. 1278 The default is peakFitMode=True. 1279 ''' 1280 1281 def setPeakInstPrmMode(normal=True): 1282 '''Determines the mode used for peak fitting. If normal=True (default) 1283 peak width parameters are computed from the instrument parameters 1284 unless the individual parameter is refined. If normal=False, 1285 peak widths are used as supplied for each peak. 1286 1287 Note that normal=True unless this routine is called. Also, 1288 instrument parameters can only be refined with normal=True. 1289 1290 :param bool normal: setting to apply to global variable :var:`peakInstPrmMode` 1291 ''' 1292 global peakInstPrmMode 1293 peakInstPrmMode = normal 1294 1281 1295 def getPeakProfile(dataType,parmDict,xdata,fixback,varyList,bakType): 1282 1296 'Computes the profile for a powder pattern' … … 1300 1314 intens = parmDict['int'+str(iPeak)] 1301 1315 sigName = 'sig'+str(iPeak) 1302 if sigName in varyList :1316 if sigName in varyList or not peakInstPrmMode: 1303 1317 sig = parmDict[sigName] 1304 1318 else: … … 1306 1320 sig = max(sig,0.001) #avoid neg sigma^2 1307 1321 gamName = 'gam'+str(iPeak) 1308 if gamName in varyList :1322 if gamName in varyList or not peakInstPrmMode: 1309 1323 gam = parmDict[gamName] 1310 1324 else: … … 1338 1352 intens = parmDict['int'+str(iPeak)] 1339 1353 alpName = 'alp'+str(iPeak) 1340 if alpName in varyList :1354 if alpName in varyList or not peakInstPrmMode: 1341 1355 alp = parmDict[alpName] 1342 1356 else: … … 1344 1358 alp = max(0.1,alp) 1345 1359 betName = 'bet'+str(iPeak) 1346 if betName in varyList :1360 if betName in varyList or not peakInstPrmMode: 1347 1361 bet = parmDict[betName] 1348 1362 else: … … 1350 1364 bet = max(0.1,bet) 1351 1365 sigName = 'sig'+str(iPeak) 1352 if sigName in varyList :1366 if sigName in varyList or not peakInstPrmMode: 1353 1367 sig = parmDict[sigName] 1354 1368 else: … … 1356 1370 sig = max(sig,0.001) #avoid neg sigma^2 1357 1371 gamName = 'gam'+str(iPeak) 1358 if gamName in varyList :1372 if gamName in varyList or not peakInstPrmMode: 1359 1373 gam = parmDict[gamName] 1360 1374 else: … … 1384 1398 intens = parmDict['int'+str(iPeak)] 1385 1399 alpName = 'alp'+str(iPeak) 1386 if alpName in varyList :1400 if alpName in varyList or not peakInstPrmMode: 1387 1401 alp = parmDict[alpName] 1388 1402 else: … … 1393 1407 alp = max(0.1,alp) 1394 1408 betName = 'bet'+str(iPeak) 1395 if betName in varyList :1409 if betName in varyList or not peakInstPrmMode: 1396 1410 bet = parmDict[betName] 1397 1411 else: … … 1402 1416 bet = max(0.0001,bet) 1403 1417 sigName = 'sig'+str(iPeak) 1404 if sigName in varyList :1418 if sigName in varyList or not peakInstPrmMode: 1405 1419 sig = parmDict[sigName] 1406 1420 else: 1407 1421 sig = G2mth.getTOFsig(parmDict,dsp) 1408 1422 gamName = 'gam'+str(iPeak) 1409 if gamName in varyList :1423 if gamName in varyList or not peakInstPrmMode: 1410 1424 gam = parmDict[gamName] 1411 1425 else: … … 1467 1481 intens = parmDict['int'+str(iPeak)] 1468 1482 sigName = 'sig'+str(iPeak) 1469 if sigName in varyList :1483 if sigName in varyList or not peakInstPrmMode: 1470 1484 sig = parmDict[sigName] 1471 1485 dsdU = dsdV = dsdW = 0 … … 1475 1489 sig = max(sig,0.001) #avoid neg sigma 1476 1490 gamName = 'gam'+str(iPeak) 1477 if gamName in varyList :1491 if gamName in varyList or not peakInstPrmMode: 1478 1492 gam = parmDict[gamName] 1479 1493 dgdX = dgdY = dgdZ = 0 … … 1540 1554 intens = parmDict['int'+str(iPeak)] 1541 1555 alpName = 'alp'+str(iPeak) 1542 if alpName in varyList :1556 if alpName in varyList or not peakInstPrmMode: 1543 1557 alp = parmDict[alpName] 1544 1558 dada0 = dada1 = 0.0 … … 1548 1562 alp = max(0.0001,alp) 1549 1563 betName = 'bet'+str(iPeak) 1550 if betName in varyList :1564 if betName in varyList or not peakInstPrmMode: 1551 1565 bet = parmDict[betName] 1552 1566 dbdb0 = dbdb1 = 0.0 … … 1556 1570 bet = max(0.0001,bet) 1557 1571 sigName = 'sig'+str(iPeak) 1558 if sigName in varyList :1572 if sigName in varyList or not peakInstPrmMode: 1559 1573 sig = parmDict[sigName] 1560 1574 dsdU = dsdV = dsdW = 0 … … 1564 1578 sig = max(sig,0.001) #avoid neg sigma 1565 1579 gamName = 'gam'+str(iPeak) 1566 if gamName in varyList :1580 if gamName in varyList or not peakInstPrmMode: 1567 1581 gam = parmDict[gamName] 1568 1582 dgdX = dgdY = dgdZ = 0 … … 1625 1639 intens = parmDict['int'+str(iPeak)] 1626 1640 alpName = 'alp'+str(iPeak) 1627 if alpName in varyList :1641 if alpName in varyList or not peakInstPrmMode: 1628 1642 alp = parmDict[alpName] 1629 1643 else: … … 1635 1649 dada0 = G2mth.getTOFalphaDeriv(dsp) 1636 1650 betName = 'bet'+str(iPeak) 1637 if betName in varyList :1651 if betName in varyList or not peakInstPrmMode: 1638 1652 bet = parmDict[betName] 1639 1653 else: … … 1645 1659 dbdb0,dbdb1,dbdb2 = G2mth.getTOFbetaDeriv(dsp) 1646 1660 sigName = 'sig'+str(iPeak) 1647 if sigName in varyList :1661 if sigName in varyList or not peakInstPrmMode: 1648 1662 sig = parmDict[sigName] 1649 1663 dsds0 = dsds1 = dsds2 = dsds3 = 0 … … 1652 1666 dsds0,dsds1,dsds2,dsds3 = G2mth.getTOFsigDeriv(dsp) 1653 1667 gamName = 'gam'+str(iPeak) 1654 if gamName in varyList :1668 if gamName in varyList or not peakInstPrmMode: 1655 1669 gam = parmDict[gamName] 1656 1670 dsdX = dsdY = dsdZ = 0 … … 2007 2021 sigName = 'sig'+str(iPeak) 2008 2022 pos = parmDict['pos'+str(iPeak)] 2009 if sigName not in varyList :2023 if sigName not in varyList and peakInstPrmMode: 2010 2024 if 'T' in Inst['Type'][0]: 2011 2025 dsp = G2lat.Pos2dsp(Inst,pos) … … 2014 2028 parmDict[sigName] = G2mth.getCWsig(parmDict,pos) 2015 2029 gamName = 'gam'+str(iPeak) 2016 if gamName not in varyList :2030 if gamName not in varyList and peakInstPrmMode: 2017 2031 if 'T' in Inst['Type'][0]: 2018 2032 dsp = G2lat.Pos2dsp(Inst,pos) … … 2071 2085 for j in range(len(names)): 2072 2086 parName = names[j]+str(i) 2073 if parName in varyList :2087 if parName in varyList or not peakInstPrmMode: 2074 2088 peak[2*j] = parmDict[parName] 2075 2089 elif 'alp' in parName: … … 2175 2189 varyList = bakVary+insVary+peakVary 2176 2190 fullvaryList = varyList[:] 2191 if not peakInstPrmMode: 2192 for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1', 2193 'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',): 2194 if v in varyList: 2195 raise Exception('Instrumental profile terms cannot be varied '+ 2196 'after setPeakInstPrmMode(False) is used') 2177 2197 while True: 2178 2198 begin = time.time() … … 2295 2315 return YI,WYI 2296 2316 2297 ################################################################################ 2298 #### RMCutilities 2299 ################################################################################ 2300 2317 #### RMCutilities ################################################################################ 2301 2318 def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd): 2302 2319 inst = PWDdata['Instrument Parameters'][0] … … 3030 3047 return np.array(bondAngles) 3031 3048 3032 ################################################################################ 3033 #### Reflectometry calculations 3034 ################################################################################ 3035 3049 #### Reflectometry calculations ################################################################################ 3036 3050 def REFDRefine(Profile,ProfDict,Inst,Limits,Substances,data): 3037 3051 G2fil.G2Print ('fit REFD data by '+data['Minimizer']+' using %.2f%% data resolution'%(data['Resolution'][0])) … … 3466 3480 3467 3481 3468 ################################################################################ 3469 #### Stacking fault simulation codes 3470 ################################################################################ 3471 3482 #### Stacking fault simulation codes ################################################################################ 3472 3483 def GetStackParms(Layers): 3473 3484 … … 3881 3892 G2fil.G2Print (' GETSAD time = %.2fs'%(time.time()-time0)) 3882 3893 3883 ############################################################################### 3884 #### Maximum Entropy Method - Dysnomia 3885 ############################################################################### 3886 3894 #### Maximum Entropy Method - Dysnomia ############################################################################### 3887 3895 def makePRFfile(data,MEMtype): 3888 3896 ''' makes Dysnomia .prf control file from Dysnomia GUI controls -
trunk/GSASIIscriptable.py
r4783 r4821 4242 4242 peaks['peaks'][i][j] = var 4243 4243 4244 def refine_peaks(self ):4244 def refine_peaks(self,mode='useIP'): 4245 4245 '''Causes a refinement of peak position, background and instrument parameters 4246 4247 :param str mode: this determines how peak widths are determined. If 4248 the value is 'useIP' (the default) then the width parameter values (sigma, gamma, 4249 alpha,...) are computed from the histogram's instrument parameters. If the 4250 value is 'hold', then peak width parameters are not overridden. In 4251 this case, it is not possible to refine the instrument parameters 4252 associated with the peak widths and an attempt to do so will result in 4253 an error. 4246 4254 4247 4255 :returns: a list of dicts with refinement results. Element 0 has uncertainties … … 4252 4260 ''' 4253 4261 import GSASIIpwd as G2pwd 4262 if mode == 'useIP': 4263 G2pwd.setPeakInstPrmMode(True) 4264 elif mode == 'hold': 4265 G2pwd.setPeakInstPrmMode(False) 4266 else: 4267 raise G2ScriptException('Error: invalid mode value in refine_peaks (allowed: "useIP" or "hold")') 4254 4268 controls = self.proj.data.get('Controls',{}) 4255 4269 controls = controls.get('data',
Note: See TracChangeset
for help on using the changeset viewer.