diff options
Diffstat (limited to 'gnuradio-core/src/python')
46 files changed, 214 insertions, 2716 deletions
diff --git a/gnuradio-core/src/python/gnuradio/__init__.py b/gnuradio-core/src/python/gnuradio/__init__.py index a4917cf64c..d55dac79db 100644 --- a/gnuradio-core/src/python/gnuradio/__init__.py +++ b/gnuradio-core/src/python/gnuradio/__init__.py @@ -1 +1,12 @@ -# make this a package +""" +GNU Radio is a free & open-source software development toolkit that provides signal processing blocks to implement software radios. It can be used with readily-available low-cost external RF hardware to create software-defined radios, or without hardware in a simulation-like environment. It is widely used in hobbyist, academic and commercial environments to support both wireless communications research and real-world radio systems. + +GNU Radio applications are primarily written using the Python programming language, while the supplied performance-critical signal-processing path is implemented in C++ using processor floating-point extensions, where available. Thus, the developer is able to implement real-time, high-throughput radio systems in a simple-to-use, rapid-application-development environment. + +While not primarily a simulation tool, GNU Radio does support development of signal processing algorithms using pre-recorded or generated data, avoiding the need for actual RF hardware. + +GNU Radio is licensed under the GNU General Public License (GPL) version 3. All of the code is copyright of the Free Software Foundation. +""" + +# This file makes gnuradio a package +# The docstring will be associated with the top level of the package. diff --git a/gnuradio-core/src/python/gnuradio/blks2/__init__.py b/gnuradio-core/src/python/gnuradio/blks2/__init__.py index 2dfdc77f46..1d3203ec79 100644 --- a/gnuradio-core/src/python/gnuradio/blks2/__init__.py +++ b/gnuradio-core/src/python/gnuradio/blks2/__init__.py @@ -18,6 +18,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # +""" +Miscellaneous contents implemented in python. +""" import glob import os.path diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt index 61fcdda42d..b8ec6c88c4 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,17 +22,11 @@ include(GrPython) GR_PYTHON_INSTALL(FILES __init__.py am_demod.py - channel_model.py filterbank.py fm_demod.py fm_emph.py - logpwrfft.py nbfm_rx.py nbfm_tx.py - pfb_arb_resampler.py - pfb_channelizer.py - pfb_decimator.py - pfb_interpolator.py rational_resampler.py standard_squelch.py stream_to_vector_decimator.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/am_demod.py b/gnuradio-core/src/python/gnuradio/blks2impl/am_demod.py index 68d024565a..6420348be3 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/am_demod.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/am_demod.py @@ -30,14 +30,11 @@ class am_demod_cf(gr.hier_block2): filtering to the audio output. It produces a float stream in the range [-1.0, +1.0]. - @param channel_rate: incoming sample rate of the AM baseband - @type sample_rate: integer - @param audio_decim: input to output decimation rate - @type audio_decim: integer - @param audio_pass: audio low pass filter passband frequency - @type audio_pass: float - @param audio_stop: audio low pass filter stop frequency - @type audio_stop: float + Args: + channel_rate: incoming sample rate of the AM baseband (integer) + audio_decim: input to output decimation rate (integer) + audio_pass: audio low pass filter passband frequency (float) + audio_stop: audio low pass filter stop frequency (float) """ def __init__(self, channel_rate, audio_decim, audio_pass, audio_stop): gr.hier_block2.__init__(self, "am_demod_cf", @@ -64,10 +61,9 @@ class demod_10k0a3e_cf(am_demod_cf): This block demodulates an AM channel conformant to 10K0A3E emission standards, such as broadcast band AM transmissions. - @param channel_rate: incoming sample rate of the AM baseband - @type sample_rate: integer - @param audio_decim: input to output decimation rate - @type audio_decim: integer + Args: + channel_rate: incoming sample rate of the AM baseband (integer) + audio_decim: input to output decimation rate (integer) """ def __init__(self, channel_rate, audio_decim): am_demod_cf.__init__(self, channel_rate, audio_decim, diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py b/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py deleted file mode 100644 index e5cd471df5..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr - -# This block is now a C++ hierarchical block, gr.channel_model -channel_model = gr.channel_model diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py b/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py index 08f1d450ba..29e50bc2a3 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py @@ -45,8 +45,9 @@ class synthesis_filterbank(gr.hier_block2): Takes M complex streams in, produces single complex stream out that runs at M times the input sample rate - @param mpoints: number of freq bins/interpolation factor/subbands - @param taps: filter taps for subband filter + Args: + mpoints: number of freq bins/interpolation factor/subbands + taps: filter taps for subband filter The channel spacing is equal to the input sample rate. The total bandwidth and output sample rate are equal the input @@ -128,8 +129,9 @@ class analysis_filterbank(gr.hier_block2): Takes 1 complex stream in, produces M complex streams out that runs at 1/M times the input sample rate - @param mpoints: number of freq bins/interpolation factor/subbands - @param taps: filter taps for subband filter + Args: + mpoints: number of freq bins/interpolation factor/subbands + taps: filter taps for subband filter Same channel to frequency mapping as described above. """ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py b/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py index 6bc0d7ed0d..cc93d5b45c 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/fm_demod.py @@ -33,20 +33,14 @@ class fm_demod_cf(gr.hier_block2): deemphasis. Low pass filtering is done on the resultant signal. It produces an output float strem in the range of [-1.0, +1.0]. - @param channel_rate: incoming sample rate of the FM baseband - @type sample_rate: integer - @param deviation: maximum FM deviation (default = 5000) - @type deviation: float - @param audio_decim: input to output decimation rate - @type audio_decim: integer - @param audio_pass: audio low pass filter passband frequency - @type audio_pass: float - @param audio_stop: audio low pass filter stop frequency - @type audio_stop: float - @param gain: gain applied to audio output (default = 1.0) - @type gain: float - @param tau: deemphasis time constant (default = 75e-6), specify 'None' - to prevent deemphasis + Args: + channel_rate: incoming sample rate of the FM baseband (integer) + deviation: maximum FM deviation (default = 5000) (float) + audio_decim: input to output decimation rate (integer) + audio_pass: audio low pass filter passband frequency (float) + audio_stop: audio low pass filter stop frequency (float) + gain: gain applied to audio output (default = 1.0) (float) + tau: deemphasis time constant (default = 75e-6), specify 'None' to prevent deemphasis """ def __init__(self, channel_rate, audio_decim, deviation, audio_pass, audio_stop, gain=1.0, tau=75e-6): @@ -79,10 +73,9 @@ class demod_20k0f3e_cf(fm_demod_cf): channel conforming to 20K0F3E emission standards, outputting floats in the range [-1.0, +1.0]. - @param sample_rate: incoming sample rate of the FM baseband - @type sample_rate: integer - @param audio_decim: input to output decimation rate - @type audio_decim: integer + Args: + sample_rate: incoming sample rate of the FM baseband (integer) + audio_decim: input to output decimation rate (integer) """ def __init__(self, channel_rate, audio_decim): fm_demod_cf.__init__(self, channel_rate, audio_decim, @@ -98,10 +91,9 @@ class demod_200kf3e_cf(fm_demod_cf): channel conforming to 200KF3E emission standards, outputting floats in the range [-1.0, +1.0]. - @param sample_rate: incoming sample rate of the FM baseband - @type sample_rate: integer - @param audio_decim: input to output decimation rate - @type audio_decim: integer + Args: + sample_rate: incoming sample rate of the FM baseband (integer) + audio_decim: input to output decimation rate (integer) """ def __init__(self, channel_rate, audio_decim): fm_demod_cf.__init__(self, channel_rate, audio_decim, diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/fm_emph.py b/gnuradio-core/src/python/gnuradio/blks2impl/fm_emph.py index fc3f2d60d2..080ebe151f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/fm_emph.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/fm_emph.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, filter import math @@ -43,10 +43,10 @@ class fm_deemph(gr.hier_block2): def __init__(self, fs, tau=75e-6): """ - @param fs: sampling frequency in Hz - @type fs: float - @param tau: Time constant in seconds (75us in US, 50us in EUR) - @type tau: float + + Args: + fs: sampling frequency in Hz (float) + tau: Time constant in seconds (75us in US, 50us in EUR) (float) """ gr.hier_block2.__init__(self, "fm_deemph", gr.io_signature(1, 1, gr.sizeof_float), # Input signature @@ -68,7 +68,7 @@ class fm_deemph(gr.hier_block2): global plot1 plot1 = gru.gnuplot_freqz (gru.freqz (btaps, ataps), fs, True) - deemph = gr.iir_filter_ffd(btaps, ataps) + deemph = filter.iir_filter_ffd(btaps, ataps) self.connect(self, deemph, self) # @@ -126,10 +126,10 @@ class fm_preemph(gr.hier_block2): """ def __init__(self, fs, tau=75e-6): """ - @param fs: sampling frequency in Hz - @type fs: float - @param tau: Time constant in seconds (75us in US, 50us in EUR) - @type tau: float + + Args: + fs: sampling frequency in Hz (float) + tau: Time constant in seconds (75us in US, 50us in EUR) (float) """ gr.hier_block2.__init__(self, "fm_deemph", @@ -147,5 +147,5 @@ class fm_preemph(gr.hier_block2): global plot2 plot2 = gru.gnuplot_freqz (gru.freqz (btaps, ataps), fs, True) - preemph = gr.iir_filter_ffd(btaps, ataps) + preemph = filter.iir_filter_ffd(btaps, ataps) self.connect(self, preemph, self) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py deleted file mode 100644 index 6f7fc520fa..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py +++ /dev/null @@ -1,155 +0,0 @@ -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, window -from stream_to_vector_decimator import stream_to_vector_decimator -import math - -class _logpwrfft_base(gr.hier_block2): - """ - Create a log10(abs(fft)) stream chain, with real or complex input. - """ - - def __init__(self, sample_rate, fft_size, ref_scale, frame_rate, avg_alpha, average, win=None): - """ - Create an log10(abs(fft)) stream chain. - Provide access to the setting the filter and sample rate. - @param sample_rate Incoming stream sample rate - @param fft_size Number of FFT bins - @param ref_scale Sets 0 dB value input amplitude - @param frame_rate Output frame rate - @param avg_alpha FFT averaging (over time) constant [0.0-1.0] - @param average Whether to average [True, False] - @param win the window taps generation function - """ - gr.hier_block2.__init__(self, self._name, - gr.io_signature(1, 1, self._item_size), # Input signature - gr.io_signature(1, 1, gr.sizeof_float*fft_size)) # Output signature - - self._sd = stream_to_vector_decimator(item_size=self._item_size, - sample_rate=sample_rate, - vec_rate=frame_rate, - vec_len=fft_size) - - if win is None: win = window.blackmanharris - fft_window = win(fft_size) - fft = self._fft_block[0](fft_size, True, fft_window) - window_power = sum(map(lambda x: x*x, fft_window)) - - c2magsq = gr.complex_to_mag_squared(fft_size) - self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size) - self._log = gr.nlog10_ff(10, fft_size, - -20*math.log10(fft_size) # Adjust for number of bins - -10*math.log10(window_power/fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale - self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self) - - self._average = average - self._avg_alpha = avg_alpha - self.set_avg_alpha(avg_alpha) - self.set_average(average) - - def set_decimation(self, decim): - """ - Set the decimation on stream decimator. - @param decim the new decimation - """ - self._sd.set_decimation(decim) - - def set_vec_rate(self, vec_rate): - """ - Set the vector rate on stream decimator. - @param vec_rate the new vector rate - """ - self._sd.set_vec_rate(vec_rate) - - def set_sample_rate(self, sample_rate): - """ - Set the new sampling rate - @param sample_rate the new rate - """ - self._sd.set_sample_rate(sample_rate) - - def set_average(self, average): - """ - Set the averaging filter on/off. - @param average true to set averaging on - """ - self._average = average - if self._average: - self._avg.set_taps(self._avg_alpha) - else: - self._avg.set_taps(1.0) - - def set_avg_alpha(self, avg_alpha): - """ - Set the average alpha and set the taps if average was on. - @param avg_alpha the new iir filter tap - """ - self._avg_alpha = avg_alpha - self.set_average(self._average) - - def sample_rate(self): - """ - Return the current sample rate. - """ - return self._sd.sample_rate() - - def decimation(self): - """ - Return the current decimation. - """ - return self._sd.decimation() - - def frame_rate(self): - """ - Return the current frame rate. - """ - return self._sd.frame_rate() - - def average(self): - """ - Return whether or not averaging is being performed. - """ - return self._average - - def avg_alpha(self): - """ - Return averaging filter constant. - """ - return self._avg_alpha - -class logpwrfft_f(_logpwrfft_base): - """ - Create an fft block chain, with real input. - """ - _name = "logpwrfft_f" - _item_size = gr.sizeof_float - _fft_block = (gr.fft_vfc, ) - -class logpwrfft_c(_logpwrfft_base): - """ - Create an fft block chain, with complex input. - """ - _name = "logpwrfft_c" - _item_size = gr.sizeof_gr_complex - _fft_block = (gr.fft_vcc, ) - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_rx.py b/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_rx.py index 8bcb47ae19..40eb255e1e 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_rx.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_rx.py @@ -32,14 +32,11 @@ class nbfm_rx(gr.hier_block2): Takes a single complex baseband input stream and produces a single float output stream of audio sample in the range [-1, +1]. - @param audio_rate: sample rate of audio stream, >= 16k - @type audio_rate: integer - @param quad_rate: sample rate of output stream - @type quad_rate: integer - @param tau: preemphasis time constant (default 75e-6) - @type tau: float - @param max_dev: maximum deviation in Hz (default 5e3) - @type max_dev: float + Args: + audio_rate: sample rate of audio stream, >= 16k (integer) + quad_rate: sample rate of output stream (integer) + tau: preemphasis time constant (default 75e-6) (float) + max_dev: maximum deviation in Hz (default 5e3) (float) quad_rate must be an integer multiple of audio_rate. diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_tx.py b/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_tx.py index 839cf6784a..75e96f2374 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_tx.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/nbfm_tx.py @@ -20,7 +20,7 @@ # import math -from gnuradio import gr, optfir +from gnuradio import gr, optfir, filter from gnuradio.blks2impl.fm_emph import fm_preemph #from gnuradio import ctcss @@ -33,14 +33,11 @@ class nbfm_tx(gr.hier_block2): Takes a single float input stream of audio samples in the range [-1,+1] and produces a single FM modulated complex baseband output. - @param audio_rate: sample rate of audio stream, >= 16k - @type audio_rate: integer - @param quad_rate: sample rate of output stream - @type quad_rate: integer - @param tau: preemphasis time constant (default 75e-6) - @type tau: float - @param max_dev: maximum deviation in Hz (default 5e3) - @type max_dev: float + Args: + audio_rate: sample rate of audio stream, >= 16k (integer) + quad_rate: sample rate of output stream (integer) + tau: preemphasis time constant (default 75e-6) (float) + max_dev: maximum deviation in Hz (default 5e3) (float) quad_rate must be an integer multiple of audio_rate. """ @@ -69,7 +66,7 @@ class nbfm_tx(gr.hier_block2): 40) # stopband atten dB #print "len(interp_taps) =", len(interp_taps) - self.interpolator = gr.interp_fir_filter_fff (interp_factor, interp_taps) + self.interpolator = filter.interp_fir_filter_fff (interp_factor, interp_taps) self.preemph = fm_preemph (quad_rate, tau=tau) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py deleted file mode 100644 index e83c327fc8..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir - -class pfb_arb_resampler_ccf(gr.hier_block2): - ''' - Convenience wrapper for the polyphase filterbank arbitrary resampler. - - The block takes a single complex stream in and outputs a single complex - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, rate, taps=None, flt_size=32, atten=100): - gr.hier_block2.__init__(self, "pfb_arb_resampler_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._rate = rate - self._size = flt_size - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) - made = False - while not made: - try: - self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_arb_resampler_ccf(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - # Note -- set_taps not implemented in base class yet - def set_taps(self, taps): - self.pfb.set_taps(taps) - - def set_rate(self, rate): - self.pfb.set_rate(rate) - - -class pfb_arb_resampler_fff(gr.hier_block2): - ''' - Convenience wrapper for the polyphase filterbank arbitrary resampler. - - The block takes a single float stream in and outputs a single float - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, rate, taps=None, flt_size=32, atten=100): - gr.hier_block2.__init__(self, "pfb_arb_resampler_fff", - gr.io_signature(1, 1, gr.sizeof_float), # Input signature - gr.io_signature(1, 1, gr.sizeof_float)) # Output signature - - self._rate = rate - self._size = flt_size - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) - made = False - while not made: - try: - self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_arb_resampler_fff(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - # Note -- set_taps not implemented in base class yet - def set_taps(self, taps): - self.pfb.set_taps(taps) - - def set_rate(self, rate): - self.pfb.set_rate(rate) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py deleted file mode 100644 index 4bbe1bec6c..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir - -class pfb_channelizer_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter channelizer (complex in, complex out, floating-point taps) - - This simplifies the interface by allowing a single input stream to connect to this block. - It will then output a stream for each channel. - ''' - def __init__(self, numchans, taps=None, oversample_rate=1, atten=100): - gr.hier_block2.__init__(self, "pfb_channelizer_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature - - self._nchans = numchans - self._oversample_rate = oversample_rate - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - made = False - while not made: - try: - self._taps = optfir.low_pass(1, self._nchans, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._nchans) - self.pfb = gr.pfb_channelizer_ccf(self._nchans, self._taps, - self._oversample_rate) - self.connect(self, self.s2ss) - - for i in xrange(self._nchans): - self.connect((self.s2ss,i), (self.pfb,i)) - self.connect((self.pfb,i), (self,i)) - - def set_channel_map(self, newmap): - self.pfb.set_channel_map(newmap) - - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py deleted file mode 100644 index adcdfe9ba1..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir - -class pfb_decimator_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter decimator (complex in, complex out, floating-point taps) - - This simplifies the interface by allowing a single input stream to connect to this block. - It will then output a stream that is the decimated output stream. - ''' - def __init__(self, decim, taps=None, channel=0, atten=100): - gr.hier_block2.__init__(self, "pfb_decimator_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._decim = decim - self._channel = channel - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - made = False - while not made: - try: - self._taps = optfir.low_pass(1, self._decim, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._decim) - self.pfb = gr.pfb_decimator_ccf(self._decim, self._taps, self._channel) - - self.connect(self, self.s2ss) - - for i in xrange(self._decim): - self.connect((self.s2ss,i), (self.pfb,i)) - - self.connect(self.pfb, self) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py deleted file mode 100644 index 5492dfcac6..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir - -class pfb_interpolator_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter interpolator (complex in, complex out, floating-point taps) - - The block takes a single complex stream in and outputs a single complex - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, interp, taps=None, atten=100): - gr.hier_block2.__init__(self, "pfb_interpolator_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._interp = interp - self._taps = taps - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.99 - made = False - while not made: - try: - self._taps = optfir.low_pass(self._interp, self._interp, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - - - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py index eea12af958..33b5b0b1f3 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/rational_resampler.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru +from gnuradio import gr, gru, filter _plot = None @@ -28,13 +28,12 @@ def design_filter(interpolation, decimation, fractional_bw): Given the interpolation rate, decimation rate and a fractional bandwidth, design a set of taps. - @param interpolation: interpolation factor - @type interpolation: integer > 0 - @param decimation: decimation factor - @type decimation: integer > 0 - @param fractional_bw: fractional bandwidth in (0, 0.5) 0.4 works well. - @type fractional_bw: float - @returns: sequence of numbers + Args: + interpolation: interpolation factor (integer > 0) + decimation: decimation factor (integer > 0) + fractional_bw: fractional bandwidth in (0, 0.5) 0.4 works well. (float) + Returns: + : sequence of numbers """ if fractional_bw >= 0.5 or fractional_bw <= 0: @@ -69,14 +68,11 @@ class _rational_resampler_base(gr.hier_block2): If neither is specified, a reasonable default, 0.4, is used as the fractional_bw. - @param interpolation: interpolation factor - @type interpolation: integer > 0 - @param decimation: decimation factor - @type decimation: integer > 0 - @param taps: optional filter coefficients - @type taps: sequence - @param fractional_bw: fractional bandwidth in (0, 0.5), measured at final freq (use 0.4) - @type fractional_bw: float + Args: + interpolation: interpolation factor (integer > 0) + decimation: decimation factor (integer > 0) + taps: optional filter coefficients (sequence) + fractional_bw: fractional bandwidth in (0, 0.5), measured at final freq (use 0.4) (float) """ if not isinstance(interpolation, int) or interpolation < 1: @@ -109,7 +105,7 @@ class rational_resampler_fff(_rational_resampler_base): Rational resampling polyphase FIR filter with float input, float output and float taps. """ - _rational_resampler_base.__init__(self, gr.rational_resampler_base_fff, + _rational_resampler_base.__init__(self, filter.rational_resampler_base_fff, interpolation, decimation, taps, fractional_bw) class rational_resampler_ccf(_rational_resampler_base): @@ -118,7 +114,7 @@ class rational_resampler_ccf(_rational_resampler_base): Rational resampling polyphase FIR filter with complex input, complex output and float taps. """ - _rational_resampler_base.__init__(self, gr.rational_resampler_base_ccf, + _rational_resampler_base.__init__(self, filter.rational_resampler_base_ccf, interpolation, decimation, taps, fractional_bw) class rational_resampler_ccc(_rational_resampler_base): @@ -127,5 +123,5 @@ class rational_resampler_ccc(_rational_resampler_base): Rational resampling polyphase FIR filter with complex input, complex output and complex taps. """ - _rational_resampler_base.__init__(self, gr.rational_resampler_base_ccc, + _rational_resampler_base.__init__(self, filter.rational_resampler_base_ccc, interpolation, decimation, taps, fractional_bw) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py b/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py index 8f75729c91..d6808b722f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py @@ -29,10 +29,12 @@ class stream_to_vector_decimator(gr.hier_block2): def __init__(self, item_size, sample_rate, vec_rate, vec_len): """ Create the block chain. - @param item_size the number of bytes per sample - @param sample_rate the rate of incoming samples - @param vec_rate the rate of outgoing vectors (same units as sample_rate) - @param vec_len the length of the outgoing vectors in items + + Args: + item_size: the number of bytes per sample + sample_rate: the rate of incoming samples + vec_rate: the rate of outgoing vectors (same units as sample_rate) + vec_len: the length of the outgoing vectors in items """ self._vec_rate = vec_rate self._vec_len = vec_len @@ -50,7 +52,9 @@ class stream_to_vector_decimator(gr.hier_block2): def set_sample_rate(self, sample_rate): """ Set the new sampling rate and update the decimator. - @param sample_rate the new rate + + Args: + sample_rate: the new rate """ self._sample_rate = sample_rate self._update_decimator() @@ -58,7 +62,9 @@ class stream_to_vector_decimator(gr.hier_block2): def set_vec_rate(self, vec_rate): """ Set the new vector rate and update the decimator. - @param vec_rate the new rate + + Args: + vec_rate: the new rate """ self._vec_rate = vec_rate self._update_decimator() @@ -66,7 +72,9 @@ class stream_to_vector_decimator(gr.hier_block2): def set_decimation(self, decim): """ Set the decimation parameter directly. - @param decim the new decimation + + Args: + decim: the new decimation """ self._decim = max(1, int(round(decim))) self.one_in_n.set_n(self._decim) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv.py index d1cbcf9127..fe4fdd1a6a 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv.py @@ -31,10 +31,9 @@ class wfm_rcv(gr.hier_block2): The input is the downconverted complex baseband signal (gr_complex). The output is the demodulated audio (float). - @param quad_rate: input sample rate of complex baseband input. - @type quad_rate: float - @param audio_decimation: how much to decimate quad_rate to get to audio. - @type audio_decimation: integer + Args: + quad_rate: input sample rate of complex baseband input. (float) + audio_decimation: how much to decimate quad_rate to get to audio. (integer) """ gr.hier_block2.__init__(self, "wfm_rcv", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py index e229bcc2e6..24c710a494 100755 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_fmdet.py @@ -32,10 +32,9 @@ class wfm_rcv_fmdet(gr.hier_block2): (gr_complex). The output is two streams of the demodulated audio (float) 0=Left, 1=Right. - @param demod_rate: input sample rate of complex baseband input. - @type demod_rate: float - @param audio_decimation: how much to decimate demod_rate to get to audio. - @type audio_decimation: integer + Args: + demod_rate: input sample rate of complex baseband input. (float) + audio_decimation: how much to decimate demod_rate to get to audio. (integer) """ gr.hier_block2.__init__(self, "wfm_rcv_fmdet", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py index d4ce6d2231..0b8706bf27 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_rcv_pll.py @@ -31,10 +31,9 @@ class wfm_rcv_pll(gr.hier_block2): The input is the downconverted complex baseband signal (gr_complex). The output is two streams of the demodulated audio (float) 0=Left, 1=Right. - @param demod_rate: input sample rate of complex baseband input. - @type demod_rate: float - @param audio_decimation: how much to decimate demod_rate to get to audio. - @type audio_decimation: integer + Args: + demod_rate: input sample rate of complex baseband input. (float) + audio_decimation: how much to decimate demod_rate to get to audio. (integer) """ gr.hier_block2.__init__(self, "wfm_rcv_pll", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_tx.py b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_tx.py index 3fcf98f891..e7547d6524 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/wfm_tx.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/wfm_tx.py @@ -31,14 +31,11 @@ class wfm_tx(gr.hier_block2): Takes a single float input stream of audio samples in the range [-1,+1] and produces a single FM modulated complex baseband output. - @param audio_rate: sample rate of audio stream, >= 16k - @type audio_rate: integer - @param quad_rate: sample rate of output stream - @type quad_rate: integer - @param tau: preemphasis time constant (default 75e-6) - @type tau: float - @param max_dev: maximum deviation in Hz (default 75e3) - @type max_dev: float + Args: + audio_rate: sample rate of audio stream, >= 16k (integer) + quad_rate: sample rate of output stream (integer) + tau: preemphasis time constant (default 75e-6) (float) + max_dev: maximum deviation in Hz (default 75e3) (float) quad_rate must be an integer multiple of audio_rate. """ diff --git a/gnuradio-core/src/python/gnuradio/eng_notation.py b/gnuradio-core/src/python/gnuradio/eng_notation.py index c552a45f55..d23f9005f0 100644 --- a/gnuradio-core/src/python/gnuradio/eng_notation.py +++ b/gnuradio-core/src/python/gnuradio/eng_notation.py @@ -18,6 +18,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # +""" +Display numbers as strings using engineering notation. +""" scale_factor = {} scale_factor['E'] = 1e18 diff --git a/gnuradio-core/src/python/gnuradio/eng_option.py b/gnuradio-core/src/python/gnuradio/eng_option.py index 02e9b0b6df..5d8660f0f2 100644 --- a/gnuradio-core/src/python/gnuradio/eng_option.py +++ b/gnuradio-core/src/python/gnuradio/eng_option.py @@ -43,7 +43,8 @@ def check_subdev (option, opt, value): """ Value has the form: (A|B)(:0|1)? - @returns a 2-tuple (0|1, 0|1) + Returns: + a 2-tuple (0|1, 0|1) """ d = { 'A' : (0, 0), 'A:0' : (0, 0), 'A:1' : (0, 1), 'A:2' : (0, 2), 'B' : (1, 0), 'B:0' : (1, 0), 'B:1' : (1, 1), 'B:2' : (1, 2) } diff --git a/gnuradio-core/src/python/gnuradio/gr/__init__.py b/gnuradio-core/src/python/gnuradio/gr/__init__.py index 602d1119fb..525c06cf5d 100644 --- a/gnuradio-core/src/python/gnuradio/gr/__init__.py +++ b/gnuradio-core/src/python/gnuradio/gr/__init__.py @@ -21,6 +21,10 @@ # The presence of this file turns this directory into a Python package +""" +Core contents. +""" + # This is the main GNU Radio python module. # We pull the swig output and the other modules into the gnuradio.gr namespace diff --git a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py index 0c45f1691d..bf7f26794f 100644 --- a/gnuradio-core/src/python/gnuradio/gr/hier_block2.py +++ b/gnuradio-core/src/python/gnuradio/gr/hier_block2.py @@ -31,7 +31,9 @@ from gnuradio_core import hier_block2_swig # class hier_block2(object): """ - Python wrapper around the C++ hierarchical block implementation. + Subclass this to create a python hierarchical block. + + This is a python wrapper around the C++ hierarchical block implementation. Provides convenience functions and allows proper Python subclassing. """ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py b/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py deleted file mode 100755 index 1757358676..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_dc_blocker(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - ''' Test impulse response - long form, cc ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.02072429656982422+0j), (-0.02081298828125+0j), - (0.979156494140625+0j), (-0.02081298828125+0j), - (-0.02072429656982422+0j)) - - src = gr.vector_source_c(src_data) - op = gr.dc_blocker_cc(32, True) - dst = gr.vector_sink_c() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around 2D-2 - result_data = dst.data()[60:65] - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - ''' Test impulse response - short form, cc ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.029296875+0j), (-0.0302734375+0j), - (0.96875+0j), (-0.0302734375+0j), - (-0.029296875+0j)) - - src = gr.vector_source_c(src_data) - op = gr.dc_blocker_cc(32, False) - dst = gr.vector_sink_c() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around D-1 - result_data = dst.data()[29:34] - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - - def test_003(self): - ''' Test impulse response - long form, ff ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.02072429656982422), (-0.02081298828125), - (0.979156494140625), (-0.02081298828125), - (-0.02072429656982422)) - - src = gr.vector_source_f(src_data) - op = gr.dc_blocker_ff(32, True) - dst = gr.vector_sink_f() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around 2D-2 - result_data = dst.data()[60:65] - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_004(self): - ''' Test impulse response - short form, ff ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.029296875), (-0.0302734375), - (0.96875), (-0.0302734375), - (-0.029296875)) - - src = gr.vector_source_f(src_data) - op = gr.dc_blocker_ff(32, False) - dst = gr.vector_sink_f() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around D-1 - result_data = dst.data()[29:34] - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_dc_blocker, "test_dc_blocker.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py b/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py deleted file mode 100755 index c1fe2a7000..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math -import random - -def make_random_int_tuple(L, min, max): - result = [] - for x in range(L): - result.append(random.randint(min, max)) - return tuple(result) - - -class test_diff_encoder (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_diff_encdec_000(self): - random.seed(0) - modulus = 2 - src_data = make_random_int_tuple(1000, 0, modulus-1) - expected_result = src_data - src = gr.vector_source_b(src_data) - enc = gr.diff_encoder_bb(modulus) - dec = gr.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() - self.tb.connect(src, enc, dec, dst) - self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data() # fetch the contents of the sink - self.assertEqual(expected_result, actual_result) - - def test_diff_encdec_001(self): - random.seed(0) - modulus = 4 - src_data = make_random_int_tuple(1000, 0, modulus-1) - expected_result = src_data - src = gr.vector_source_b(src_data) - enc = gr.diff_encoder_bb(modulus) - dec = gr.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() - self.tb.connect(src, enc, dec, dst) - self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data() # fetch the contents of the sink - self.assertEqual(expected_result, actual_result) - - def test_diff_encdec_002(self): - random.seed(0) - modulus = 8 - src_data = make_random_int_tuple(40000, 0, modulus-1) - expected_result = src_data - src = gr.vector_source_b(src_data) - enc = gr.diff_encoder_bb(modulus) - dec = gr.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() - self.tb.connect(src, enc, dec, dst) - self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data() # fetch the contents of the sink - self.assertEqual(expected_result, actual_result) - -if __name__ == '__main__': - gr_unittest.run(test_diff_encoder, "test_diff_encoder.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py deleted file mode 100755 index 41f96aa616..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -class test_diff_phasor (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_diff_phasor_cc (self): - src_data = (0+0j, 1+0j, -1+0j, 3+4j, -3-4j, -3+4j) - expected_result = (0+0j, 0+0j, -1+0j, -3-4j, -25+0j, -7-24j) - src = gr.vector_source_c (src_data) - op = gr.diff_phasor_cc () - dst = gr.vector_sink_c () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink - self.assertComplexTuplesAlmostEqual (expected_result, actual_result) - - - -if __name__ == '__main__': - gr_unittest.run(test_diff_phasor, "test_diff_phasor.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py deleted file mode 100755 index 693d0e67c5..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -from gnuradio import gr, gr_unittest -import sys -import random - -primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53, - 59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131, - 137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223, - 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311) - - -class test_fft(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def assert_fft_ok2(self, expected_result, result_data): - expected_result = expected_result[:len(result_data)] - self.assertComplexTuplesAlmostEqual2 (expected_result, result_data, - abs_eps=1e-9, rel_eps=4e-4) - - def assert_fft_float_ok2(self, expected_result, result_data, abs_eps=1e-9, rel_eps=4e-4): - expected_result = expected_result[:len(result_data)] - self.assertFloatTuplesAlmostEqual2 (expected_result, result_data, - abs_eps, rel_eps) - - def test_001(self): - tb = gr.top_block() - fft_size = 32 - src_data = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - expected_result = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, True, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - self.assert_fft_ok2(expected_result, result_data) - - def test_002(self): - tb = gr.top_block() - fft_size = 32 - - tmp_data = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src_data = tuple([x/fft_size for x in tmp_data]) - - expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, False, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - self.assert_fft_ok2(expected_result, result_data) - - def test_003(self): - # Same test as above, only use 2 threads - - tb = gr.top_block() - fft_size = 32 - - tmp_data = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src_data = tuple([x/fft_size for x in tmp_data]) - - expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - nthreads = 2 - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, False, [], False, nthreads) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - self.assert_fft_ok2(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_fft, "test_fft.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py deleted file mode 100755 index c0aadc306f..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2005,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import sys -import random - -def make_random_complex_tuple(L): - result = [] - for x in range(L): - result.append(complex(random.uniform(-1000,1000), - random.uniform(-1000,1000))) - return tuple(result) - -def make_random_float_tuple(L): - result = [] - for x in range(L): - result.append(float(int(random.uniform(-1000,1000)))) - return tuple(result) - - -def reference_filter_ccc(dec, taps, input): - """ - compute result using conventional fir filter - """ - tb = gr.top_block() - #src = gr.vector_source_c(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_c(input) - op = gr.fir_filter_ccc(dec, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - return dst.data() - -def reference_filter_fff(dec, taps, input): - """ - compute result using conventional fir filter - """ - tb = gr.top_block() - #src = gr.vector_source_f(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_f(input) - op = gr.fir_filter_fff(dec, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - return dst.data() - - -def print_complex(x): - for i in x: - i = complex(i) - sys.stdout.write("(%6.3f,%6.3fj), " % (i.real, i.imag)) - sys.stdout.write('\n') - - -class test_fft_filter(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def assert_fft_ok2(self, expected_result, result_data): - expected_result = expected_result[:len(result_data)] - self.assertComplexTuplesAlmostEqual2 (expected_result, result_data, - abs_eps=1e-9, rel_eps=4e-4) - - def assert_fft_float_ok2(self, expected_result, result_data, abs_eps=1e-9, rel_eps=4e-4): - expected_result = expected_result[:len(result_data)] - self.assertFloatTuplesAlmostEqual2 (expected_result, result_data, - abs_eps, rel_eps) - - #def test_ccc_000(self): - # self.assertRaises (RuntimeError, gr.fft_filter_ccc, 2, (1,)) - - def test_ccc_001(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (1,) - expected_result = tuple([complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_ccc_002(self): - # Test nthreads - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - nthreads = 2 - expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps, nthreads) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - def test_ccc_003(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_ccc_004(self): - random.seed(0) - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(1, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - del tb - - self.assert_fft_ok2(expected_result, result_data) - - def test_ccc_005(self): - random.seed(0) - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(dec, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(dec, taps) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - del tb - result_data = dst.data() - - self.assert_fft_ok2(expected_result, result_data) - - def test_ccc_006(self): - # Test decimating with nthreads=2 - random.seed(0) - nthreads = 2 - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(dec, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(dec, taps, nthreads) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - del tb - result_data = dst.data() - - self.assert_fft_ok2(expected_result, result_data) - - # ---------------------------------------------------------------- - # test _fff version - # ---------------------------------------------------------------- - - def test_fff_001(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (1,) - expected_result = tuple([float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_fff_002(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - def test_fff_003(self): - # Test 02 with nthreads - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - nthreads = 2 - expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps, nthreads) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - def xtest_fff_004(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4096 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(1, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - #print "src_len =", src_len, " ntaps =", ntaps - try: - self.assert_fft_float_ok2(expected_result, result_data, abs_eps=1.0) - except: - expected = open('expected', 'w') - for x in expected_result: - expected.write(`x` + '\n') - actual = open('actual', 'w') - for x in result_data: - actual.write(`x` + '\n') - raise - - def xtest_fff_005(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(1, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data, abs_eps=2.0) - - def xtest_fff_006(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(dec, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(dec, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data) - - def xtest_fff_007(self): - # test decimation with nthreads - random.seed(0) - nthreads = 2 - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(dec, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(dec, taps, nthreads) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data) - - def test_fff_get0(self): - random.seed(0) - for i in xrange(25): - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - - op = gr.fft_filter_fff(1, taps) - result_data = op.taps() - #print result_data - - self.assertEqual(taps, result_data) - - def test_ccc_get0(self): - random.seed(0) - for i in xrange(25): - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - - op = gr.fft_filter_ccc(1, taps) - result_data = op.taps() - #print result_data - - self.assertComplexTuplesAlmostEqual(taps, result_data, 4) - - -if __name__ == '__main__': - gr_unittest.run(test_fft_filter, "test_fft_filter.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py b/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py deleted file mode 100755 index 8d325fc3e6..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -class test_filter_delay_fc (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001_filter_delay_one_input (self): - - # expected result - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - tb = self.tb - - sampling_freq = 100 - - ntaps = 51 - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - dst2 = gr.vector_sink_c () - - # calculate taps - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - tb.connect (src1, head) - tb.connect (head, hd) - tb.connect (hd,dst2) - - tb.run () - - # get output - result_data = dst2.data () - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - def test_002_filter_delay_two_inputs (self): - - # giving the same signal to both the inputs should fetch the same results - # as above - - # expected result - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - - tb = self.tb - - sampling_freq = 100 - ntaps = 51 - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - dst2 = gr.vector_sink_c () - - - # calculate taps - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - tb.connect (src1, head) - tb.connect (head, (hd,0)) - tb.connect (head, (hd,1)) - tb.connect (hd,dst2) - tb.run () - - # get output - result_data = dst2.data () - - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_003_filter_delay_two_inputs (self): - - # give two different inputs - - # expected result - expected_result = ( -0.0020331963896751404j, - -0.0016448829555884004j, - -0.0032375147566199303j, - -0.0014826074475422502j, - -0.0033034090884029865j, - -0.00051144487224519253j, - -0.0043686260469257832j, - -0.0010198024101555347j, - -0.0082517862319946289j, - -0.003456643782556057j, - -0.014193611219525337j, - -0.005875137634575367j, - -0.020293503999710083j, - -0.0067503536120057106j, - -0.026798896491527557j, - -0.0073488112539052963j, - -0.037041611969470978j, - -0.010557252913713455j, - -0.055669989436864853j, - -0.018332764506340027j, - -0.089904911816120148j, - -0.033361352980136871j, - -0.16902604699134827j, - -0.074318811297416687j, - -0.58429563045501709j, - (7.2191945754696007e-09 -0.35892376303672791j), - (0.58778399229049683 +0.63660913705825806j), - (0.95105588436126709 +0.87681591510772705j), - (0.95105588436126709 +0.98705857992172241j), - (0.5877838134765625 +0.55447429418563843j), - (5.8516356205018383e-09 +0.026006083935499191j), - (-0.5877840518951416 -0.60616838932037354j), - (-0.95105588436126709 -0.9311758279800415j), - (-0.95105588436126709 -0.96169203519821167j), - (-0.5877838134765625 -0.57292771339416504j), - (-8.7774534307527574e-09 -0.0073488391935825348j), - (0.58778399229049683 +0.59720659255981445j), - (0.95105588436126709 +0.94438445568084717j), - (0.95105588436126709 +0.95582199096679688j), - (0.5877838134765625 +0.58196049928665161j), - (1.4629089051254596e-08 +0.0026587247848510742j), - (-0.5877840518951416 -0.59129220247268677j), - (-0.95105588436126709 -0.94841635227203369j), - (-0.95105588436126709 -0.95215457677841187j), - (-0.5877838134765625 -0.58535969257354736j), - (-1.7554906861505515e-08 -0.00051158666610717773j), - (0.58778399229049683 +0.58867418766021729j), - (0.95105582475662231 +0.94965213537216187j), - (0.95105588436126709 +0.95050644874572754j), - (0.5877838134765625 +0.58619076013565063j), - (2.3406542482007353e-08 +1.1920928955078125e-07j), - (-0.5877840518951416 -0.58783555030822754j), - (-0.95105588436126709 -0.95113480091094971j), - (-0.95105588436126709 -0.95113474130630493j), - (-0.5877838134765625 -0.58783555030822754j), - (-2.6332360292258272e-08 -8.1956386566162109e-08j), - (0.58778399229049683 +0.58783555030822754j), - (0.95105582475662231 +0.95113474130630493j), - (0.95105588436126709 +0.95113474130630493j), - (0.5877838134765625 +0.58783560991287231j), - (3.218399768911695e-08 +1.1920928955078125e-07j)) - - tb = self.tb - - sampling_freq = 100 - ntaps = 51 - - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE,sampling_freq * 0.10, 1.0) - src2 = gr.sig_source_f (sampling_freq, gr.GR_COS_WAVE,sampling_freq * 0.10, 1.0) - - head1 = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - head2 = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - dst2 = gr.vector_sink_c () - - tb.connect (src1, head1) - tb.connect (src2, head2) - - tb.connect (head1, (hd,0)) - tb.connect (head2, (hd,1)) - tb.connect (hd, dst2) - - tb.run () - - # get output - result_data = dst2.data () - - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - -if __name__ == '__main__': - gr_unittest.run(test_filter_delay_fc, "test_filter_delay_fc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py b/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py deleted file mode 100755 index e19bb28f31..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_fractional_resampler (gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000_make(self): - op = gr.fractional_interpolator_ff(0.0, 1.0) - op2 = gr.fractional_interpolator_cc(0.0, 1.0) - -if __name__ == '__main__': - gr_unittest.run(test_fractional_resampler, "test_fractional_resampler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py b/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py deleted file mode 100755 index 95b8c06641..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -def sincos(x): - return math.cos(x) + math.sin(x) * 1j - -class test_bytes_to_syms (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_bytes_to_syms_001 (self): - src_data = (0x01, 0x80, 0x03) - expected_result = (-1, -1, -1, -1, -1, -1, -1, +1, - +1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, +1, +1) - src = gr.vector_source_b (src_data) - op = gr.bytes_to_syms () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - def test_simple_framer (self): - src_data = (0x00, 0x11, 0x22, 0x33, - 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, - 0xcc, 0xdd, 0xee, 0xff) - - expected_result = ( - 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x00, 0x00, 0x11, 0x22, 0x33, 0x55, - 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x01, 0x44, 0x55, 0x66, 0x77, 0x55, - 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x02, 0x88, 0x99, 0xaa, 0xbb, 0x55, - 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x03, 0xcc, 0xdd, 0xee, 0xff, 0x55) - - src = gr.vector_source_b (src_data) - op = gr.simple_framer (4) - dst = gr.vector_sink_b () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - -if __name__ == '__main__': - gr_unittest.run(test_bytes_to_syms, "test_bytes_to_syms.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py deleted file mode 100755 index 161e4a5cc1..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_glfsr_source(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_make_b(self): - src = gr.glfsr_source_b(16) - self.assertEquals(src.mask(), 0x8016) - self.assertEquals(src.period(), 2**16-1) - - def test_001_degree_b(self): - self.assertRaises(RuntimeError, - lambda: gr.glfsr_source_b(0)) - self.assertRaises(RuntimeError, - lambda: gr.glfsr_source_b(33)) - - def test_002_correlation_b(self): - for degree in range(1,11): # Higher degrees take too long to correlate - src = gr.glfsr_source_b(degree, False) - b2f = gr.chunks_to_symbols_bf((-1.0,1.0), 1) - dst = gr.vector_sink_f() - del self.tb # Discard existing top block - self.tb = gr.top_block() - self.tb.connect(src, b2f, dst) - self.tb.run() - self.tb.disconnect_all() - actual_result = dst.data() - R = auto_correlate(actual_result) - self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin - for i in range(len(R)-1): - self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else - - def test_003_make_f(self): - src = gr.glfsr_source_f(16) - self.assertEquals(src.mask(), 0x8016) - self.assertEquals(src.period(), 2**16-1) - - def test_004_degree_f(self): - self.assertRaises(RuntimeError, - lambda: gr.glfsr_source_f(0)) - self.assertRaises(RuntimeError, - lambda: gr.glfsr_source_f(33)) - def test_005_correlation_f(self): - for degree in range(1,11): # Higher degrees take too long to correlate - src = gr.glfsr_source_f(degree, False) - dst = gr.vector_sink_f() - del self.tb # Discard existing top block - self.tb = gr.top_block() - self.tb.connect(src, dst) - self.tb.run() - - actual_result = dst.data() - R = auto_correlate(actual_result) - self.assertEqual(R[0], float(len(R))) # Auto-correlation peak at origin - for i in range(len(R)-1): - self.assertEqual(R[i+1], -1.0) # Auto-correlation minimum everywhere else - -def auto_correlate(data): - l = len(data) - R = [0,]*l - for lag in range(l): - for i in range(l): - R[lag] += data[i]*data[i-lag] - return R - -if __name__ == '__main__': - gr_unittest.run(test_glfsr_source, "test_glfsr_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py b/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py deleted file mode 100755 index 77f1b5f897..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -from math import pi, cos - -class test_goertzel(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def make_tone_data(self, rate, freq): - return [cos(2*pi*x*freq/rate) for x in range(rate)] - - def transform(self, src_data, rate, freq): - src = gr.vector_source_f(src_data, False) - dft = gr.goertzel_fc(rate, rate, freq) - dst = gr.vector_sink_c() - self.tb.connect(src, dft, dst) - self.tb.run() - return dst.data() - - def test_001(self): # Measure single tone magnitude - rate = 8000 - freq = 100 - bin = freq - src_data = self.make_tone_data(rate, freq) - expected_result = 0.5 - actual_result = abs(self.transform(src_data, rate, bin)[0]) - self.assertAlmostEqual(expected_result, actual_result, places=4) - - def test_002(self): # Measure off frequency magnitude - rate = 8000 - freq = 100 - bin = freq/2 - src_data = self.make_tone_data(rate, freq) - expected_result = 0.0 - actual_result = abs(self.transform(src_data, rate, bin)[0]) - self.assertAlmostEqual(expected_result, actual_result, places=4) - -if __name__ == '__main__': - gr_unittest.run(test_goertzel, "test_goertzel.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py b/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py deleted file mode 100755 index 27d01092bb..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -class test_hilbert (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_hilbert (self): - tb = self.tb - ntaps = 51 - sampling_freq = 100 - - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - hilb = gr.hilbert_fc (ntaps) - dst1 = gr.vector_sink_c () - tb.connect (src1, head) - tb.connect (head, hilb) - tb.connect (hilb, dst1) - tb.run () - dst_data = dst1.data () - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) - -if __name__ == '__main__': - gr_unittest.run(test_hilbert, "test_hilbert.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_iir.py deleted file mode 100755 index 06b8d767ed..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_iir (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_iir_direct_001 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = () - fbtaps = () - expected_result = (0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_002 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2,) - fbtaps = (0,) - expected_result = (2, 4, 6, 8, 10, 12, 14, 16) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_003 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11) - fbtaps = (0, 0) - expected_result = (2, 15, 28, 41, 54, 67, 80, 93) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_004 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11) - fbtaps = (0, -1) - expected_result = (2, 13, 15, 26, 28, 39, 41, 52) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_005 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11, 0) - fbtaps = (0, -1, 3) - expected_result = (2, 13, 21, 59, 58, 186, 68, 583) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_006 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2, 13, 21, 59, 58, 186, 68, 583) - fftaps = (2, 1) - fbtaps = (0, -1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps = (2, 11, 0) - fbtaps = (0, -1, 3) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_007 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2,2,5,5,8,8,11,11) - fftaps = (2, 1) - fbtaps = (0, -1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps = (2,0,1) - fbtaps = (0, -1) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_008 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2,4,4,10,18,14,26,56) - fftaps = (2,) - fbtaps = (0, 1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps_data = (1) - fbtaps = (0,0, -1,3) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - - - -if __name__ == '__main__': - gr_unittest.run(test_iir, "test_iir.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py deleted file mode 100755 index 9bd9977c75..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math - -class test_interp_fir_filter (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_fff (self): - taps = [1, 10, 100, 1000, 10000] - src_data = (0, 2, 3, 5, 7, 11, 13, 17) - interpolation = 3 - xr = (0,0,0,0,2,20,200,2003,20030,300,3005,30050,500,5007,50070,700,7011,70110,1100,11013,110130,1300,13017,130170) - expected_result = tuple ([float (x) for x in xr]) - - src = gr.vector_source_f (src_data) - op = gr.interp_fir_filter_fff (interpolation, taps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - L = min(len(result_data), len(expected_result)) - self.assertEqual (expected_result[0:L], result_data[0:L]) - - -if __name__ == '__main__': - gr_unittest.run(test_interp_fir_filter, "test_interp_fir_filter.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py deleted file mode 100755 index 6a62a6997b..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_pn_correlator_cc(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - - def tearDown(self): - self.tb = None - - def test_000_make(self): - c = gr.pn_correlator_cc(10) - - def test_001_correlate(self): - degree = 10 - length = 2**degree-1 - src = gr.glfsr_source_f(degree) - head = gr.head(gr.sizeof_float, length*length) - f2c = gr.float_to_complex() - corr = gr.pn_correlator_cc(degree) - dst = gr.vector_sink_c() - self.tb.connect(src, head, f2c, corr, dst) - self.tb.run() - data = dst.data() - self.assertEqual(data[-1], (1.0+0j)) - -if __name__ == '__main__': - gr_unittest.run(test_pn_correlator_cc, "test_pn_correlator_cc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py deleted file mode 100755 index 5fe89bdc7f..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_scrambler(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_scrambler_descrambler(self): - src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) - scrambler = gr.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler - descrambler = gr.descrambler_bb(0x8a, 0x7F, 7) - dst = gr.vector_sink_b() - self.tb.connect(src, scrambler, descrambler, dst) - self.tb.run() - self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization - - def test_additive_scrambler(self): - src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) - scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7) - descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7) - dst = gr.vector_sink_b() - self.tb.connect(src, scrambler, descrambler, dst) - self.tb.run() - self.assertEqual(src_data, dst.data()) - - def test_additive_scrambler_reset(self): - src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) - scrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100) - descrambler = gr.additive_scrambler_bb(0x8a, 0x7f, 7, 100) - dst = gr.vector_sink_b() - self.tb.connect(src, scrambler, descrambler, dst) - self.tb.run() - self.assertEqual(src_data, dst.data()) - -if __name__ == '__main__': - gr_unittest.run(test_scrambler, "test_scrambler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py deleted file mode 100755 index bfe2d8fc8c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_single_pole_iir(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = src_data - src = gr.vector_source_f(src_data) - op = gr.single_pole_iir_filter_ff (1.0) - dst = gr.vector_sink_f() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = (0, 125, 359.375, 689.453125, 1103.271484, 1590.36255) - src = gr.vector_source_f(src_data) - op = gr.single_pole_iir_filter_ff (0.125) - dst = gr.vector_sink_f() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 3) - - def test_003(self): - block_size = 2 - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = (0, 125, 250, 484.375, 718.75, 1048.828125) - src = gr.vector_source_f(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_float, block_size) - op = gr.single_pole_iir_filter_ff (0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_float, block_size) - dst = gr.vector_sink_f() - self.tb.connect (src, s2p, op, p2s, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 3) - - -if __name__ == '__main__': - gr_unittest.run(test_single_pole_iir, "test_single_pole_iir.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py deleted file mode 100755 index 353df1bc0d..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_single_pole_iir_cc(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = (0+0j, 1000+1000j, 2000+2000j, 3000+3000j, 4000+4000j, 5000+5000j) - expected_result = src_data - src = gr.vector_source_c(src_data) - op = gr.single_pole_iir_filter_cc (1.0) - dst = gr.vector_sink_c() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - src_data = (complex(0,0), complex(1000,-1000), complex(2000,-2000), complex(3000,-3000), complex(4000,-4000), complex(5000,-5000)) - expected_result = (complex(0,0), complex(125,-125), complex(359.375,-359.375), complex(689.453125,-689.453125), complex(1103.271484,-1103.271484), complex(1590.36255,-1590.36255)) - src = gr.vector_source_c(src_data) - op = gr.single_pole_iir_filter_cc (0.125) - dst = gr.vector_sink_c() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 3) - - def test_003(self): - block_size = 2 - src_data = (complex(0,0), complex(1000,-1000), complex(2000,-2000), complex(3000,-3000), complex(4000,-4000), complex(5000,-5000)) - expected_result = (complex(0,0), complex(125,-125), complex(250,-250), complex(484.375,-484.375), complex(718.75,-718.75), complex(1048.828125,-1048.828125)) - src = gr.vector_source_c(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, block_size) - op = gr.single_pole_iir_filter_cc (0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_gr_complex, block_size) - dst = gr.vector_sink_c() - self.tb.connect (src, s2p, op, p2s, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 3) - - -if __name__ == '__main__': - gr_unittest.run(test_single_pole_iir_cc, "test_single_pole_iir_cc.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/top_block.py b/gnuradio-core/src/python/gnuradio/gr/top_block.py index 43af8073b6..2d315a2780 100644 --- a/gnuradio-core/src/python/gnuradio/gr/top_block.py +++ b/gnuradio-core/src/python/gnuradio/gr/top_block.py @@ -85,6 +85,12 @@ class _top_block_waiter(_threading.Thread): # method in gr_top_block # class top_block(object): + """ + Top-level hierarchical block representing a flow-graph. + + This is a python wrapper around the C++ implementation to allow + python subclassing. + """ def __init__(self, name="top_block"): self._tb = top_block_swig(name) @@ -93,13 +99,13 @@ class top_block(object): raise RuntimeError("top_block: invalid state--did you forget to call gr.top_block.__init__ in a derived class?") return getattr(self._tb, name) - def start(self, max_noutput_items=100000): + def start(self, max_noutput_items=10000000): self._tb.start(max_noutput_items) def stop(self): self._tb.stop() - def run(self, max_noutput_items=100000): + def run(self, max_noutput_items=10000000): self.start(max_noutput_items) self.wait() diff --git a/gnuradio-core/src/python/gnuradio/gr_unittest.py b/gnuradio-core/src/python/gnuradio/gr_unittest.py index e4510a6eb9..c729566e88 100755 --- a/gnuradio-core/src/python/gnuradio/gr_unittest.py +++ b/gnuradio-core/src/python/gnuradio/gr_unittest.py @@ -19,6 +19,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # +""" +GNU radio specific extension of unittest. +""" import unittest import gr_xmlrunner diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/socket_stuff.py b/gnuradio-core/src/python/gnuradio/gruimpl/socket_stuff.py index 329fd2ed3d..489b6ab255 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/socket_stuff.py +++ b/gnuradio-core/src/python/gnuradio/gruimpl/socket_stuff.py @@ -27,9 +27,12 @@ import sys def tcp_connect_or_die(sock_addr): """ - @param sock_addr: (host, port) to connect to - @type sock_addr: tuple - @returns: socket or exits + + Args: + sock_addr: (host, port) to connect to (tuple) + + Returns: + : socket or exits """ s = socket.socket (socket.AF_INET, socket.SOCK_STREAM) try: @@ -42,9 +45,12 @@ def tcp_connect_or_die(sock_addr): def udp_connect_or_die(sock_addr): """ - @param sock_addr: (host, port) to connect to - @type sock_addr: tuple - @returns: socket or exits + + Args: + sock_addr: (host, port) to connect to (tuple) + + Returns: + : socket or exits """ s = socket.socket (socket.AF_INET, socket.SOCK_DGRAM) try: diff --git a/gnuradio-core/src/python/gnuradio/optfir.py b/gnuradio-core/src/python/gnuradio/optfir.py index bbf9ead747..bbd48dae75 100644 --- a/gnuradio-core/src/python/gnuradio/optfir.py +++ b/gnuradio-core/src/python/gnuradio/optfir.py @@ -32,18 +32,20 @@ from gnuradio import gr remez = gr.remez -# ---------------------------------------------------------------- - -## Builds a low pass filter. -# @param gain Filter gain in the passband (linear) -# @param Fs Sampling rate (sps) -# @param freq1 End of pass band (in Hz) -# @param freq2 Start of stop band (in Hz) -# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) -# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) -# @param nextra_taps Extra taps to use in the filter (default=2) def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, nextra_taps=2): + """ + Builds a low pass filter. + + Args: + gain: Filter gain in the passband (linear) + Fs: Sampling rate (sps) + freq1: End of pass band (in Hz) + freq2: Start of stop band (in Hz) + passband_ripple_db: Pass band ripple in dB (should be small, < 1) + stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) + nextra_taps: Extra taps to use in the filter (default=2) + """ passband_dev = passband_ripple_to_dev (passband_ripple_db) stopband_dev = stopband_atten_to_dev (stopband_atten_db) desired_ampls = (gain, 0) @@ -53,19 +55,23 @@ def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") return taps -## Builds a band pass filter. -# @param gain Filter gain in the passband (linear) -# @param Fs Sampling rate (sps) -# @param freq_sb1 End of stop band (in Hz) -# @param freq_pb1 Start of pass band (in Hz) -# @param freq_pb2 End of pass band (in Hz) -# @param freq_sb2 Start of stop band (in Hz) -# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) -# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) -# @param nextra_taps Extra taps to use in the filter (default=2) def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, passband_ripple_db, stopband_atten_db, nextra_taps=2): + """ + Builds a band pass filter. + + Args: + gain: Filter gain in the passband (linear) + Fs: Sampling rate (sps) + freq_sb1: End of stop band (in Hz) + freq_pb1: Start of pass band (in Hz) + freq_pb2: End of pass band (in Hz) + freq_sb2: Start of stop band (in Hz) + passband_ripple_db: Pass band ripple in dB (should be small, < 1) + stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) + nextra_taps: Extra taps to use in the filter (default=2) + """ passband_dev = passband_ripple_to_dev (passband_ripple_db) stopband_dev = stopband_atten_to_dev (stopband_atten_db) desired_ampls = (0, gain, 0) @@ -78,20 +84,24 @@ def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, return taps -## Builds a band pass filter with complex taps by making an LPF and -# spinning it up to the right center frequency -# @param gain Filter gain in the passband (linear) -# @param Fs Sampling rate (sps) -# @param freq_sb1 End of stop band (in Hz) -# @param freq_pb1 Start of pass band (in Hz) -# @param freq_pb2 End of pass band (in Hz) -# @param freq_sb2 Start of stop band (in Hz) -# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) -# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) -# @param nextra_taps Extra taps to use in the filter (default=2) def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, passband_ripple_db, stopband_atten_db, nextra_taps=2): + """ + Builds a band pass filter with complex taps by making an LPF and + spinning it up to the right center frequency + + Args: + gain: Filter gain in the passband (linear) + Fs: Sampling rate (sps) + freq_sb1: End of stop band (in Hz) + freq_pb1: Start of pass band (in Hz) + freq_pb2: End of pass band (in Hz) + freq_sb2: Start of stop band (in Hz) + passband_ripple_db: Pass band ripple in dB (should be small, < 1) + stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) + nextra_taps: Extra taps to use in the filter (default=2) + """ center_freq = (freq_pb2 + freq_pb1) / 2.0 lp_pb = (freq_pb2 - center_freq)/1.0 lp_sb = freq_sb2 - center_freq @@ -102,20 +112,24 @@ def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, return taps -## Builds a band reject filter -# spinning it up to the right center frequency -# @param gain Filter gain in the passband (linear) -# @param Fs Sampling rate (sps) -# @param freq_pb1 End of pass band (in Hz) -# @param freq_sb1 Start of stop band (in Hz) -# @param freq_sb2 End of stop band (in Hz) -# @param freq_pb2 Start of pass band (in Hz) -# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) -# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) -# @param nextra_taps Extra taps to use in the filter (default=2) def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, passband_ripple_db, stopband_atten_db, nextra_taps=2): + """ + Builds a band reject filter + spinning it up to the right center frequency + + Args: + gain: Filter gain in the passband (linear) + Fs: Sampling rate (sps) + freq_pb1: End of pass band (in Hz) + freq_sb1: Start of stop band (in Hz) + freq_sb2: End of stop band (in Hz) + freq_pb2: Start of pass band (in Hz) + passband_ripple_db: Pass band ripple in dB (should be small, < 1) + stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) + nextra_taps: Extra taps to use in the filter (default=2) + """ passband_dev = passband_ripple_to_dev (passband_ripple_db) stopband_dev = stopband_atten_to_dev (stopband_atten_db) desired_ampls = (gain, 0, gain) @@ -131,16 +145,20 @@ def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, return taps -## Builds a high pass filter. -# @param gain Filter gain in the passband (linear) -# @param Fs Sampling rate (sps) -# @param freq1 End of stop band (in Hz) -# @param freq2 Start of pass band (in Hz) -# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) -# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) -# @param nextra_taps Extra taps to use in the filter (default=2) def high_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, nextra_taps=2): + """ + Builds a high pass filter. + + Args: + gain: Filter gain in the passband (linear) + Fs: Sampling rate (sps) + freq1: End of stop band (in Hz) + freq2: Start of pass band (in Hz) + passband_ripple_db: Pass band ripple in dB (should be small, < 1) + stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) + nextra_taps: Extra taps to use in the filter (default=2) + """ passband_dev = passband_ripple_to_dev (passband_ripple_db) stopband_dev = stopband_atten_to_dev (stopband_atten_db) desired_ampls = (0, 1) |