27 lines
785 B
Python
27 lines
785 B
Python
"scaling the images, so that the maximums would be the same"
|
|
|
|
import numpy as np
|
|
import h5py
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--infile", type = str, help = "input file with all the calculated images")
|
|
parser.add_argument('--converted', type = str, help = 'name of the converted data file')
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
with h5py.File(args.infile, 'r') as input_images, h5py.File(args.converted, 'w') as converter:
|
|
for name in input_images:
|
|
if isinstance(input_images[name], h5py.Group):
|
|
input_images.copy(name, converter)
|
|
|
|
def conv(name, obj):
|
|
if isinstance(obj, h5py.Dataset):
|
|
data = obj[:]
|
|
mod = data / np.max(data) * 100
|
|
obj[...] = mod
|
|
|
|
converter.visititems(conv)
|
|
|