Exemplo n.º 1
0
 def _setup_specest(self):
     """Select the chosen estimator and configure it, add it into the flow
     graph.
     """
     options = self.options
     specest_selector = {
         'welch': lambda: specest.welch(options.fft_len, options.overlap,
                                        options.ma_length, options.shift_fft,
                                        options.window_type, options.window_param),
         'welchsp': lambda: specest.welchsp(options.fft_len, options.overlap,
                                            options.alpha, options.shift_fft,
                                            options.window_type, options.window_param),
         'burg': lambda: specest.burg(options.samples, options.fft_len,
                                      options.order, options.shift_fft),
         'fcov': lambda: specest.fcov(options.samples, options.fft_len,
                                      options.order, options.shift_fft),
         'fmcov': lambda: specest.fmcov(options.samples, options.fft_len,
                                        options.order, options.shift_fft),
         'esprit': lambda: specest.esprit(options.order, options.correlation_size,
                                          options.samples, options.fft_len, 1),
         'music': lambda: specest.music(options.order, options.correlation_size,
                                        options.samples, options.fft_len, 1),
         'mtm': lambda: specest.mtm(options.fft_len, options.timebandwidthproduct,
                                    options.n_tapers, options.weight_method,
                                    options.shift_fft)}
     self.specest = specest_selector[options.method]()
     if self.options.verbose:
         verbose_output_estimator(options)
Exemplo n.º 2
0
 def setup_block(self, shift_fft):
     try:
         window = WIN_TYPE_IDX[self.window]
     except KeyError:
         print "Unkown window-type set for Welch!"
     self.block = specest.welch(self.fft_size, self.overlap,
                                self.mov_avg_len, shift_fft,
                                window, self.window_option)
     return (self.fft_size, self.fft_size)
Exemplo n.º 3
0
 def _setup_specest(self):
     options = self.options
     specest_selector = {
             'welch': lambda: specest.welch(options.fft_len, options.overlap, options.ma_length, options.shift_fft,
                                             options.window_type, options.window_param),
             'burg': lambda: specest.burg(options.samples, options.fft_len, options.order, options.shift_fft),
             'fcov': lambda: specest.fcov(options.samples, options.fft_len, options.order, options.shift_fft),
             'fmcov': lambda: specest.fmcov(options.samples, options.fft_len, options.order, options.shift_fft),
             'esprit': lambda: specest.esprit(options.sinusoids_count, options.correlation_size, options.samples, options.fft_len, 1),
             'music': lambda: specest.music(options.sinusoids_count, options.correlation_size, options.samples, options.fft_len, 1),
             'mtm': lambda: specest.mtm(options.fft_len, options.timebandwidthproduct, options.n_tapers,
                                        options.weight_method, options.shift_fft)}
     self.specest = specest_selector[options.method]()
