#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Convert gain map to saturation map
#
# Copyright © 2016-2020 Deutsches Elektronen-Synchrotron DESY,
#                       a research centre of the Helmholtz Association.
#
# Author:
#    2016-2017 Thomas White <taw@physics.org>

import numpy as np
import h5py
import sys

fh = h5py.File(sys.argv[1], 'r')
gains = fh['/data/data'].value
fh.close()

satns = np.ones_like(gains) * 13000
satns[gains > 4] = 60000

fh = h5py.File('saturation_map.h5', 'w')
fh.create_dataset('/data/data', data=satns)
fh.close()

