@@ -488,6 +488,32 @@ def run_tvla(ctx: typer.Context):
488
488
# Amount of tolerable deviation from average during filtering.
489
489
num_sigmas = 3.5
490
490
491
+ # Slice of wave file
492
+ # these options are only tested for otbn
493
+ if (cfg ["mode" ] != "otbn" and "sample_start" in cfg and cfg ["sample_start" ] is not None ):
494
+ raise RuntimeError ('Option "sample_start is only supported for otbn!' )
495
+ if (cfg ["mode" ] != "otbn" and "num_samples" in cfg and cfg ["num_samples" ] is not None ):
496
+ raise RuntimeError ('Option "num_samples is only supported for otbn!' )
497
+
498
+ if (cfg ["mode" ] != "otbn" or cfg ["sample_start" ] is None ):
499
+ sample_start = 0
500
+ else :
501
+ sample_start = cfg ["sample_start" ]
502
+
503
+ assert sample_start < len (project .waves [0 ])
504
+
505
+ if (cfg ["mode" ] != "otbn" or cfg ["num_samples" ] is None ):
506
+ num_samples = len (project .waves [0 ]) - sample_start
507
+ else :
508
+ num_samples = cfg ["num_samples" ]
509
+
510
+ if (num_samples + sample_start > len (project .waves [0 ])):
511
+ log .warning (f"Selected sample window { sample_start } to " +
512
+ f"{ sample_start + num_samples } is out of range!" )
513
+ num_samples = len (project .waves [0 ]) - sample_start
514
+ log .warning (f"Will use samples from { sample_start } " +
515
+ f"to { sample_start + num_samples } instead!" )
516
+
491
517
# Overall number of traces, trace start and end indices.
492
518
num_traces_max = len (project .waves )
493
519
if cfg ["trace_start" ] is None :
@@ -548,8 +574,11 @@ def run_tvla(ctx: typer.Context):
548
574
log .info ("Converting Traces" )
549
575
if project .waves [0 ].dtype == 'uint16' :
550
576
traces = np .empty ((num_traces , num_samples ), dtype = np .uint16 )
577
+ log .info (f"Will use samples from { sample_start } to { sample_start + num_samples } " )
551
578
for i_trace in range (num_traces ):
552
- traces [i_trace ] = project .waves [i_trace + trace_start ]
579
+ traces [i_trace ] = project .waves [i_trace +
580
+ trace_start ][sample_start :sample_start +
581
+ num_samples ]
553
582
else :
554
583
traces = np .empty ((num_traces , num_samples ), dtype = np .double )
555
584
for i_trace in range (num_traces ):
0 commit comments