iir_widget.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pyrpl 作者: lneuhaus 项目源码 文件源码
def update_plot(self):
        # first, we compile the line plot data, then we iterate over them and
        # plot them. we then plot the scatter plots in the same manner
        tfargs = {}  # args to the call of iir.transfer_function
        frequencies = self.frequencies
        plot = OrderedDict()
        # plot underlying curve data
        try:
            plot['data'] = self.module._data_curve_object.data.values
        except AttributeError:  # no curve for plotting available
            plot['data'] = []
        # plot designed filter
        plot['filter_design'] = self.module.transfer_function(frequencies,
                                                                  **tfargs)
        # plot product
        try:
            plot['data_x_design'] = plot['data'] / plot['filter_design']
        except ValueError:
            try:
                plot['data_x_design'] = 1.0 / plot['filter_design']
            except:
                plot['data_x_design'] = []
        # plot everything (all lines) up to here
        for k, v in plot.items():
            self.graph_widget.plots[k].setData(frequencies[:len(v)],
                                               self._magnitude(v))
            self.graph_widget.plots[k+'_phase'].setData(frequencies[:len(v)],
                                                    self._phase(v))
        # plot poles and zeros
        aws = self.attribute_widgets
        for end in ['poles', 'zeros']:
            mag, phase = [], []
            for start in ['complex', 'real']:
                key = start+'_'+end
                freq = getattr(self.module, key)
                if start == 'complex':
                    freq = np.imag(freq)
                freq = np.abs(freq)
                tf = self.module.transfer_function(freq, **tfargs)
                selected = aws[key].attribute_value.selected
                brush = [pg.mkBrush(color='b')
                         if (num == selected)
                         else pg.mkBrush(color='y')
                         for num in range(aws[key].number)]
                mag += [{'pos': (fr, val), 'data': i, 'brush': br}
                 for (i, (fr, val, br))
                 in enumerate(zip(list(np.log10(freq)),
                                  list(self._magnitude(tf)),
                                  brush))]
                phase += [{'pos': (fr, val), 'data': i, 'brush': br}
                 for (i, (fr, val, br))
                 in enumerate(zip(list(np.log10(freq)),
                                  list(self._phase(tf)),
                                  brush))]
            self.graph_widget.plots[end].setPoints(mag)
            self.graph_widget.plots[end+'_phase'].setPoints(phase)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号