Example #1
0
    def initialize(self, doc, plot_lst):

        plot = figure(tools = utils.default_tools(),
                           y_range = [0, self.nrows],
                           x_range = [self.frequency_range[0],
                                      self.frequency_range[-1]],
                                      output_backend="webgl")
        plot.yaxis.formatter = FuncTickFormatter(code = """
                           return (%s - tick)*%s
                           """ % (self.nrows, self.time_per_sample))

        self.waterfall_renderer = []
        for i in range(self.nconnections):
            self.waterfall_renderer.append(
                WaterfallRenderer(palette = utils.PALETTES[self.palette],
                                  time_length = self.nrows,
                                  fft_length = self.size,
                                  min_value = self.values_range[0],
                                  max_value = self.values_range[-1]))
            plot.renderers.append(self.waterfall_renderer[i])

        self.plot = plot
        plot_lst.append(self)

        def callback():
            self.update( )

        doc.add_periodic_callback(callback, self.update_time)
Example #2
0
    def initialize(self, legend_list=utils.default_labels_f, update_time=100):
        self.plot = figure(
            tools=utils.default_tools(),
            active_drag='ypan',
            active_scroll='ywheel_zoom',
        )
        data = dict()
        data['x'] = []

        if self.is_message:
            nconn = 1
        else:
            nconn = self.nconnections
        for i in range(nconn):
            data['y' + str(i)] = []

        self.stream = ColumnDataSource(data)

        self.lines = []
        self.lines_markers = []
        self.legend_list = legend_list[:]
        for i in range(self.nconnections):
            self.lines.append(
                self.plot.line(x='x',
                               y='y' + str(i),
                               source=self.stream,
                               line_color='blue',
                               legend=self.legend_list[i]))
            self.lines_markers.append((None, None))

        self.add_custom_tools()

        # Add max-hold plot
        self.max_hold = None
        self.enable_max_hold(False)
        # max-hold plot done

        self.plot_lst.append(self)

        if self.name:
            self.set_title(self.name)

        self.doc.add_periodic_callback(self.update, update_time)
Example #3
0
    def initialize(self, doc, plot_lst):
        y_axis_type = 'log' if self.log_y else 'linear'
        x_axis_type = 'log' if self.log_x else 'linear'
        plot = figure(tools=utils.default_tools(),
                      active_drag='ypan',
                      active_scroll='ywheel_zoom',
                      y_axis_type=y_axis_type,
                      x_axis_type=x_axis_type,
                      output_backend="webgl")
        data = dict()
        tag_data = dict()
        data['x'] = []

        if self.is_message:
            nconnection = 1
        else:
            nconnection = self.nconnections

        for i in range(nconnection):
            data['y' + str(i)] = []

            tag_data['x' + str(i)] = []
            tag_data['y' + str(i)] = []
            if not self.is_message:
                tag_data['tags' + str(i)] = []
        stream = ColumnDataSource(data)
        self.lines = []  #TODO: de self ize
        self.lines_markers = []
        if self.tags_enabled:
            tag_stream = ColumnDataSource(tag_data)
            if not self.is_message:
                self.tags = []
                self.tags_marker = []
        else:
            tag_stream = None
        for i in range(nconnection):
            self.lines.append(
                plot.line(x='x',
                          y='y' + str(i),
                          source=stream,
                          line_color=self.colors[i],
                          line_width=self.widths[i],
                          line_alpha=self.alphas[i],
                          legend_label=self.legend_list[i]))
            self.lines_markers.append((None, None))
            if self.styles[i] == 'None':
                self.lines[i].visible = False
            else:
                self.lines[i].glyph.line_dash = self.styles[i]
            if self.tags_enabled:
                if not self.is_message:
                    self.tags.append(
                        LabelSet(x='x' + str(i),
                                 y='y' + str(i),
                                 text='tags' + str(i),
                                 level='glyph',
                                 x_offset=-20,
                                 y_offset=5,
                                 source=tag_stream,
                                 text_font_style='bold',
                                 text_font_size='11pt',
                                 render_mode='canvas'))
                    self.tags_marker.append(
                        plot.triangle(x='x' + str(i),
                                      y='y' + str(i),
                                      source=tag_stream,
                                      size=10,
                                      fill_color='red',
                                      line_color='red'))

                    plot.add_layout(self.tags[i])
        if self.title_text is not None:
            plot.title.text = self.title_text
        if self.y_range is not None:
            plot.y_range = Range1d(self.y_range[0], self.y_range[1])
        if self.x_range is not None:
            plot.x_range = Range1d(self.x_range[0], self.x_range[1])
        if self.y_label is not None:
            plot.yaxis[0].axis_label = self.y_label
        if self.x_label is not None:
            plot.xaxis[0].axis_label = self.x_label
        plot.xgrid.visible = self.x_grid
        plot.ygrid.visible = self.y_grid
        if self.en_axis_labels:
            plot.xaxis[0].axis_label_text_color = '#000000'
            plot.yaxis[0].axis_label_text_color = '#000000'
        else:
            plot.xaxis[0].axis_label_text_color = '#FFFFFF'
            plot.yaxis[0].axis_label_text_color = '#FFFFFF'
        plot.legend[0].visible = self.en_legend
        plot.legend[0].click_policy = "hide"

        self.plot = plot
        self.stream = stream
        self.add_custom_tools()
        plot_lst.append(self)

        for i in range(nconnection):
            self.use_line_marker(i, self.markers[i])

        def callback():
            self.update(tag_stream, stream)

        doc.add_periodic_callback(callback, self.update_time)
