From 92fb8988fb0b2b8cccb53b7b918b7242fbfdf295 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Sun, 31 Oct 2021 09:58:18 +0100 Subject: [PATCH] Add differentiation between stillscan and 2th scan --- beamtime/xrd/io.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 1fffdcb..c5e5966 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -16,6 +16,13 @@ def get_image_array(path): return image_array +def get_image_headers(path): + + image = fabio.open(path) + + return image.header + + def integrate_1d(calibrant, bins, path=None, image=None, options=None): ''' Integrates an image file to a 1D diffractogram. @@ -198,13 +205,25 @@ def read_brml(path, options=None): diffractogram = [] for chain in root.findall('./DataRoutes/DataRoute'): - if chain.get('Description') == 'Originally measured data.': - for data in chain.findall('Datum'): - data = data.text.split(',') - twotheta, intensity = float(data[2]), float(data[3]) - - if twotheta > 0: - diffractogram.append({'2th': twotheta, 'I': intensity}) + + for scantype in chain.findall('ScanInformation/ScanMode'): + if scantype.text == 'StillScan': + + if chain.get('Description') == 'Originally measured data.': + for data in chain.findall('Datum'): + data = data.text.split(',') + data = [float(i) for i in data] + twotheta, intensity = float(data[2]), float(data[3]) + + + else: + if chain.get('Description') == 'Originally measured data.': + for data in chain.findall('Datum'): + data = data.text.split(',') + twotheta, intensity = float(data[2]), float(data[3]) + + if twotheta > 0: + diffractogram.append({'2th': twotheta, 'I': intensity}) diffractogram = pd.DataFrame(diffractogram)