Cheby2-Lowpass Filter

    Filter data by passing data only below a certain frequency.
    The main purpose of this cheby2 filter is downsampling.
    
    This method will iteratively design a filter, whose pass
    band frequency is determined dynamically, such that the
    values above the stop band frequency are lower than -96dB.

    samples : Data to filter, type numpy.ndarray.
    freq    : The frequency above which signals are attenuated
              with 95 dB
    sr      : Sampling rate in Hz.
    maxorder: Maximal order of the designed cheby2 filter

def lowpass_cheby2(samples, freq, sr, maxorder=12):
    # type: (np.ndarray, float, int, int) -> np.ndarray
    """
    Cheby2-Lowpass Filter

    Filter data by passing data only below a certain frequency.
    The main purpose of this cheby2 filter is downsampling.
    
    This method will iteratively design a filter, whose pass
    band frequency is determined dynamically, such that the
    values above the stop band frequency are lower than -96dB.

    samples : Data to filter, type numpy.ndarray.
    freq    : The frequency above which signals are attenuated
              with 95 dB
    sr      : Sampling rate in Hz.
    maxorder: Maximal order of the designed cheby2 filter
    """
    if freq > sr*0.5:
        raise ValueError("Can't filter freq. above nyquist")
    b, a, freq_passband = lowpass_cheby2_coeffs(freq, sr, maxorder)
    return signal.lfilter(b, a, samples)