Exemplo n.º 4
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-w",
            "--which",
            type="int",
            default=0,
            help="select which USRP (0, 1, ...) default is %default",
            metavar="NUM")
        parser.add_option(
            "-R",
            "--rx-subdev-spec",
            type="subdev",
            default=None,
            help=
            "select USRP Rx side A or B (default=first one with a daughterboard)"
        )
        parser.add_option("-A",
                          "--antenna",
                          default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option(
            "-d",
            "--decim",
            type="int",
            default=16,
            help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=None,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB [default is midpoint]")
        parser.add_option("-8",
                          "--width-8",
                          action="store_true",
                          default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("--no-hb",
                          action="store_true",
                          default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S",
                          "--oscilloscope",
                          action="store_true",
                          default=False,
                          help="Enable oscilloscope display")
        parser.add_option(
            "",
            "--avg-alpha",
            type="eng_float",
            default=1e-1,
            help="Set fftsink averaging factor, [default=%default]")
        parser.add_option("",
                          "--ref-scale",
                          type="eng_float",
                          default=13490.0,
                          help="Set dBFS=0dB input value, [default=%default]")
        parser.add_option("",
                          "--fft-size",
                          type="int",
                          default=512,
                          help="Set FFT frame size, [default=%default]")
        parser.add_option("-e",
                          "--order",
                          type="int",
                          default=4,
                          help="order of the AR filter for burg estimator")
        parser.add_option("",
                          "--shift-fft",
                          action="store_true",
                          default=True,
                          help="shift the DC carrier to the middle.")
        parser.add_option("-W",
                          "--waterfall",
                          action="store_true",
                          default=False,
                          help="Enable waterfall display")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
        self.options = options
        self.show_debug_info = True

        # build the graph
        if options.no_hb or (options.decim < 8):
            #Min decimation of this firmware is 4.
            #contains 4 Rx paths without halfbands and 0 tx paths.
            self.fpga_filename = "std_4rx_0tx.rbf"
            self.u = usrp.source_c(which=options.which,
                                   decim_rate=options.decim,
                                   fpga_filename=self.fpga_filename)
        else:
            #Min decimation of standard firmware is 8.
            #standard fpga firmware "std_2rxhb_2tx.rbf"
            #contains 2 Rx paths with halfband filters and 2 tx paths (the default)
            self.u = usrp.source_c(which=options.which,
                                   decim_rate=options.decim)

        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self.u.set_mux(
            usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        if options.width_8:
            width = 8
            shift = 8
            format = self.u.make_format(width, shift)
            print "format =", hex(format)
            r = self.u.set_format(format)
            print "set_format =", r

        # determine the daughterboard subdevice we're using
        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)

        input_rate = self.u.adc_freq() / self.u.decim_rate()

        self.scope = fftsink2.fft_sink_c(panel,
                                         fft_size=options.fft_size,
                                         sample_rate=input_rate,
                                         ref_scale=options.ref_scale,
                                         ref_level=80,
                                         y_divs=20,
                                         avg_alpha=options.avg_alpha)

        toskip = 1

        self.head = gr.head(gr.sizeof_gr_complex,
                            (toskip + 1) * options.fft_size)
        self.skip = gr.skiphead(gr.sizeof_gr_complex,
                                toskip * options.fft_size)
        mywindow1 = window.hamming(options.fft_size)
        ma_len = 200
        overlap = 100
        self.welch = specest.welch(options.fft_size, overlap, ma_len, True,
                                   mywindow1)
        self.f2c = gr.float_to_complex(options.fft_size)
        mywindow2 = window.rectangular(options.fft_size)
        self.ifft = gr.fft_vcc(options.fft_size, False, mywindow2, True)
        self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, options.fft_size)
        self.connect(self.u, self.welch, self.f2c, self.ifft, self.v2s,
                     self.scope)

        self._build_gui(vbox)
        self._setup_events()

        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.subdev.gain_range()
            options.gain = float(g[0] + g[1]) / 2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.subdev.freq_range()
            options.freq = float(r[0] + r[1]) / 2

        self.set_gain(options.gain)

        if options.antenna is not None:
            print "Selecting antenna %s" % (options.antenna, )
            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['fs@usb'].set_value(self.u.adc_freq() /
                                            self.u.decim_rate())
            self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
Exemplo n.º 5
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel
        
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-w", "--which", type="int", default=0,
                          help="select which USRP (0, 1, ...) default is %default",
			  metavar="NUM")
        parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select USRP Rx side A or B (default=first one with a daughterboard)")
        parser.add_option("-A", "--antenna", default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-d", "--decim", type="int", default=16,
                          help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=None,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB [default is midpoint]")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option( "--no-hb", action="store_true", default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
	parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
			  help="Set fftsink averaging factor, [default=%default]")
	parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
			  help="Set dBFS=0dB input value, [default=%default]")
        parser.add_option("", "--fft-size", type="int", default=512,
                          help="Set FFT frame size, [default=%default]");
	parser.add_option("-e", "--order", type="int", default=4,
                	  help="order of the AR filter for burg estimator")
	parser.add_option("", "--shift-fft", action="store_true", default=True,
                	  help="shift the DC carrier to the middle.")
        parser.add_option("-W", "--waterfall", action="store_true", default=False,
                          help="Enable waterfall display")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
	self.options = options
        self.show_debug_info = True
        
        # build the graph
        if options.no_hb or (options.decim<8):
          #Min decimation of this firmware is 4. 
          #contains 4 Rx paths without halfbands and 0 tx paths.
          self.fpga_filename="std_4rx_0tx.rbf"
          self.u = usrp.source_c(which=options.which, decim_rate=options.decim, fpga_filename=self.fpga_filename)
        else:
          #Min decimation of standard firmware is 8. 
          #standard fpga firmware "std_2rxhb_2tx.rbf" 
          #contains 2 Rx paths with halfband filters and 2 tx paths (the default)
          self.u = usrp.source_c(which=options.which, decim_rate=options.decim)

        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        if options.width_8:
            width = 8
            shift = 8
            format = self.u.make_format(width, shift)
            print "format =", hex(format)
            r = self.u.set_format(format)
            print "set_format =", r
            
        # determine the daughterboard subdevice we're using
        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)

        input_rate = self.u.adc_freq() / self.u.decim_rate()

        self.scope = fftsink2.fft_sink_c (panel, fft_size=options.fft_size, sample_rate=input_rate, 
					      ref_scale=options.ref_scale, ref_level=80, y_divs = 20,
					      avg_alpha=options.avg_alpha)


	toskip = 1

	self.head = gr.head(gr.sizeof_gr_complex, (toskip+1)*options.fft_size)
	self.skip = gr.skiphead(gr.sizeof_gr_complex, toskip*options.fft_size)
	mywindow1 = window.hamming(options.fft_size)
	ma_len = 200
	overlap = 100
	self.welch = specest.welch (options.fft_size, overlap, ma_len, True, mywindow1)
	self.f2c = gr.float_to_complex(options.fft_size)
	mywindow2 = window.rectangular(options.fft_size)
	self.ifft = gr.fft_vcc(options.fft_size, False, mywindow2, True)
	self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, options.fft_size)
        self.connect(self.u, self.welch, self.f2c, self.ifft, self.v2s, self.scope)

        self._build_gui(vbox)
	self._setup_events()
	
        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.subdev.gain_range()
            options.gain = float(g[0]+g[1])/2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.subdev.freq_range()
            options.freq = float(r[0]+r[1])/2

        self.set_gain(options.gain)

	if options.antenna is not None:
            print "Selecting antenna %s" % (options.antenna,)
            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
            self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")