Skip to content

Commit 3bfddbb

Browse files
committed
more fixes to calibrate from peak fit. Now does TOF as well as CW 'A' & 'C'
1 parent 7baa794 commit 3bfddbb

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

GSASII/GSASIIplot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ def OnMotion(event):
23922392
found = XY[np.where(np.fabs(XY.T[0]-xpos) < 0.005*wid)]
23932393
if len(found):
23942394
pos = found[0][1]
2395-
if 'C' in Inst['Type'][0]:
2395+
if Inst['Type'][0][2] in ['A','B','C']:
23962396
Page.SetToolTipString('position=%.4f'%(pos))
23972397
else:
23982398
Page.SetToolTipString('position=%.2f'%(pos))
@@ -2413,7 +2413,7 @@ def OnMotion(event):
24132413
G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar
24142414
Plot.set_title(Title,fontsize=14)
24152415
Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=14)
2416-
if 'C' in Inst['Type'][0]:
2416+
if Inst['Type'][0][2] in ['A','B','C']:
24172417
Plot.set_ylabel(r'$\mathsf{\Delta(2\theta)}$',fontsize=14)
24182418
else:
24192419
Plot.set_ylabel(r'$\mathsf{\Delta}T/T$',fontsize=14)
@@ -2425,7 +2425,7 @@ def OnMotion(event):
24252425
W = 0.
24262426
Q = 2.*np.pi/X
24272427
Yc = G2lat.Dsp2pos(Inst,X)
2428-
if 'C' in Inst['Type'][0]:
2428+
if Inst['Type'][0][2] in ['A','B','C']:
24292429
Y = Y-Yc
24302430
E = Sigs[ixy]
24312431
bin = W/2.

GSASII/GSASIIpwd.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,11 +2227,16 @@ def DoCalibInst(IndexPeaks,Inst,Sample):
22272227

22282228
def SetInstParms():
22292229
dataType = Inst['Type'][0]
2230-
insNames = ['Lam',]
2231-
insVals = [G2mth.getWave(Inst),]
2232-
insVary = []
2233-
if Inst.get('Lam',[1.0,1.0,False])[2]:
2234-
insVary.append('Lam')
2230+
if 'T' in dataType:
2231+
insNames = []
2232+
insVals = []
2233+
insVary = []
2234+
else:
2235+
insNames = ['Lam',]
2236+
insVals = [G2mth.getWave(Inst),]
2237+
insVary = []
2238+
if Inst.get('Lam',[1.0,1.0,False])[2]:
2239+
insVary.append('Lam')
22352240
for parm in Inst:
22362241
if parm == 'Lam':
22372242
continue
@@ -2264,16 +2269,17 @@ def SetInstParms():
22642269
def GetInstParms(parmDict,varyList):
22652270
for name in Inst:
22662271
Inst[name][1] = parmDict[name]
2267-
for name in Sample:
2268-
if name in ['DisplaceX','DisplaceY','Shift']: # for CW only
2269-
try:
2270-
Sample[name][0] = parmDict[name]
2271-
except:
2272-
pass
2272+
if Inst['Type'][0][2] in ['A','B','C']:
2273+
for name in Sample:
2274+
if name in ['DisplaceX','DisplaceY','Shift']: # for CW only
2275+
try:
2276+
Sample[name][0] = parmDict[name]
2277+
except:
2278+
pass
22732279

