converting .h5 files

This commit is contained in:
2025-10-27 09:05:27 +02:00
parent cf21390395
commit cb2267c79a

26
scaling_converter.py Normal file
View File

@@ -0,0 +1,26 @@
"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)