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)
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]()
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(usage="%prog: [options]") parser.add_option("-N", "--dpsslength", type="int", help="Length of the DPSS", default="512") parser.add_option("-B", "--timebandwidthproduct", type="float", help="Time Bandwidthproduct used to calculate the DPSS", default="3") parser.add_option("-K", "--tapers", type="int", help="Number of Tapers used to calculate the Spectrum", default="5") parser.add_option("-W", "--weighting", type="choice", choices=("unity", "eigenvalues" ,"adaptive" ), help="weighting-type to be used (unity, eigenvalues, adaptive) ", default="adaptive") (options, args) = parser.parse_args () self.options = options #setting up our signal self.samplingrate = 48000 self.source = analog.sig_source_c(self.samplingrate, analog.GR_SIN_WAVE, 3000, 1) self.noise = analog.noise_source_c(analog.GR_GAUSSIAN,0.5) self.add = blocks.add_cc() self.throttle = blocks.throttle(gr.sizeof_gr_complex, self.samplingrate) #the actual spectrum estimator self.v2s = blocks.vector_to_stream(gr.sizeof_float, self.options.dpsslength) self.mtm = specest.mtm( N = self.options.dpsslength, NW = self.options.timebandwidthproduct, K = self.options.tapers, weighting = self.options.weighting ) self.scope = specest.spectrum_sink_f( panel, title='Spectrum with %s weighting, Length %i and %i Tapers' % ( self.options.weighting, self.options.dpsslength, self.options.tapers ), spec_size=self.options.dpsslength, sample_rate=self.samplingrate, ref_level=80, avg_alpha=0.8, y_per_div=20 ) self.connect(self.source, (self.add, 0) ) self.connect(self.noise, (self.add, 1) ) self.connect(self.add, self.throttle, self.mtm) self.connect(self.mtm, self.v2s, self.scope) self._build_gui(vbox)
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(usage="%prog: [options]") parser.add_option("-N", "--dpsslength", type="int", help="Length of the DPSS", default="512") parser.add_option("-B", "--timebandwidthproduct", type="float", help="Time Bandwidthproduct used to calculate the DPSS", default="3") parser.add_option("-K", "--tapers", type="int", help="Number of Tapers used to calculate the Spectrum", default="5") parser.add_option("-W", "--weighting", type="choice", choices=("unity", "eigenvalues" ,"adaptive" ), help="weighting-type to be used (unity, eigenvalues, adaptive) ", default="adaptive") (options, args) = parser.parse_args () self.options = options #setting up our signal self.samplingrate = 48000 self.source = gr.sig_source_c(self.samplingrate, gr.GR_SIN_WAVE, 3000, 1) self.noise = gr.noise_source_c(gr.GR_GAUSSIAN,0.5) self.add = gr.add_cc() self.throttle = gr.throttle(gr.sizeof_gr_complex, self.samplingrate) #the actual spectrum estimator self.v2s = gr.vector_to_stream(gr.sizeof_float, self.options.dpsslength) self.mtm = specest.mtm(N = self.options.dpsslength, NW = self.options.timebandwidthproduct, K = self.options.tapers, weighting = self.options.weighting) self.scope = specest.spec_sink_f(panel, title='Spectrum with %s weighting, Length %i and %i Tapers' % ( self.options.weighting, self.options.dpsslength, self.options.tapers ), spec_size=self.options.dpsslength, sample_rate=self.samplingrate, ref_level=80, avg_alpha=0.8, y_per_div=20) self.connect(self.source, (self.add, 0) ) self.connect(self.noise, (self.add, 1) ) self.connect(self.add, self.throttle, self.mtm) self.connect(self.mtm, self.v2s, self.scope) self._build_gui(vbox)
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)
def setup_block(self, shift_fft): self.block = specest.mtm(self.dpss_len, self.tbp, self.num_tap, self.weight_method, shift_fft) return (self.dpss_len, self.dpss_len)