Browse Source

fft cut test

master
Clemens Richter 9 years ago
parent
commit
e450fdad4a
  1. 3
      grc/CMakeLists.txt
  2. 44
      grc/crfa_vector_cutter.xml
  3. 3
      python/CMakeLists.txt
  4. 1
      python/__init__.py
  5. 59
      python/vector_cutter.py

3
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
)

44
grc/crfa_vector_cutter.xml

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<block>
<name>vector_cutter</name>
<key>crfa_vector_cutter</key>
<category>[crfa]</category>
<import>import crfa</import>
<make>crfa.vector_cutter($insize, $outsize, $cutpoint)</make>
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<callback>set_cutpoint($cutpoint);</callback>
<param>
<name>insize</name>
<key>insize</key>
<value>2048</value>
<type>int</type>
</param>
<param>
<name>outsize</name>
<key>outsize</key>
<value>1024</value>
<type>int</type>
</param>
<param>
<name>cutpoint</name>
<key>cutpoint</key>
<value>512</value>
<type>int</type>
</param>
<sink>
<name>in</name>
<type>complex</type>
<vlen>$insize</vlen>
</sink>
<source>
<name>out</name>
<type>complex</type>
<vlen>$outsize</vlen>
</source>
</block>

3
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
)
########################################################################

1
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
#

59
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])
Loading…
Cancel
Save