Skip to content

Commit 173dcf1

Browse files
committed
provide config var (BRML_T_col) to allow selection of column for temperature in BRML files
1 parent 41c552b commit 173dcf1

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

GSASII/config_example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,9 @@
331331
files when files are imported. For Linux the default is True, but
332332
for Windows and Mac, the default is False
333333
'''
334+
335+
BRML_T_col = -1
336+
'''When zero or positive, this indicates a column where the temperature
337+
is stored in a Bruker BRML file. With the default value (-1), the columns
338+
8, 6, and 5 are tried, in that order.
339+
'''

GSASII/imports/G2pwd_BrukerBRML.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ def XtractXMLScan():
7878
# Extract 2-theta angle and counts from the XML document
7979
i=0
8080
T = {}
81-
for j in (5,6,8): # columns with temperature?
81+
tcol = GSASIIpath.GetConfigValue('BRML_T_col',-1)
82+
if tcol >= 0:
83+
tcols = (tcol,)
84+
else:
85+
tcols = (8,6,5) # columns to use for temperature
86+
87+
for j in tcols:
88+
T[f'{j}max'] = -1
89+
T[f'{j}min'] = 9999
8290
T[f'{j}sum'] = 0
8391
T[f'{j}c'] = 0
8492
# data appears to be in column 4 most of the time
@@ -93,13 +101,12 @@ def XtractXMLScan():
93101
y[i] = float(entry[4])*float(entry[0])/effTime
94102
y3.append(float(entry[3]))
95103
i = i + 1
96-
# both entry 6 & 8 seem to have a temperature in the multi-scan file
97-
# these columns are not present in the single-scan file.
98-
# Try column 8 first
99-
for j in (5,6,8): # columns with temperature?
104+
for j in tcols: # columns with temperature?
100105
try:
101106
t = float(entry[j])
102107
if t > 0:
108+
T[f'{j}max'] = max(T[f'{j}max'],t)
109+
T[f'{j}min'] = min(T[f'{j}min'],t)
103110
T[f'{j}sum'] += t
104111
T[f'{j}c'] += 1
105112
except:
@@ -110,9 +117,16 @@ def XtractXMLScan():
110117
except:
111118
y = np.array(y3)
112119
w = np.where(y>0,1/y,0.)
113-
for j in (8,6,5): # columns with temperature?
120+
for j in sorted(tcols): # show all columns with temperature
121+
if T[f'{j}c'] > 0:
122+
print(f'Column {j} T min {T[f'{j}min']:.2f}'
123+
f' max {T[f'{j}max']:.2f}'
124+
f' avg {T[f'{j}sum']/T[f'{j}c']:.2f} (C assumed)')
125+
for j in tcols: # take 1st column with non-zero temperatures
114126
if T[f'{j}c'] > 0:
115-
self.Sample['Temperature'] = 273. + T[f'{j}sum']/T[f'{j}c']
127+
self.Sample['Temperature'] = 273.15 + T[f'{j}sum']/T[f'{j}c']
128+
if len(tcols) > 1:
129+
print(f'Using column {j}, T={self.Sample['Temperature']:.3f} K')
116130
break
117131
self.powderdata = [x,y,w,np.zeros(nSteps),np.zeros(nSteps),np.zeros(nSteps)]
118132
return True

0 commit comments

Comments
 (0)