aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-02-08 17:02:19 +0100
committerThomas White <taw@physics.org>2018-02-08 17:02:19 +0100
commit14d9a22b951eb5e1216b05c3c34a9cb178a2a31b (patch)
treeec2a76bf0c758eaabab86a9466c1316fd0f43c13 /scripts
parentfaf99fe8fe477227ad18628d6c337ec17a6661b8 (diff)
Add scripts/eiger-badmap
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/eiger-badmap32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/eiger-badmap b/scripts/eiger-badmap
new file mode 100755
index 00000000..7fe0a382
--- /dev/null
+++ b/scripts/eiger-badmap
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Generate bad pixel map for EIGER detector from a native HDF5 file
+#
+# Copyright © 2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
+#
+# Author:
+# 2017 Thomas White <taw@physics.org>
+
+import numpy as np
+import h5py
+import sys
+
+fh = h5py.File(sys.argv[1], 'r')
+frame = fh['/entry/data/data_000001'][0]
+fh.close()
+
+if len(frame.shape) != 2:
+ print("Input frame is not 2D!")
+ sys.exit(1)
+
+print("Size of mask: "+str(frame.shape[0])+" by "+str(frame.shape[1])+" pixels")
+
+mask = np.zeros_like(frame)
+mask[frame > 65535] = 1
+
+fh = h5py.File('eiger_badmap.h5', 'w')
+fh.create_dataset('/data/data', data=mask)
+fh.close()
+