def set_spectrum(self, freqs, levels, monitors, noise):
        timestamp = time.time()
        self._freqs = freqs
        if timestamp - self._timestamp > self._delayDraw:
            t1 = time.time()
            self._timestamp = timestamp

            self.__clear_plots()
            self._axes.axhline(noise,
                               color='black',
                               ls='--',
                               label='Noise level',
                               gid='line')
            for monitor in monitors:
                colour = monitor.get_colour()
                freq = monitor.get_frequency()
                self._axes.axvline(freq,
                                   color=colour,
                                   dashes=[2, 1],
                                   label='{:.6f}MHz'.format(freq),
                                   gid='line')
                self._axes.axhline(monitor.get_threshold(),
                                   color=colour,
                                   dashes=[2, 1],
                                   gid='line')

            Legend.create(self)

            self._spectrum.set_data(freqs, levels)
            self._axes.relim()
            self._axes.autoscale_view(True, True, True)
            self._axes.autoscale(self._toolbar.get_autoscale())

            self._canvas.draw()
            delay = time.time() - t1
            self._delayDraw += delay * 2.
            self._delayDraw /= 2.
            if self._delayDraw < 1. / MAX_SPECTRUM_FPS:
                self._delayDraw = 1. / MAX_SPECTRUM_FPS
Beispiel #2
0
    def set_spectrum(self, freqs, levels, monitors, noise):
        timestamp = time.time()
        self._freqs = freqs
        if timestamp - self._timestamp > self._delayDraw:
            t1 = time.time()
            self._timestamp = timestamp

            self.__clear_plots()
            self._axes.axhline(noise,
                               color='black',
                               ls='--',
                               label='Noise level',
                               gid='line')
            for monitor in monitors:
                colour = monitor.get_colour()
                freq = monitor.get_frequency()
                self._axes.axvline(freq,
                                   color=colour,
                                   dashes=[2, 1],
                                   label='{:.6f}MHz'.format(freq),
                                   gid='line')
                self._axes.axhline(monitor.get_threshold(),
                                   color=colour,
                                   dashes=[2, 1],
                                   gid='line')

            Legend.create(self)

            self._spectrum.set_data(freqs, levels)
            self._axes.relim()
            self._axes.autoscale_view(True, True, True)
            self._axes.autoscale(self._toolbar.get_autoscale())

            self._canvas.draw()
            delay = time.time() - t1
            self._delayDraw += delay * 2.
            self._delayDraw /= 2.
            if self._delayDraw < 1. / MAX_SPECTRUM_FPS:
                self._delayDraw = 1. / MAX_SPECTRUM_FPS
    def set_monitors(self, monitors, isLive):
        self._timer.Stop()
        self._monitors = monitors

        timestamp = time.time()
        if timestamp - self._timestamp > self._delayDraw:
            t1 = time.time()
            self._timestamp = timestamp

            tMin = None
            tMax = None

            height = SAMPLE_RATE / BINS
            height /= 1e6

            self.__clear_plots()
            timeNow = epoch2num(time.time())

            for monitor in monitors:
                freq = monitor.get_frequency()
                signals = []
                periods = []

                for period in monitor.get_periods():
                    tStart = epoch2num(period.start)
                    if period.end is not None:
                        tEnd = epoch2num(period.end)
                    else:
                        tEnd = timeNow
                    periods.append([tStart, tEnd - tStart])

                for signal in monitor.get_signals():
                    tStart = epoch2num(signal.start)
                    if signal.end is not None:
                        tEnd = epoch2num(signal.end)
                    else:
                        tEnd = timeNow
                    tMin = min(tMin, tStart)
                    tMax = max(tMax, tEnd)
                    signals.append([tStart, tEnd - tStart])

                colour = monitor.get_colour()
                self._axes.broken_barh(periods, [freq - height / 2, height],
                                       color=colour,
                                       alpha=0.2,
                                       gid='plot')
                self._axes.broken_barh(signals, [freq - height / 2, height],
                                       color=colour,
                                       gid='plot')
                self._axes.axhline(freq,
                                   color=colour,
                                   label='{:.6f}MHz'.format(freq),
                                   gid='plot')

            if isLive:
                tMax = timeNow
                self._axes.axvline(timeNow,
                                   color='black',
                                   linestyle='--',
                                   label='Latest',
                                   gid='plot')

            Legend.create(self)

            if tMax is None:
                self._axes.set_xlim(timeNow - 1. / 288, timeNow)
                self._axes.autoscale(axis='y')
            else:
                self._axes.set_xlim(tMin, tMax)
                self._axes.autoscale(self._toolbar.get_autoscale())

            self._axes.get_figure().autofmt_xdate()

            self._canvas.draw()

            delay = time.time() - t1
            self._delayDraw += delay * 2.
            self._delayDraw /= 2.
            if self._delayDraw < 1. / MAX_TIMELINE_FPS:
                self._delayDraw = 1. / MAX_TIMELINE_FPS

            if isLive:
                self._timer.Start(1000. / TIMELINE_FPS, True)
    def set_monitors(self, monitors, isLive):
        self._timer.Stop()
        self._monitors = monitors

        timestamp = time.time()
        if timestamp - self._timestamp > self._delayDraw:
            t1 = time.time()
            self._timestamp = timestamp

            tMin = None
            tMax = None

            height = SAMPLE_RATE / BINS
            height /= 1e6

            self.__clear_plots()
            timeNow = epoch2num(time.time())

            for monitor in monitors:
                freq = monitor.get_frequency()
                signals = []
                periods = []

                for period in monitor.get_periods():
                    tStart = epoch2num(period.start)
                    if period.end is not None:
                        tEnd = epoch2num(period.end)
                    else:
                        tEnd = timeNow
                    periods.append([tStart, tEnd - tStart])

                for signal in monitor.get_signals():
                    tStart = epoch2num(signal.start)
                    if signal.end is not None:
                        tEnd = epoch2num(signal.end)
                    else:
                        tEnd = timeNow
                    tMin = min(tMin, tStart)
                    tMax = max(tMax, tEnd)
                    signals.append([tStart, tEnd - tStart])

                colour = monitor.get_colour()
                self._axes.broken_barh(periods, [freq - height / 2, height],
                                       color=colour,
                                       alpha=0.2,
                                       gid='plot')
                self._axes.broken_barh(signals, [freq - height / 2, height],
                                       color=colour,
                                       gid='plot')
                self._axes.axhline(freq,
                                   color=colour,
                                   label='{:.6f}MHz'.format(freq),
                                   gid='plot')

            if isLive:
                tMax = timeNow
                self._axes.axvline(timeNow,
                                   color='black',
                                   linestyle='--',
                                   label='Latest',
                                   gid='plot')

            Legend.create(self)

            if tMax is None:
                self._axes.set_xlim(timeNow - 1. / 288, timeNow)
                self._axes.autoscale(axis='y')
            else:
                self._axes.set_xlim(tMin, tMax)
                self._axes.autoscale(self._toolbar.get_autoscale())

            self._axes.get_figure().autofmt_xdate()

            self._canvas.draw()

            delay = time.time() - t1
            self._delayDraw += delay * 2.
            self._delayDraw /= 2.
            if self._delayDraw < 1. / MAX_TIMELINE_FPS:
                self._delayDraw = 1. / MAX_TIMELINE_FPS

            if isLive:
                self._timer.Start(1000. / TIMELINE_FPS, True)