Skip to content

Commit 2085db5

Browse files
committed
debug test_CBF
1 parent 46fc5a9 commit 2085db5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

GSASII/imports/G2img_CBF.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def GetCbfData(self,filename):
3838

3939
import unpack_cbf as cbf
4040
if GSASIIpath.GetConfigValue('debug'):
41-
print ('Read cif binary detector data cbf file: '+filename)
41+
print ('Reading cif binary detector data cbf file: '+filename)
4242
File = open(filename,'rb')
4343
sizexy = [0,0]
4444
pixSize = [172,172] #Pixium4700?
@@ -49,6 +49,7 @@ def GetCbfData(self,filename):
4949
byteOrd = '<'
5050
stream = File.read()
5151
if 'bytes' in str(type(stream)):
52+
print ('decoding: '+filename)
5253
stream = stream.decode('latin-1')
5354
starter = '\x0c\x1a\x04\xd5'
5455
imageBeg = stream.find(starter)+4
@@ -59,6 +60,7 @@ def GetCbfData(self,filename):
5960
else:
6061
term = '\n' #LF only
6162
head = head.split(term)
63+
compImageSize = None
6264
for line in head:
6365
fields = line.split()
6466
if 'Wavelength' in line:
@@ -81,6 +83,12 @@ def GetCbfData(self,filename):
8183
Npix = int(fields[1])
8284
elif 'Detector_2theta' in line:
8385
det2theta = float(fields[2])
86+
if compImageSize is None:
87+
print('CBF failed to read header')
88+
print(header)
89+
print('\\r\\n in header','\r\n' in header, 'size',imageBeg)
90+
return
91+
8492
nxy = sizexy[0]*sizexy[1]
8593
cent = [cent[0]*pixSize[0]/1000.,cent[1]*pixSize[1]/1000.]
8694
File.seek(0)

0 commit comments

Comments
 (0)