aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-11-12 11:14:06 +0100
committerThomas White <taw@physics.org>2020-11-12 11:14:06 +0100
commitc570bbe16cb68cfb340e4ce3bc8c66831a08a306 (patch)
tree52a306029e02bd652f52eb56a69c436965904ba2 /scripts
parent5e61ee1322a30ee505782697ff4b762dcec9b947 (diff)
Add scripts/make-csplit
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make-csplit58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/make-csplit b/scripts/make-csplit
new file mode 100755
index 00000000..0f289056
--- /dev/null
+++ b/scripts/make-csplit
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# Create custom split file for partialator, based on pulse sequence
+#
+# Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2020 Thomas White <taw@physics.org>
+
+import sys
+
+f = open(sys.argv[1])
+
+fn = None
+ev = None
+pulseid = None
+
+def dataset(pulse):
+ # Divide 8 because we are at 0.5 MHz instead of 4 MHz
+ # Pulse sequence is light-dark1-dark2-dark3
+ if (pulse/8) % 4 == 0: return 'light'
+ if (pulse/8) % 4 == 1: return 'dark1'
+ if (pulse/8) % 4 == 2: return 'dark2'
+ if (pulse/8) % 4 == 3: return 'dark3'
+
+while True:
+ fline = f.readline()
+ if not fline:
+ break
+ if fline.find("Image filename: ") != -1:
+ if not fn == None:
+ print("Duplicate filename {}".format(fn), file=sys.stderr)
+ fn = fline.split(': ')[1].split(' ')[0].rstrip("\r\n")
+ if fline.find("Event: ") != -1:
+ if not ev == None:
+ print("Duplicate event ID {}".format(ev), file=sys.stderr)
+ ev = fline.split(': ')[1].split(' ')[0].rstrip("\r\n")
+ if fline.find("hdf5/instrument/pulseID = ") != -1:
+ if not pulseid == None:
+ print("Duplicate pulse ID {}".format(pulseid), file=sys.stderr)
+ pulseid = int(fline.split(' = ')[1].split(' ')[0].rstrip("\r\n"))
+ if fline.find("Begin chunk") != -1:
+ fn = None
+ ev = None
+ pulseid = None
+ if fline.find("End chunk") != -1:
+ if (fn == None) or (ev == None) or (pulseid == None):
+ print('Incomplete chunk! {} {} {}'.format(fn, ev, pulseid), file=sys.stderr)
+ else:
+ if pulseid == 0:
+ print("Zero pulse ID for {} {}".format(fn, ev), file=sys.stderr)
+ else:
+ print('{} {} {}'.format(fn, ev, dataset(pulseid)))
+
+
+f.close()