save progress

This commit is contained in:
2023-02-09 16:54:16 +00:00
parent 2f4dc477bd
commit cac3ee03d9
4 changed files with 106 additions and 80 deletions
+21 -1
View File
@@ -1,4 +1,4 @@
import tables as tb
class Frame:
def __init__(self, id, frame_nr, garment):
@@ -12,3 +12,23 @@ class Frame:
def __eq__(self, other):
return (self.id, self.frame_nr) == (other.id, other.frame_nr)
def save_to_h5file(h5file, id, frame_nr, garment, data, name, type):
filters = tb.Filters(complevel=9, complib='blosc2')
group = h5file.get_node(f'/{id}/{frame_nr}/{garment}')
if type == 'float32':
atom = tb.Float32Atom()
elif type == 'uint8':
atom = tb.UInt8Atom()
elif type == 'bool':
atom = tb.BoolAtom()
else:
raise Exception('Unknown type')
if f'{name}' in group:
array = h5file.get_node(f'/{id}/{frame_nr}/{garment}/{name}')
array[:] = data
else:
carray = h5file.create_carray(group, name, atom=atom, shape=data.shape, filters=filters)
carray[:] = data