From f31c8cd01d36347e9254b6ff83979af690628975 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 17 May 2017 16:14:35 +0200 Subject: Actually add scripts/sum-peaks --- scripts/sum-peaks | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 scripts/sum-peaks (limited to 'scripts/sum-peaks') diff --git a/scripts/sum-peaks b/scripts/sum-peaks new file mode 100755 index 00000000..eccb9fc6 --- /dev/null +++ b/scripts/sum-peaks @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Generate "peak powder" from CrystFEL stream +# +# Copyright © 2017 Deutsches Elektronen-Synchrotron DESY, +# a research centre of the Helmholtz Association. +# +# Author: +# 2017 Thomas White +# + +import numpy as np +import h5py +import sys +import re + +f = open(sys.argv[1], 'r') +powder = np.zeros((512,1024), dtype=float) +peaks = [] + +prog1 = re.compile("^\s*([\d\-\.]+)\s+([\d\-\.]+)\s+[\d\-\.]+\s+([\d\-\.]+)\s+\S+$") + +while True: + + fline = f.readline() + if not fline: + break + + if fline == '----- End chunk -----\n': + if len(peaks) > 10: + for p in peaks: + powder[p[1],p[0]] += p[2] + peaks = [] + + match = prog1.match(fline) + if match: + fs = int(float(match.group(1))) + ss = int(float(match.group(2))) + intensity = float(match.group(3)) + peaks.append((fs,ss,intensity)) + +f.close() + +fh = h5py.File("summed-peaks.h5", "w") +fh.create_dataset("/data", (512,1024), data=powder) +fh.close() -- cgit v1.2.3