@@ -755,6 +755,7 @@ def _write_data_worker(
755
755
data_size ,
756
756
stop_event ,
757
757
):
758
+ sim_idx = 0
758
759
with h5py .File (file_path , 'a' ) as h5_file :
759
760
# loop until the stop event is set
760
761
while not stop_event .is_set ():
@@ -764,13 +765,15 @@ def _write_data_worker(
764
765
if sem .acquire (timeout = 1e-3 ):
765
766
# retrieve the data from the shared buffer
766
767
data = shared_buffer [i * data_size : (i + 1 ) * data_size ]
767
- data_dict = pickle .loads (bytes (data ))
768
+ # data_dict = pickle.loads(bytes(data))
768
769
769
770
# write data to the file
770
- MonteCarlo .__dict_to_h5 (h5_file , '/' , data_dict )
771
-
771
+ grp = h5_file .create_group (f"{ sim_idx } " )
772
+ grp .create_dataset ("data" , data = data )
773
+
772
774
# release the write semaphore // tell worker it can write again
773
775
go_write_semaphores [i ].release ()
776
+ sim_idx += 1
774
777
# print(f"Wrote data to file. Buffer pos: {i}")
775
778
776
779
# loop through all the semaphores to write the remaining data
@@ -779,13 +782,15 @@ def _write_data_worker(
779
782
if sem .acquire (timeout = 1e-3 ):
780
783
# retrieve the data from the shared buffer
781
784
data = shared_buffer [i * data_size : (i + 1 ) * data_size ]
782
- data_dict = pickle .loads (bytes (data ))
785
+ # data_dict = pickle.loads(bytes(data))
783
786
784
787
# write data to the file
785
- MonteCarlo .__dict_to_h5 (h5_file , '/' , data_dict )
788
+ grp = h5_file .create_group (f"{ sim_idx } " )
789
+ grp .create_dataset ("data" , data = data )
786
790
787
791
# release the write semaphore // tell worker it can write again
788
792
go_write_semaphores [i ].release ()
793
+ sim_idx += 1
789
794
790
795
@staticmethod
791
796
def __downsample_recursive (data_dict , max_time , sample_time ):
0 commit comments