Commit 7002d579 authored by Viktor Reshniak's avatar Viktor Reshniak
Browse files

read_integration_file

parent 538efc60
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -83,6 +83,40 @@ def histogram_grid(hist_ws):
	return points, edges


###############################################################################
# reading integration files

def read_integration_file(file):
	data = []
	headi = 1e12
	has_mnp = False
	with open(file, "r") as file:
		lines = file.readlines()
		if 'M    N    P' in lines:
			has_mnp = True
		for i,line in enumerate(lines):
			if '0  NRUN DETNUM     CHI      PHI    OMEGA       MONCNT' in line:
				headi = i
				continue
			if i<headi+3:
				continue
			data.append(line)
	hkl = []
	mnp = []
	I = []
	peak_ids = []
	for line in data:
		words = line.split()
		peak_ids.append(int(words[1]))
		hkl.append(f'{words[2]},{words[3]},{words[4]}')
		if has_mnp:
			mnp.append(f'{words[5]},{words[6]},{words[7]}')
			I.append(float(words[17]))
		else:
			I.append(float(words[14]))
	return hkl, mnp, I


###############################################################################
# detector mask