aboutsummaryrefslogtreecommitdiff
path: root/scripts/find-multiples
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-11-13 14:14:44 +0100
committerThomas White <taw@physics.org>2018-11-13 14:14:44 +0100
commit71f4e6a5752f6586ec83a8c9606b100f2fe497fb (patch)
treee943dd39bb33493edc60b49d79bebdb0dcbb76fb /scripts/find-multiples
parent7c89d56e87a24877fd07d515b70051c141ad62d8 (diff)
Add some new scripts
Diffstat (limited to 'scripts/find-multiples')
-rwxr-xr-xscripts/find-multiples58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/find-multiples b/scripts/find-multiples
new file mode 100755
index 00000000..6196e83c
--- /dev/null
+++ b/scripts/find-multiples
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Find multiple crystal hits
+#
+# Copyright © 2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2017 Thomas White <taw@physics.org>
+#
+
+import sys
+from collections import deque
+
+f = open(sys.argv[1], 'r')
+n_crystals = 0
+crystal = deque()
+in_crystal = 0
+while True:
+
+ fline = f.readline()
+ if not fline:
+ break
+
+ fline = fline.rstrip("\r\n")
+
+ if fline.find("Image filename") != -1:
+ filename = fline
+
+ if fline.find("Event") != -1:
+ event = fline
+
+ if fline.find("End chunk") != -1:
+ if n_crystals > 1:
+ print("\nFilename: "+filename)
+ print("Event: "+event)
+ for line in crystal:
+ print(line)
+
+ if fline.find("Begin chunk") != -1:
+ n_crystals = 0
+ filename = ""
+ event = ""
+ crystal.clear()
+
+ if fline.find("Begin crystal") != -1:
+ n_crystals += 1
+
+ if fline.find("Cell param") != -1:
+ in_crystal = 1
+
+ if in_crystal:
+ crystal.append(fline)
+
+ if fline.find("unique_axis") != -1:
+ in_crystal = 0
+