本文整理汇总了Python中gnuradio.blocks.complex_to_mag方法的典型用法代码示例。如果您正苦于以下问题:Python blocks.complex_to_mag方法的具体用法?Python blocks.complex_to_mag怎么用?Python blocks.complex_to_mag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnuradio.blocks
的用法示例。
在下文中一共展示了blocks.complex_to_mag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gnuradio import blocks [as 别名]
# 或者: from gnuradio.blocks import complex_to_mag [as 别名]
def __init__(self, samp_rate_in, samp_rate_out, center_freq,
tune_freq, channel_width, transition_width, threshold,
iq_filename, dig_out_filename):
gr.top_block.__init__(self)
##################################################
# Variables
##################################################
self.cutoff_freq = channel_width/2
self.firdes_taps = firdes.low_pass(1, samp_rate_in,
self.cutoff_freq,
transition_width)
##################################################
# Blocks
##################################################
self.tuning_filter_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_in/samp_rate_out),
(self.firdes_taps),
tune_freq-center_freq,
samp_rate_in)
self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, iq_filename, False)
self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1*threshold, ))
# message sink is primary method of getting baseband data into waveconverter
self.sink_queue = gr.msg_queue()
self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, self.sink_queue, False)
# if directed, we also dump the baseband data into a file
if len(dig_out_filename) > 0:
print "Outputing baseband to waveform to " + dig_out_filename
self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, dig_out_filename, False)
self.blocks_file_sink_0.set_unbuffered(False)
##################################################
# Connections
##################################################
self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0))
self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_add_const_vxx_0, 0))
self.connect((self.blocks_file_source_0, 0), (self.tuning_filter_0, 0))
self.connect((self.tuning_filter_0, 0), (self.blocks_complex_to_mag_0, 0))
self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
if len(dig_out_filename) > 0:
self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
##############################################################
# This flowgraph consists of the following blocks:
# - a File Source that
# - a Frequency Translating FIR filter that tunes to the target signal
# - a quadrature demod block that demodules the FSK signal
# - an Add Const block that shifts the demodulated signal downwards, centering
# it around zero on the y-axis
# - a Binary Slicer that converts centered signal from floating point to binary
# - a File Sink that outputs
示例2: __init__
# 需要导入模块: from gnuradio import blocks [as 别名]
# 或者: from gnuradio.blocks import complex_to_mag [as 别名]
def __init__(self):
gr.top_block.__init__(self, "Top Block")
##################################################
# Variables
##################################################
self.trans_width = trans_width = 10e3
self.samp_rate = samp_rate = 1e6
self.mult_const = mult_const = 100
self.lowpass_decimation = lowpass_decimation = 10
self.freq = freq = 344940000
self.cutoff_freq = cutoff_freq = 50e3
##################################################
# Blocks
##################################################
self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
self.osmosdr_source_0.set_sample_rate(samp_rate)
self.osmosdr_source_0.set_center_freq(freq, 0)
self.osmosdr_source_0.set_freq_corr(0, 0)
self.osmosdr_source_0.set_dc_offset_mode(0, 0)
self.osmosdr_source_0.set_iq_balance_mode(0, 0)
self.osmosdr_source_0.set_gain_mode(True, 0)
self.osmosdr_source_0.set_gain(0, 0)
self.osmosdr_source_0.set_if_gain(20, 0)
self.osmosdr_source_0.set_bb_gain(20, 0)
self.osmosdr_source_0.set_antenna('', 0)
self.osmosdr_source_0.set_bandwidth(0, 0)
self.low_pass_filter_0 = filter.fir_filter_ccf(lowpass_decimation, firdes.low_pass(
1, samp_rate, cutoff_freq, trans_width, firdes.WIN_HAMMING, 6.76))
self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult_const, ))
self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/tmp/grcfifo', False)
self.blocks_file_sink_1.set_unbuffered(False)
self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
##################################################
# Connections
##################################################
self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0))
self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_1, 0))
self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_uchar_0, 0))
self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))
self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))