aboutsummaryrefslogtreecommitdiff
path: root/scripts/find-pairs
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-08-15 15:11:40 +0200
committerThomas White <taw@physics.org>2014-08-15 15:11:40 +0200
commit8058916275230cadb371b01f1824a320a2e03ceb (patch)
tree1321f9d4784e725ccc510762fa72c670695f94b4 /scripts/find-pairs
parentf4e2669a6e1b6b438329de8e94806ace81ce7800 (diff)
Add add-beam-params and find-pairs
Diffstat (limited to 'scripts/find-pairs')
-rwxr-xr-xscripts/find-pairs73
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/find-pairs b/scripts/find-pairs
new file mode 100755
index 00000000..4629767d
--- /dev/null
+++ b/scripts/find-pairs
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+#
+# Find pairs of observations from the same pattern
+#
+# Copyright © 2014 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2014 Thomas White <taw@physics.org>
+#
+
+import re as regexp
+
+fn1 = "test-0.5.0-satfix.stream"
+fn2 = "test-curr.stream"
+
+def find_405(f):
+ lines = dict()
+ fn = ""
+ prog = regexp.compile("^\s+([\d-]+)\s+([\d-]+)\s+([\d-]+)\s+")
+ while True:
+ fline = f.readline()
+ if not fline:
+ break
+ if fline.find("Image filename: ") != -1:
+ fn = fline.split(': ')[1].rstrip("\r\n")
+ continue
+ match = prog.match(fline)
+ if not match:
+ continue
+ h = int(match.group(1))
+ k = int(match.group(2))
+ l = int(match.group(3))
+ if (h==0) and (k==0) and (l==6):
+ lines[fn] = fline
+ if (h==0) and (k==0) and (l==-6):
+ lines[fn] = fline
+ return lines
+
+f = open(fn1, 'r')
+flines = find_405(f)
+print len(flines),"measurements in",fn1
+
+g = open(fn2, 'r')
+glines = find_405(g)
+print len(glines),"measurements in",fn2
+
+print "\nThe common measurements:\n"
+for fn in flines.keys():
+ if fn in glines:
+ print fn
+ print flines[fn].rstrip("\r\n")
+ print glines[fn]
+ print
+ del flines[fn]
+ del glines[fn]
+
+print "\nThe measurements only in",fn1,":\n"
+
+for fn in flines.keys():
+ print fn
+ print flines[fn].rstrip("\r\n")
+ print
+
+print "\nThe measurements only in",fn2,":\n"
+
+for fn in glines.keys():
+ print fn
+ print glines[fn].rstrip("\r\n")
+ print
+