From e450fdad4a1b34e635846f8cd20bc19bdc228018 Mon Sep 17 00:00:00 2001 From: csrichter Date: Wed, 1 Feb 2017 23:36:49 +0100 Subject: [PATCH] fft cut test --- grc/CMakeLists.txt | 3 +- grc/crfa_vector_cutter.xml | 44 ++++++++++++++++++++++++++++ python/CMakeLists.txt | 3 +- python/__init__.py | 1 + python/vector_cutter.py | 59 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 grc/crfa_vector_cutter.xml create mode 100644 python/vector_cutter.py diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 8d24022..724310f 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -24,5 +24,6 @@ install(FILES crfa_rds_decoder.xml crfa_max_freq.xml crfa_smooth_vectors.xml - crfa_stream_selector.xml DESTINATION share/gnuradio/grc/blocks + crfa_stream_selector.xml + crfa_vector_cutter.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/crfa_vector_cutter.xml b/grc/crfa_vector_cutter.xml new file mode 100644 index 0000000..c28dda9 --- /dev/null +++ b/grc/crfa_vector_cutter.xml @@ -0,0 +1,44 @@ + + + vector_cutter + crfa_vector_cutter + [crfa] + import crfa + crfa.vector_cutter($insize, $outsize, $cutpoint) + + set_cutpoint($cutpoint); + + insize + insize + 2048 + int + + + outsize + outsize + 1024 + int + + + cutpoint + cutpoint + 512 + int + + + + in + complex + $insize + + + + out + complex + $outsize + + diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5adfc50..3b2bd3e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -38,7 +38,8 @@ GR_PYTHON_INSTALL( max_freq.py smooth_vectors.py chart.py - stream_selector.py DESTINATION ${GR_PYTHON_DIR}/crfa + stream_selector.py + vector_cutter.py DESTINATION ${GR_PYTHON_DIR}/crfa ) ######################################################################## diff --git a/python/__init__.py b/python/__init__.py index 5eb27b8..9ed1cda 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -39,4 +39,5 @@ from max_freq import max_freq from smooth_vectors import smooth_vectors from chart import Chart from stream_selector import stream_selector +from vector_cutter import vector_cutter # diff --git a/python/vector_cutter.py b/python/vector_cutter.py new file mode 100644 index 0000000..6c77c0f --- /dev/null +++ b/python/vector_cutter.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2017 <+YOU OR YOUR COMPANY+>. +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this software; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import numpy as np +from gnuradio import gr +import code + +class vector_cutter(gr.sync_block): + """ + docstring for block vector_cutter + """ + def __init__(self, insize=2048,outsize=1024,cutpoint=512): + gr.sync_block.__init__(self, + name="vector_cutter", + in_sig=[(np.complex64,insize)], + out_sig=[(np.complex64,outsize)]) + + self.cutpoint=cutpoint + self.insize=insize + self.outsize=outsize + + def set_cutpoint(self, cutpoint=None): + print("cutpoint set to %i"%cutpoint) + if cutpoint is not None: + if isinstance(cutpoint, float) or isinstance(cutpoint, int): + self.cutpoint=cutpoint + else: + self.cutpoint = int(cutpoint) + def work(self, input_items, output_items): + in0 = input_items[0] + out = output_items[0] + # <+signal processing here+> + #out[:] = in0[512:1536] + for i,in_vec in enumerate(in0): + out[i]=in_vec[self.cutpoint:self.cutpoint+self.outsize] + #out = in0[512:1536] + #code.interact(local=locals()) + #out[0] = in0[0][512:1536] + #out[1] = in0[1][512:1536] + return len(output_items[0]) +