@@ -319,8 +319,10 @@ def _parse_header(self):
319319
320320 # The only way to know if it is the PTP-variant of file spec 3.0
321321 # is to check for nanosecond timestamp resolution.
322- if "timestamp_resolution" in self .__nsx_basic_header [nsx_nb ].dtype .names \
323- and self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ] == 1_000_000_000 :
322+ if (
323+ "timestamp_resolution" in self .__nsx_basic_header [nsx_nb ].dtype .names
324+ and self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ] == 1_000_000_000
325+ ):
324326 nsx_dataheader_reader = self .__nsx_dataheader_reader ["3.0-ptp" ]
325327 else :
326328 nsx_dataheader_reader = self .__nsx_dataheader_reader [spec ]
@@ -372,8 +374,10 @@ def _parse_header(self):
372374 spec = self .__nsx_spec [nsx_nb ]
373375 # The only way to know if it is the PTP-variant of file spec 3.0
374376 # is to check for nanosecond timestamp resolution.
375- if "timestamp_resolution" in self .__nsx_basic_header [nsx_nb ].dtype .names \
376- and self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ] == 1_000_000_000 :
377+ if (
378+ "timestamp_resolution" in self .__nsx_basic_header [nsx_nb ].dtype .names
379+ and self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ] == 1_000_000_000
380+ ):
377381 _data_reader_fun = self .__nsx_data_reader ["3.0-ptp" ]
378382 else :
379383 _data_reader_fun = self .__nsx_data_reader [spec ]
@@ -437,7 +441,7 @@ def _parse_header(self):
437441 if "timestamp_resolution" in self .__nsx_basic_header [nsx_nb ].dtype .names :
438442 ts_res = self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ]
439443 elif spec == "2.1" :
440- ts_res = self .__nsx_params [spec ](nsx_nb )[' timestamp_resolution' ]
444+ ts_res = self .__nsx_params [spec ](nsx_nb )[" timestamp_resolution" ]
441445 else :
442446 ts_res = 30_000
443447 period = self .__nsx_basic_header [nsx_nb ]["period" ]
@@ -966,7 +970,11 @@ def __read_nsx_dataheader_variant_b(
966970 return data_header
967971
968972 def __read_nsx_dataheader_variant_c (
969- self , nsx_nb , filesize = None , offset = None , ):
973+ self ,
974+ nsx_nb ,
975+ filesize = None ,
976+ offset = None ,
977+ ):
970978 """
971979 Reads the nsx data header for each data block for file spec 3.0 with PTP timestamps
972980 """
@@ -984,7 +992,7 @@ def __read_nsx_dataheader_variant_c(
984992 ("reserved" , "uint8" ),
985993 ("timestamps" , "uint64" ),
986994 ("num_data_points" , "uint32" ),
987- ("samples" , "int16" , self .__nsx_basic_header [nsx_nb ]["channel_count" ])
995+ ("samples" , "int16" , self .__nsx_basic_header [nsx_nb ]["channel_count" ]),
988996 ]
989997 npackets = int ((filesize - offset ) / np .dtype (ptp_dt ).itemsize )
990998 struct_arr = np .memmap (filename , dtype = ptp_dt , shape = npackets , offset = offset , mode = "r" )
@@ -1001,28 +1009,20 @@ def __read_nsx_dataheader_variant_c(
10011009 _clock_rate = self .__nsx_basic_header [nsx_nb ]["timestamp_resolution" ] # clocks per sec
10021010 clk_per_samp = _clock_rate / _nominal_rate # clk/sec / smp/sec = clk/smp
10031011 seg_thresh_clk = int (2 * clk_per_samp )
1004- seg_starts = np .hstack (
1005- (0 , 1 + np .argwhere (np .diff (struct_arr ["timestamps" ]) > seg_thresh_clk ).flatten ())
1006- )
1012+ seg_starts = np .hstack ((0 , 1 + np .argwhere (np .diff (struct_arr ["timestamps" ]) > seg_thresh_clk ).flatten ()))
10071013 for seg_ix , seg_start_idx in enumerate (seg_starts ):
10081014 if seg_ix < (len (seg_starts ) - 1 ):
10091015 seg_stop_idx = seg_starts [seg_ix + 1 ]
10101016 else :
1011- seg_stop_idx = ( len (struct_arr ) - 1 )
1017+ seg_stop_idx = len (struct_arr ) - 1
10121018 seg_offset = offset + seg_start_idx * struct_arr .dtype .itemsize
10131019 num_data_pts = seg_stop_idx - seg_start_idx
1014- seg_struct_arr = np .memmap (
1015- filename ,
1016- dtype = ptp_dt ,
1017- shape = num_data_pts ,
1018- offset = seg_offset ,
1019- mode = "r"
1020- )
1020+ seg_struct_arr = np .memmap (filename , dtype = ptp_dt , shape = num_data_pts , offset = seg_offset , mode = "r" )
10211021 data_header [seg_ix ] = {
10221022 "header" : None ,
10231023 "timestamp" : seg_struct_arr ["timestamps" ], # Note, this is an array, not a scalar
10241024 "nb_data_points" : num_data_pts ,
1025- "offset_to_data_block" : seg_offset
1025+ "offset_to_data_block" : seg_offset ,
10261026 }
10271027 return data_header
10281028
@@ -1075,7 +1075,7 @@ def __read_nsx_data_variant_c(self, nsx_nb):
10751075 ("reserved" , "uint8" ),
10761076 ("timestamps" , "uint64" ),
10771077 ("num_data_points" , "uint32" ),
1078- ("samples" , "int16" , self .__nsx_basic_header [nsx_nb ]["channel_count" ])
1078+ ("samples" , "int16" , self .__nsx_basic_header [nsx_nb ]["channel_count" ]),
10791079 ]
10801080
10811081 data = {}
@@ -1084,7 +1084,8 @@ def __read_nsx_data_variant_c(self, nsx_nb):
10841084 filename ,
10851085 dtype = ptp_dt ,
10861086 shape = bl_header ["nb_data_points" ],
1087- offset = bl_header ["offset_to_data_block" ], mode = "r"
1087+ offset = bl_header ["offset_to_data_block" ],
1088+ mode = "r" ,
10881089 )
10891090 # Does this concretize the data?
10901091 # If yes then investigate np.ndarray with buffer=file,
0 commit comments