3 # Copyright 2004 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gr_unittest
26 class test_sig_source (gr_unittest.TestCase):
29 self.fg = gr.flow_graph ()
34 def test_hilbert (self):
39 expected_result = ( -1.4678005338941702e-11j,
40 -0.0011950774351134896j,
41 -0.0019336787518113852j,
42 -0.0034673355985432863j,
43 -0.0036765895783901215j,
44 -0.004916108213365078j,
45 -0.0042778430506587029j,
46 -0.006028641015291214j,
47 -0.005476709920912981j,
48 -0.0092810001224279404j,
49 -0.0095402700826525688j,
50 -0.016060983762145042j,
51 -0.016446959227323532j,
52 -0.02523401565849781j,
53 -0.024382550269365311j,
54 -0.035477779805660248j,
55 -0.033021725714206696j,
56 -0.048487484455108643j,
57 -0.04543270543217659j,
58 -0.069477587938308716j,
59 -0.066984444856643677j,
60 -0.10703597217798233j,
61 -0.10620346665382385j,
63 -0.19357112050056458j,
64 (7.2191945754696007e-09 -0.50004088878631592j),
65 (0.58778399229049683 -0.6155126690864563j),
66 (0.95105588436126709 -0.12377222627401352j),
67 (0.95105588436126709 +0.41524654626846313j),
68 (0.5877838134765625 +0.91611981391906738j),
69 (5.8516356205018383e-09 +1.0670661926269531j),
70 (-0.5877840518951416 +0.87856143712997437j),
71 (-0.95105588436126709 +0.35447561740875244j),
72 (-0.95105588436126709 -0.26055556535720825j),
73 (-0.5877838134765625 -0.77606213092803955j),
74 (-8.7774534307527574e-09 -0.96460390090942383j),
75 (0.58778399229049683 -0.78470128774642944j),
76 (0.95105588436126709 -0.28380891680717468j),
77 (0.95105588436126709 +0.32548999786376953j),
78 (0.5877838134765625 +0.82514488697052002j),
79 (1.4629089051254596e-08 +1.0096219778060913j),
80 (-0.5877840518951416 +0.81836479902267456j),
81 (-0.95105588436126709 +0.31451958417892456j),
82 (-0.95105588436126709 -0.3030143678188324j),
83 (-0.5877838134765625 -0.80480599403381348j),
84 (-1.7554906861505515e-08 -0.99516552686691284j),
85 (0.58778399229049683 -0.80540722608566284j),
86 (0.95105582475662231 -0.30557557940483093j),
87 (0.95105588436126709 +0.31097668409347534j),
88 (0.5877838134765625 +0.81027895212173462j),
89 (2.3406542482007353e-08 +1.0000816583633423j),
90 (-0.5877840518951416 +0.80908381938934326j),
91 (-0.95105588436126709 +0.30904293060302734j),
92 (-0.95105588436126709 -0.30904296040534973j),
93 (-0.5877838134765625 -0.80908387899398804j),
94 (-2.6332360292258272e-08 -1.0000815391540527j),
95 (0.58778399229049683 -0.80908381938934326j),
96 (0.95105582475662231 -0.30904299020767212j),
97 (0.95105588436126709 +0.30904293060302734j),
98 (0.5877838134765625 +0.80908381938934326j),
99 (3.218399768911695e-08 +1.0000815391540527j))
102 src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE,
103 sampling_freq * 0.10, 1.0)
105 head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10))
106 hilb = gr.hilbert_fc (ntaps)
107 dst1 = gr.vector_sink_c ()
108 fg.connect (src1, head)
109 fg.connect (head, hilb)
110 fg.connect (hilb, dst1)
112 dst_data = dst1.data ()
113 self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5)
115 if __name__ == '__main__':