Example #4
0
    def initialize(self, legend_list=utils.default_labels_c, update_time=100):
        tools = utils.default_tools()
        tools.remove('ypan')
        tools.remove('ywheel_zoom')
        tools.append('pan')
        tools.append('wheel_zoom')
        self.plot = figure(tools=tools,
                           active_drag='pan',
                           active_scroll='wheel_zoom',
                           y_axis_type='linear',
                           x_axis_type='linear',
                           output_backend="webgl")
        data = dict()

        tag_data = dict()

        if self.is_message:
            nconnection = 1
        else:
            nconnection = self.nconnections

        for i in range(nconnection):
            data['y' + str(i)] = []
            data['x' + str(i)] = []

            tag_data['y' + str(i)] = []
            tag_data['x' + str(i)] = []

        for i in range(self.nconnections):
            tag_data['tags' + str(i)] = []

        self.stream = ColumnDataSource(data)
        self.tag_stream = ColumnDataSource(tag_data)

        self.lines_markers = []
        self.legend_list = legend_list[:]
        if not self.nconnections == 0:
            self.tags = []
            self.tags_marker = []
        for i in range(nconnection):
            self.lines_markers.append((self.plot.scatter(
                x='x' + str(i),
                y='y' + str(i),
                source=self.stream,
                legend=self.legend_list[i],
            ), 'o'))

            if not self.is_message:
                self.tags.append(
                    LabelSet(x='x' + str(i),
                             y='y' + str(i),
                             text='tags' + str(i),
                             level='glyph',
                             x_offset=-20,
                             y_offset=5,
                             source=self.tag_stream,
                             text_font_style='bold',
                             text_font_size='11pt',
                             render_mode='canvas'))
                self.tags_marker.append(
                    self.plot.triangle(
                        x='x' + str(i),
                        y='y' + str(i),
                        source=self.tag_stream,
                        size=10,
                        fill_color='red',
                    ))
                self.plot.add_layout(self.tags[i])

        self.add_custom_tools()
        self.plot_lst.append(self)

        if self.name:
            self.set_title(self.name)

        self.update_callback = self.doc.add_periodic_callback(
            self.update, update_time)
