Exemplo n.º 1
0
    def update_plot(self, data):
        """Update main spectrum plot"""
        self.counter += 1

        # Apply smoothing to data
        if self.smooth:
            data["y"] = smooth(data["y"],
                               window_len=self.smooth_length,
                               window=self.smooth_window)

        # Draw main curve
        if self.main_curve:
            self.curve.setData(data["x"], data["y"])

        # Update peak hold data and draw peak hold curve
        if self.peak_hold:
            if self.peak_hold_data is None:
                self.peak_hold_data = data["y"].copy()
            else:
                for i, y in enumerate(data["y"]):
                    if y > self.peak_hold_data[i]:
                        self.peak_hold_data[i] = y
            self.curve_peak_hold.setData(data["x"], self.peak_hold_data)

        # Update average data and draw average curve
        if self.average:
            if self.average_data is None:
                self.average_data = data["y"].copy()
            else:
                for i, y in enumerate(data["y"]):
                    self.average_data[i] = (self.counter * self.average_data[i] + y) / (self.counter + 1)
            self.curve_average.setData(data["x"], self.average_data)

        # Draw persistence curves
        if self.persistence:
            if self.persistence_data is None:
                self.persistence_data = collections.deque(maxlen=self.persistence_length)
            else:
                for i, y in enumerate(self.persistence_data):
                    self.persistence_curves[i].setData(data["x"], y)
            self.persistence_data.appendleft(data["y"].copy())
Exemplo n.º 2
0
 def smooth_data(self, y):
     """Apply smoothing function to data"""
     return smooth(y,
                   window_len=self.smooth_length,
                   window=self.smooth_window)
Exemplo n.º 3
0
 def smooth_data(self, y):
     """Apply smoothing function to data"""
     return smooth(y, window_len=self.smooth_length, window=self.smooth_window)