Esempio n. 1
0
    def custom_line(self,
                    name: str,
                    data: np.ndarray,
                    offset: bool,
                    invert: bool = True):
        """
        :param offset:
        - True, for untriggered wave data:
            - line will be shifted and triggered (by offset_viewport()).
        - False, for triggered data and buffers:
            - line is immune to offset_viewport().

        :param invert:
        - True, for wave (data and buffers):
            - If wave data is inverted (edge_direction = -1),
              data will be plotted inverted.
        - False, for buffers and autocorrelated wave data:
            - Data is plotted as-is.
        """
        if self._renderer is None:
            return
        data = data / abs_max(data, 0.01) / 2
        if invert:
            data *= np.copysign(1, self._wave.amplification)
        self._renderer.update_custom_line(name,
                                          self._wave_idx,
                                          self._stride,
                                          data,
                                          offset=offset)
Esempio n. 2
0
def sign_times_peak(data: np.ndarray) -> np.ndarray:
    """
    Computes peak = max(abs(data)).
    Returns `peak` for positive parts of data, and `-peak` for negative parts,
    and heavily amplifies parts of the wave near zero.
    """
    data = data.copy()

    peak = abs_max(data)
    data *= SIGN_AMPLIFICATION / (peak + MIN_AMPLITUDE)

    sign_data = np.tanh(data)
    sign_data *= peak

    return sign_data