22742280
def InstPrint(sigDict):
22752281
print ('Instrument/Sample Parameters:')
2276-
if 'C' in Inst['Type'][0] or 'B' in Inst['Type'][0]:
2282+
if Inst['Type'][0][2] in ['A','B','C']:
22772283
ptfmt = "%12.6f"
22782284
else:
22792285
ptfmt = "%12.3f"
@@ -2288,17 +2294,18 @@ def InstPrint(sigDict):
22882294
sigstr += ptfmt % (sigDict[parm])
22892295
else:
22902296
sigstr += 12*' '
2291-
parmList = ['Shift',]
2292-
if 'Debye' in Sample['Type']:
2293-
parmList = ['DisplaceX','DisplaceY']
2294-
for parm in Sample:
2295-
if parm in parmList:
2296-
ptlbls += "%s" % (parm.center(12))
2297-
ptstr += ptfmt % (Sample[parm][0])
2298-
if parm in sigDict:
2299-
sigstr += ptfmt % (sigDict[parm])
2300-
else:
2301-
sigstr += 12*' '
2297+
if Inst['Type'][0][2] in ['A','B','C']:
2298+
parmList = ['Shift',]
2299+
if 'Debye' in Sample['Type']:
2300+
parmList = ['DisplaceX','DisplaceY']
2301+
for parm in Sample:
2302+
if parm in parmList:
2303+
ptlbls += "%s" % (parm.center(12))
2304+
ptstr += ptfmt % (Sample[parm][0])
2305+
if parm in sigDict:
2306+
sigstr += ptfmt % (sigDict[parm])
2307+
else:
2308+
sigstr += 12*' '
23022309
print (ptlbls)
23032310
print (ptstr)
23042311
print (sigstr)
@@ -2312,9 +2319,6 @@ def errPeakPos(values,peakDsp,peakPos,peakWt,dataType,parmDict,varyList):
23122319
shft = -0.5*const*(parmDict['DisplaceX']*npcosd(calcPos)+parmDict['DisplaceY']*npsind(calcPos))+parmDict['Zero']
23132320
else:
23142321
shft = -2.0*const*(parmDict['Shift']*npcosd(calcPos/2.0)+parmDict['Zero'])
2315-
# DThX = npasind(10**-3*parmDict['DisplaceX']*npcosd(calcPos)/parmDict['radius'])
2316-
# DThY = -npasind(10**-3*parmDict['DisplaceY']*npsind(calcPos)/parmDict['radius'])
2317-
# shft = DThX+DThY+parmDict['Zero']
23182322
return np.sqrt(peakWt)*(calcPos+shft-peakPos)
23192323
else:
23202324
return np.sqrt(peakWt)*(calcPos-peakPos)

GSASII/GSASIIpwdGUI.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,9 +2562,6 @@ def OnCalibrate(event):
25622562
fitPeaks = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Peak List'))
25632563
IndexPeaks = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Index Peak List'))
25642564
Sample = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Sample Parameters'))
2565-
# if 'Debye' not in Sample['Type']:
2566-
# G2frame.ErrorDialog('Cannot calibrate','Only apropriate for Debye-Scherrer geometry')
2567-
# return
25682565
if not len(IndexPeaks[0]):
25692566
G2frame.ErrorDialog('Cannot calibrate','Index Peak List empty')
25702567
return
@@ -2582,8 +2579,7 @@ def OnCalibrate(event):
25822579
UpdateInstrumentGrid(G2frame,data)
25832580
const = 0.0
25842581
if data['Type'][0][2] in ['A','B','C']:
2585-
const = 18.e-2/(np.pi*Sample['Gonio. radius'])
2586-
# const = 10**-3/Sample['Gonio. radius']
2582+
const = 0.18/(np.pi*Sample['Gonio. radius'])
25872583
XY = []
25882584
Sigs = []
25892585
for ip,peak in enumerate(IndexPeaks[0]):
@@ -2592,9 +2588,9 @@ def OnCalibrate(event):
25922588
binwid = cw[np.searchsorted(xye[0],peak[0])]
25932589
if const:
25942590
if 'Debye' in Sample['Type']:
2595-
shft = -const*(Sample['DisplaceX'][0]*npcosd(peak[0])+Sample['DisplaceY'][0]*npsind(peak[0]))
2591+
shft -= 0.5*const*(Sample['DisplaceX'][0]*npcosd(peak[0])+Sample['DisplaceY'][0]*npsind(peak[0]))
25962592
else:
2597-
shft = -2.0*const*Sample['Shift'][0]*npcosd(peak[0]/2.0)
2593+
shft -= 2.0*const*Sample['Shift'][0]*npcosd(peak[0]/2.0)
25982594
XY.append([peak[-1],peak[0]-shft,binwid])
25992595
Sigs.append(IndexPeaks[1][ip])
26002596
if len(XY):

0 commit comments

Comments
 (0)