aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-02-08 17:12:07 +0100
committerThomas White <taw@physics.org>2018-02-08 17:12:07 +0100
commited135cad77c52f65e0a3d7ecdeebbca492b7becd (patch)
treef943738307af7df0371f914dfc944adb5c619ada /scripts
parent14d9a22b951eb5e1216b05c3c34a9cb178a2a31b (diff)
Add scripts/sum-hdf5-files
Diffstat (limited to 'scripts')
-rw-r--r--scripts/sum-hdf5-files34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/sum-hdf5-files b/scripts/sum-hdf5-files
new file mode 100644
index 00000000..22fea42b
--- /dev/null
+++ b/scripts/sum-hdf5-files
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import numpy as np
+import h5py
+import sys
+
+dfh = h5py.File("darkcal_jungfrau_13_05_1428.h5", "r")
+darkcal = dfh["/data/data"].value
+dfh.close
+
+sum = np.zeros((512,1024), dtype=float)
+f = open(sys.argv[1], 'r')
+
+while True:
+
+ fline = f.readline()
+ if not fline:
+ break
+ fn = fline.rstrip("\r\n")
+ filename = fn.split()[0]
+ ev = int(fn.split()[1].lstrip("/"))
+
+ fh = h5py.File(filename, 'r')
+ dset = fh["/entry/instrument/detector/data"][ev,:,:].astype(np.float)
+ dset -= darkcal
+ sum = np.add(sum, dset)
+ fh.close()
+ print("Summed '{}' '{}'".format(filename,ev))
+
+f.close()
+fh = h5py.File('summed.h5', 'w')
+fh.create_dataset('/data', data=sum)
+fh.close()
+