77
88from timebased import calculate_features_xyz , DATA_TYPECODE , N_FEATURES
99
10- def compute_dataset_features (data : npyfile .Reader ,
10+ def compute_dataset_features (data : npyfile .Reader , window_length ,
1111 skip_samples = 0 , limit_samples = None , verbose = 0 ):
1212
1313 # Check that data is expected format
1414 shape = data .shape
15- assert len (shape ) == 3 , shape
16- n_samples , window_length , n_axes = shape
15+ assert len (shape ) == 2 , shape
16+ n_samples , n_axes = shape
1717 assert n_axes == 3 , shape
18- #assert window_length == 128, shape
1918
2019 # We expect data to be h/int16
2120 assert data .typecode == DATA_TYPECODE , data .typecode
@@ -32,6 +31,11 @@ def compute_dataset_features(data: npyfile.Reader,
3231 data_chunks = data .read_data_chunks (chunk_size , offset = chunk_size * skip_samples )
3332 for arr in data_chunks :
3433
34+ print ('cc' , len (arr ))
35+ if len (arr ) < chunk_size :
36+ # short read, last data piece, ignore
37+ continue
38+
3539 # process the data
3640 # De-interleave data from XYZ1 XYZ2... into separate continious X,Y,Z
3741 for i in range (window_length ):
@@ -71,16 +75,20 @@ def main():
7175
7276 out_typecode = 'f'
7377 n_features = N_FEATURES
78+ window_length = 128
7479
7580 features_array = array .array (out_typecode , (0 for _ in range (n_features )))
7681
7782 with npyfile .Reader (in_path ) as data :
78- n_samples , window_length , n_axes = data .shape
83+ n_samples , n_axes = data .shape
84+
85+ n_windows = n_samples // window_length
7986
80- out_shape = (n_samples , n_features )
87+ out_shape = (n_windows , n_features )
8188 with npyfile .Writer (out_path , out_shape , out_typecode ) as out :
8289
8390 generator = compute_dataset_features (data ,
91+ window_length = window_length ,
8492 skip_samples = skip_samples ,
8593 limit_samples = limit_samples ,
8694 )
0 commit comments