converting .h5 files
This commit is contained in:
26
scaling_converter.py
Normal file
26
scaling_converter.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user