import pyfar as pf
import numpy as np
from scipy.signal import remez
import matplotlib.pyplot as plt
freq = [0, 0.2, 0.3, 1.0]
h_linear = pf.Signal(remez(151, freq, [1, 0], fs=2.), 44100)
h_min = pf.dsp.minimum_phase(h_linear, truncate=False)
pf.plot.use()
fig, axs = plt.subplots(3, figsize=(8, 6))
pf.plot.time(h_linear, ax=axs[0], unit='ms')
pf.plot.time(h_min, ax=axs[0], unit='ms')
axs[0].grid(True)
pf.plot.freq(h_linear, ax=axs[1])
pf.plot.group_delay(h_linear, ax=axs[2], unit="ms")
pf.plot.freq(h_min, ax=axs[1])
pf.plot.group_delay(h_min, ax=axs[2], unit="ms")
axs[2].legend(['Linear', 'Minimum'], loc=3, ncol=2)
axs[2].set_ylim(-2.5, 2.5)
