save progress
This commit is contained in:
+21
-1
@@ -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
|
||||
Reference in New Issue
Block a user