diff --git a/gamutrf/grscan.py b/gamutrf/grscan.py index f91cb9aa..77ed46cf 100755 --- a/gamutrf/grscan.py +++ b/gamutrf/grscan.py @@ -7,6 +7,7 @@ from pathlib import Path try: + from gnuradio import filter # pytype: disable=import-error from gnuradio import blocks # pytype: disable=import-error from gnuradio import fft # pytype: disable=import-error from gnuradio import gr # pytype: disable=import-error @@ -48,6 +49,10 @@ def __init__( tuning_ranges="", scaling="spectrum", description="", + dc_block_len=0, + dc_block_long=False, + db_clamp_floor=-200, + db_clamp_ceil=50, iqtlabs=None, wavelearner=None, ): @@ -77,7 +82,9 @@ def __init__( sdrargs=sdrargs, ) - fft_blocks, fft_roll = self.get_fft_blocks(fft_size, sdr) + fft_blocks, fft_roll = self.get_fft_blocks( + fft_size, sdr, dc_block_len, dc_block_long + ) self.fft_blocks = fft_blocks + self.get_db_blocks(fft_size, samp_rate, scaling) self.fft_to_inference_block = self.fft_blocks[-1] @@ -123,8 +130,8 @@ def __init__( tune_step_fft, skip_tune_step, fft_roll, - -200, - 50, + db_clamp_floor, + db_clamp_ceil, sample_dir, write_samples, bucket_range, @@ -251,10 +258,15 @@ def get_db_blocks(self, fft_size, samp_rate, scaling): def get_window(self, fft_size): return window.hann(fft_size) - def get_fft_blocks(self, fft_size, sdr): + def get_fft_blocks(self, fft_size, sdr, dc_block_len, dc_block_long): + fft_blocks = [] + fft_roll = False + if dc_block_len: + fft_blocks.append(filter.dc_blocker_cc(dc_block_len, dc_block_long)) if self.wavelearner: fft_batch_size = 256 - return ( + fft_roll = True + fft_blocks.extend( [ blocks.stream_to_vector( gr.sizeof_gr_complex, fft_batch_size * fft_size @@ -269,16 +281,16 @@ def get_fft_blocks(self, fft_size, sdr): blocks.vector_to_stream( gr.sizeof_gr_complex * fft_size, fft_batch_size ), - ], - True, + ] ) - return ( - [ - blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size), - fft.fft_vcc(fft_size, True, self.get_window(fft_size), True, 1), - ], - False, - ) + else: + fft_blocks.extend( + [ + blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size), + fft.fft_vcc(fft_size, True, self.get_window(fft_size), True, 1), + ] + ) + return (fft_blocks, fft_roll) def start(self): super().start() diff --git a/gamutrf/scan.py b/gamutrf/scan.py index 4949039b..a4379b3d 100755 --- a/gamutrf/scan.py +++ b/gamutrf/scan.py @@ -173,6 +173,33 @@ def argument_parser(): default=0.85, help="what proportion of FFT buckets to use", ) + parser.add_argument( + "--db_clamp_floor", + dest="db_clamp_floor", + type=float, + default=-200, + help="clamp dB output floor", + ) + parser.add_argument( + "--db_clamp_ceil", + dest="db_clamp_ceil", + type=float, + default=50, + help="clamp dB output ceil", + ) + parser.add_argument( + "--dc_block_len", + dest="dc_block_len", + type=int, + default=0, + help="if > 0, use dc_block_cc filter with length", + ) + parser.add_argument( + "--dc_block_long", + dest="dc_block_long", + action="store_true", + help="Use dc_block_cc long form", + ) parser.add_argument( "--inference_plan_file", dest="inference_plan_file", @@ -286,6 +313,10 @@ def run_loop(options, prom_vars, wavelearner): sample_dir=handler.options.sample_dir, write_samples=handler.options.write_samples, bucket_range=handler.options.bucket_range, + db_clamp_floor=handler.options.db_clamp_floor, + db_clamp_ceil=handler.options.db_clamp_ceil, + dc_block_len=handler.options.dc_block_len, + dc_block_long=handler.options.dc_block_long, inference_plan_file=handler.options.inference_plan_file, inference_output_dir=handler.options.inference_output_dir, inference_input_len=handler.options.inference_input_len,