@@ -145,7 +145,7 @@ def detect_endian(data):
145145 elif endianness == "IEEE" :
146146 return ">"
147147 else :
148- raise SigMFConversionError (f"Unexpected endianness: { endianness } " )
148+ raise SigMFConversionError (f"Unsupported endianness: { endianness } " )
149149
150150
151151def read_hcb (file_path ):
@@ -313,7 +313,7 @@ def read_extended_header(file_path, h_fixed):
313313 return entries
314314
315315
316- def data_loopback (blue_path : Path , out_path : Path , h_fixed : dict ) -> np . ndarray :
316+ def data_loopback (blue_path : Path , out_path : Path , h_fixed : dict ) -> None :
317317 """
318318 Write SigMF data file from BLUE file samples.
319319
@@ -356,41 +356,26 @@ def data_loopback(blue_path: Path, out_path: Path, h_fixed: dict) -> np.ndarray:
356356
357357 # Determine destination path for SigMF data file
358358 dest_path = out_path .with_suffix (".sigmf-data" )
359- print ("#" * 80 )
360- print ("Writing SigMF data to:" , dest_path )
361- print ("#" * 80 )
362359
363360 # read raw samples
364361 raw_samples = np .fromfile (blue_path , dtype = np_dtype , offset = HEADER_SIZE_BYTES , count = elem_count )
365362
366363 if is_complex :
367- # complex data: already in IQIQIQ... format or native complex
368- if np_dtype == np .complex64 :
364+ # check if data is already complex or needs deinterleaving
365+ if np .iscomplexobj ( raw_samples ) :
369366 # already complex, no reassembly needed
370367 samples = raw_samples
371368 else :
372369 # reassemble interleaved IQ samples
373370 samples = raw_samples [::2 ] + 1j * raw_samples [1 ::2 ]
374- log .debug (f"Deinterleaved { len (raw_samples )} samples into { len (samples )} complex samples" )
375371 else :
376372 # scalar data
377373 samples = raw_samples
378374
379- # print('dbug', samples.dtype, len(samples), get_normalization_factor(fmt))
380-
381- # normalize if needed
382- # if should_normalize:
383- # norm_factor = get_normalization_factor(fmt)
384- # if norm_factor:
385- # samples /= norm_factor
386-
387375 # save out as SigMF IQ data file
388376 samples .tofile (dest_path )
389377 log .info ("wrote %s" , dest_path )
390378
391- # return the IQ data if needed for further processing if needed
392- return samples
393-
394379
395380def construct_sigmf (
396381 out_path : Path , h_fixed : dict , h_keywords : dict , h_adjunct : dict , h_extended : list , is_metadata_only : bool = False
@@ -627,7 +612,7 @@ def blue_to_sigmf(
627612 implement a function that instead writes metadata only for a non-conforming
628613 dataset using the HEADER_BYTES_KEY and TRAILING_BYTES_KEY in most cases.
629614 """
630- log .debug (f"convert { blue_path } " )
615+ log .debug (f"read { blue_path } " )
631616
632617 blue_path = Path (blue_path )
633618 if out_path is None :
@@ -650,7 +635,7 @@ def blue_to_sigmf(
650635
651636 # write to SigMF data file only if samples exist
652637 if not is_metadata_only :
653- _ = data_loopback (blue_path , out_path , h_fixed )
638+ data_loopback (blue_path , out_path , h_fixed )
654639 else :
655640 log .info ("skipping data file creation for zero-sample BLUE file" )
656641
0 commit comments