Example #5
0
    def initialize(self, doc, plot_lst):
        plot = figure(tools=utils.default_tools(),
                      active_drag='ypan',
                      active_scroll='ywheel_zoom',
                      output_backend="webgl")
        data = dict()
        data['x'] = []
        if self.is_message:
            nconn = 1
        else:
            nconn = self.nconnections
        for i in range(nconn):
            data['y' + str(i)] = []

        stream = ColumnDataSource(data)

        self.lines = []
        self.lines_markers = []
        for i in range(self.nconnections):
            self.lines.append(
                plot.line(x='x',
                          y='y' + str(i),
                          source=stream,
                          line_color=self.colors[i],
                          line_width=self.widths[i],
                          line_alpha=self.alphas[i],
                          legend_label=self.legend_list[i]))
            self.lines_markers.append((None, None))
            if self.styles[i] == 'None':
                self.lines[i].visible = False
            else:
                self.lines[i].glyph.line_dash = self.styles[i]

        if self.title_text is not None:
            plot.title.text = self.title_text
        if self.y_range is not None:
            plot.y_range = Range1d(self.y_range[0], self.y_range[1])
        if self.x_range is not None:
            plot.x_range = Range1d(self.x_range[0], self.x_range[1])
        if self.y_label is not None:
            plot.yaxis[0].axis_label = self.y_label
        if self.x_label is not None:
            plot.xaxis[0].axis_label = self.x_label
        plot.xgrid.visible = self.x_grid
        plot.ygrid.visible = self.y_grid
        if self.en_axis_labels:
            plot.xaxis[0].axis_label_text_color = '#000000'
            plot.yaxis[0].axis_label_text_color = '#000000'
        else:
            plot.xaxis[0].axis_label_text_color = '#FFFFFF'
            plot.yaxis[0].axis_label_text_color = '#FFFFFF'
        plot.legend[0].visible = self.en_legend
        plot.legend[0].click_policy = "hide"

        self.plot = plot
        self.stream = stream
        self.add_custom_tools()

        # Add max-hold plot
        max_hold_source = ColumnDataSource(
            data=dict(x=range(self.size), y=[float("-inf")] * self.size))
        self.max_hold_plot = plot.line(x='x',
                                       y='y',
                                       source=max_hold_source,
                                       line_color='green',
                                       line_dash='dotdash',
                                       legend_label='Max')
        callback = CustomJS(args=dict(max_hold_source=max_hold_source),
                            code="""
                        var no_of_elem = cb_obj.data.x.length;
                        var data = cb_obj.data;
                        const nconn = Object.getOwnPropertyNames(data).length -1;
                        var max_data = max_hold_source.data;
                        max_data.x = cb_obj.data.x;

                        for(let n = 0; n < nconn; n++) {
                               for (let i = 0; i < no_of_elem; i++) {
                                   if(max_data['y'][i] < data['y'+n][i]) {
                                       max_data['y'][i] = data['y'+n][i]
                                   }
                               }
                        }
                        max_hold_source.change.emit();
                        """)
        stream.js_on_change("streaming", callback)
        self.max_hold_plot.visible = self.max_hold
        # max-hold plot done

        plot_lst.append(self)

        def callback():
            self.update(stream)

        doc.add_periodic_callback(callback, self.update_time)
Example #6
0
    def initialize(self,
                   log_x=False,
                   log_y=False,
                   legend_list=utils.default_labels_c,
                   update_time=100):
        y_axis_type = 'log' if log_y else 'linear'
        x_axis_type = 'log' if log_x else 'linear'
        self.plot = figure(tools=utils.default_tools(),
                           active_drag='ypan',
                           active_scroll='ywheel_zoom',
                           y_axis_type=y_axis_type,
                           x_axis_type=x_axis_type)
        data = dict()
        data['x'] = []

        tag_data = dict()

        if self.is_message:
            nconnection = 1
        else:
            nconnection = self.nconnections

        for i in range(2 * nconnection):
            data['y' + str(i)] = []

            tag_data['y' + str(i)] = []
            tag_data['x' + str(i)] = []

        for i in range(self.nconnections):
            tag_data['tags' + str(i)] = []

        self.stream = ColumnDataSource(data)
        self.tag_stream = ColumnDataSource(tag_data)

        self.lines = []
        self.lines_markers = []
        self.legend_list = legend_list[:]
        if not self.nconnections == 0:
            self.tags = []
            self.tags_marker = []
        for i in range(2 * nconnection):
            self.lines.append(
                self.plot.line(x='x',
                               y='y' + str(i),
                               source=self.stream,
                               line_color='blue',
                               legend=self.legend_list[i]))
            self.lines_markers.append((None, None))

            if not self.is_message:
                self.tags.append(
                    LabelSet(x='x' + str(i),
                             y='y' + str(i),
                             text='tags' + str(i // 2),
                             level='glyph',
                             x_offset=-20,
                             y_offset=5,
                             source=self.tag_stream,
                             text_font_style='bold',
                             text_font_size='11pt',
                             render_mode='canvas'))
                self.tags_marker.append(
                    self.plot.triangle(
                        x='x' + str(i),
                        y='y' + str(i),
                        source=self.tag_stream,
                        size=10,
                        fill_color='red',
                    ))
                self.plot.add_layout(self.tags[i])

        self.add_custom_tools()
        self.plot_lst.append(self)

        if self.name:
            self.set_title(self.name)

        self.update_callback = self.doc.add_periodic_callback(
            self.update, update_time)