aboutsummaryrefslogtreecommitdiff
path: root/scripts/eiger-badmap
blob: 7fe0a38293957c80849fe522794f917d34440aa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()