Skip to content

Commit 1358927

Browse files
committed
refactor normalization pass
1 parent 59467df commit 1358927

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

sigmf/apps/convert_blue.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,13 @@ def write_data(blue_path: Path, out_path: Path, h_fixed: dict) -> np.ndarray:
369369
else:
370370
# reassemble interleaved IQ samples
371371
samples = raw_samples[::2] + 1j * raw_samples[1::2]
372-
# normalize if needed
373-
if should_normalize:
374-
samples = samples.astype(np.float32) / NORMALIZATION_FACTORS[fmt]
375372
else:
376373
# scalar data
377374
samples = raw_samples
378-
if should_normalize:
379-
samples = samples.astype(np.float32) / NORMALIZATION_FACTORS[fmt]
375+
376+
# normalize if needed
377+
if should_normalize:
378+
samples /= NORMALIZATION_FACTORS[fmt]
380379

381380
# save out as SigMF IQ data file
382381
samples.tofile(dest_path)
@@ -468,11 +467,10 @@ def get_tag(tag):
468467
extended[key] = value
469468
global_info["blue:extended"] = extended
470469

471-
# BLUE uses 1950-01-01 as epoch, UNIX uses 1970-01-01
472470
blue_start_time = float(h_fixed.get("timecode", 0))
473471
blue_start_time += h_adjunct.get("xstart", 0)
474472
blue_start_time += float(h_keywords.get("TC_PREC", 0))
475-
473+
# timecode uses 1950-01-01 as epoch, datetime uses 1970-01-01
476474
blue_epoch = blue_start_time - 631152000 # seconds between 1950 and 1970
477475
# FIXME: I am unsure if the timezone is always UTC in these files
478476
blue_datetime = datetime.fromtimestamp(blue_epoch, tz=timezone.utc)
@@ -609,6 +607,8 @@ def convert_blue(
609607
implement a function that instead writes metadata only for a non-conforming
610608
dataset using the HEADER_BYTES_KEY and TRAILING_BYTES_KEY in most cases.
611609
"""
610+
log.debug(f"convert {blue_path}")
611+
612612
blue_path = Path(blue_path)
613613
if out_path is None:
614614
# extension will be changed later

0 commit comments

Comments
 (0)