⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qa_agc.py

📁 这是用python语言写的一个数字广播的信号处理工具包。利用它
💻 PY
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/env python## Copyright 2004 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_unittestimport mathtest_output = Falseclass test_sig_source (gr_unittest.TestCase):    def setUp (self):        self.fg = gr.flow_graph ()    def tearDown (self):        self.fg = None        def test_001(self):        ''' Test the complex AGC loop (single rate input) '''        fg = self.fg        expected_result = (            (100.000244140625+7.2191943445432116e-07j),            (72.892257690429688+52.959323883056641j),            (25.089065551757812+77.216217041015625j),            (-22.611061096191406+69.589706420898438j),            (-53.357715606689453+38.766635894775391j),            (-59.458671569824219+3.4792964243024471e-07j),            (-43.373462677001953-31.512666702270508j),            (-14.94139289855957-45.984889984130859j),            (13.478158950805664-41.48150634765625j),            (31.838506698608398-23.132022857666016j),            (35.519271850585938-3.1176801940091536e-07j),            (25.942903518676758+18.848621368408203j),            (8.9492912292480469+27.5430908203125j),            (-8.0852642059326172+24.883890151977539j),            (-19.131628036499023+13.899936676025391j),            (-21.383295059204102+3.1281737733479531e-07j),            (-15.650330543518066-11.370632171630859j),            (-5.4110145568847656-16.65339469909668j),            (4.9008159637451172-15.083160400390625j),            (11.628337860107422-8.4484796524047852j),            (13.036135673522949-2.288476110834381e-07j),            (9.5726661682128906+6.954948902130127j),            (3.3216962814331055+10.223132133483887j),            (-3.0204284191131592+9.2959251403808594j),            (-7.1977195739746094+5.2294478416442871j),            (-8.1072216033935547+1.8976157889483147e-07j),            (-5.9838657379150391-4.3475332260131836j),            (-2.0879747867584229-6.4261269569396973j),            (1.9100792407989502-5.8786196708679199j),            (4.5814824104309082-3.3286411762237549j),            (5.1967458724975586-1.3684227440080576e-07j),            (3.8647139072418213+2.8078789710998535j),            (1.3594740629196167+4.1840314865112305j),            (-1.2544282674789429+3.8607344627380371j),            (-3.0366206169128418+2.2062335014343262j),            (-3.4781389236450195+1.1194014604143376e-07j),            (-2.6133756637573242-1.8987287282943726j),            (-0.9293016791343689-2.8600969314575195j),            (0.86727333068847656-2.6691930294036865j),            (2.1243946552276611-1.5434627532958984j),            (2.4633183479309082-8.6486437567145913e-08j),            (1.8744727373123169+1.3618841171264648j),            (0.67528903484344482+2.0783262252807617j),            (-0.63866174221038818+1.965599536895752j),            (-1.5857341289520264+1.152103066444397j),            (-1.8640764951705933+7.6355092915036948e-08j),            (-1.4381576776504517-1.0448826551437378j),            (-0.52529704570770264-1.6166983842849731j),            (0.50366902351379395-1.5501341819763184j),            (1.26766037940979-0.92100900411605835j))        sampling_freq = 100        src1 = gr.sig_source_c (sampling_freq, gr.GR_SIN_WAVE,                                sampling_freq * 0.10, 100.0)        dst1 = gr.vector_sink_c ()        head = gr.head (gr.sizeof_gr_complex, int (5*sampling_freq * 0.10))        agc = gr.agc_cc(1e-3, 1, 1, 1000)                fg.connect (src1, head)        fg.connect (head, agc)        fg.connect (agc, dst1)        if test_output == True:            fg.connect (agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc_cc.dat"))        fg.run ()        dst_data = dst1.data ()        self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 4)    def test_002(self):        ''' Test the floating point AGC loop (single rate input) '''        fg = self.fg        expected_result = (            7.2191943445432116e-07,            58.837181091308594,            89.700050354003906,            81.264183044433594,            45.506141662597656,            4.269894304798072e-07,            -42.948936462402344,            -65.50335693359375,            -59.368724822998047,            -33.261005401611328,            -4.683740257860336e-07,            31.423542022705078,            47.950984954833984,            43.485683441162109,            24.378345489501953,            5.7254135299444897e-07,            -23.062990188598633,            -35.218441009521484,            -31.964075088500977,            -17.934831619262695,            -5.0591745548445033e-07,            16.998210906982422,            25.982204437255859,            23.606258392333984,            13.260685920715332,            4.9936483037527069e-07,            -12.59880542755127,            -19.28221321105957,            -17.54347038269043,            -9.8700437545776367,            -4.188150626305287e-07,            9.4074573516845703,            14.422011375427246,            13.145503044128418,            7.41046142578125,            3.8512698097292741e-07,            -7.0924453735351562,            -10.896408081054688,            -9.9552040100097656,            -5.6262712478637695,            -3.1982864356905338e-07,            5.4131259918212891,            8.3389215469360352,            7.6409502029418945,            4.3320145606994629,            2.882407841298118e-07,            -4.194943904876709,            -6.4837145805358887,            -5.9621825218200684,            -3.3931560516357422)        sampling_freq = 100        src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE,                                sampling_freq * 0.10, 100.0)        dst1 = gr.vector_sink_f ()        head = gr.head (gr.sizeof_float, int (5*sampling_freq * 0.10))        agc = gr.agc_ff(1e-3, 1, 1, 1000)                fg.connect (src1, head)        fg.connect (head, agc)        fg.connect (agc, dst1)        if test_output == True:            fg.connect (agc, gr.file_sink(gr.sizeof_float, "test_agc_ff.dat"))        fg.run ()        dst_data = dst1.data ()        self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 4)    def test_003(self):        ''' Test the complex AGC loop (attack and decay rate inputs) '''        fg = self.fg        expected_result = \                        ((100.000244140625+7.2191943445432116e-07j),                         (0.80881959199905396+0.58764183521270752j),                         (0.30894950032234192+0.95084899663925171j),                         (-0.30895623564720154+0.95086973905563354j),                         (-0.80887287855148315+0.58768033981323242j),                         (-0.99984413385391235+5.850709250410091e-09j),                         (-0.80889981985092163-0.58770018815994263j),                         (-0.30897706747055054-0.95093393325805664j),                         (0.30898112058639526-0.95094609260559082j),                         (0.80893135070800781-0.58772283792495728j),                         (0.99990922212600708-8.7766354184282136e-09j),                         (0.80894720554351807+0.58773452043533325j),                         (0.30899339914321899+0.95098406076431274j),                         (-0.30899572372436523+0.95099133253097534j),                         (-0.80896598100662231+0.58774799108505249j),                         (-0.99994778633117676+1.4628290578855285e-08j),                         (-0.80897533893585205-0.58775502443313599j),                         (-0.30900305509567261-0.95101380348205566j),                         (0.30900448560714722-0.95101797580718994j),                         (0.80898630619049072-0.58776277303695679j),                         (0.99997037649154663-1.7554345532744264e-08j),                         (0.80899184942245483+0.58776694536209106j),                         (0.30900871753692627+0.95103120803833008j),                         (-0.30900952219963074+0.95103377103805542j),                         (-0.8089984655380249+0.58777159452438354j),                         (-0.99998390674591064+2.3406109050938539e-08j),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -